Array, X & Y Koordinaten Mitte finden

  • Hallo,

    ich bin leider noch nicht wirklich weiter. Also ich versuche immer noch die im Array als 999999 markierten Einträge so abzuarbeiten das jeweils die mitte gefunden wird.

    Er soll wenn er auf der Y Achse ein 999999 gefunden hat weiterzählen bis 0 kommt. Dann die Anzahl halbieren und von dort aus die X Achse durchlaufen und die Mitte mit 777777 setzen sodass der Wert 777777 in der Mitte von der X und Y Achse liegt!!

    Die Randzählung soll 2 Pixel sein.

    Als Ergebnis hab ich dann die Nullinie des Types...aber es funzt nicht!! Wer kann helfen??

    Edit:

    Spoiler anzeigen

    [autoit#include <GuiConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    #include <ScreenCapture.au3>
    #include <WinAPI.au3>
    #include <File.au3>
    #include <Array.au3>
    Opt('MustDeclareVars', 1)
    Local $hBitmap, $hImage, $sImageType, $iX, $iY, $iXc, $iYc, $iMemo, $iPixelColor, $count, $File, $color1, $oForm, $color, $dc, $setpixel, $realesedc
    Local $hGraphic, $hBitmap, $hBackbuffer, $save, $hPen, $hWind, $cPix, $line, $split, $fRand
    Local $midY[1]
    Local $midX[1]
    Local $found[1]
    $File = FileOpen(@ScriptDir & "\coords.txt", 2)
    $fRand = FileOpen(@ScriptDir & "\cRand.txt", 2)
    _Main()
    Func _Main()
    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\PicA.jpg')
    $sImageType = _GDIPlus_EncodersGetCLSID("JPG")
    $iX = _GDIPlus_ImageGetWidth($hImage)
    $iY = _GDIPlus_ImageGetHeight($hImage)
    Local $aCoords[$iX][$iY]
    $oForm = GUICreate("GDI+", ($iX), ($iY))
    GUISetBkColor(0xFFFFFF)
    GUISetState()
    $hWind = WinGetHandle($oForm)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWind)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iX, $iY, $hGraphic)
    $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsClear($hBackbuffer, 0xFFFFFFFF)
    For $iXc = 0 To $iX - 1
    For $iYc = 0 To $iY - 1
    $iPixelColor = Hex(_GDIPlus_GetPixel($hImage, $iXc, $iYc), 6)
    If Dec($iPixelColor) < Dec('999999') Then
    ;$count = $count + 1
    ;FileWrite($File, $iXc & "," & $iYc & @CRLF)
    $aCoords[$iXc][$iYc] = 999999
    SetPixel($oForm, $iXc, $iYc, $color)
    $hPen = _GDIPlus_PenCreate(0xFF000000);
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $iXc, $iYc, $iXc + 1, $iYc + 1, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iXc, $iYc, $iXc + 1, $iYc + 1, $hPen)
    Else
    $aCoords[$iXc][$iYc] = 0
    EndIf
    Next
    Next
    ;$save = _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & '\Image1.jpg')
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ;FileClose($File)
    _GDIPlus_Shutdown()
    ;_ArrayDisplay($aCoords, Default, Default, 1)

    For $iXc = 0 To $iX - 1
    For $iYc = 0 To $iY - 1
    If $aCoords[$iXc][$iYc] = 999999 Then
    If $aCoords[$iXc - 1][$iYc] = 0 Or $aCoords[$iXc + 1][$iYc] = 0 Or $aCoords[$iXc][$iYc - 1] = 0 Or $aCoords[$iXc][$iYc + 1] = 0 Then
    $aCoords[$iXc][$iYc] = 777777
    FileWrite($fRand, $iXc & "," & $iYc & @CRLF)
    EndIf
    EndIf
    Next
    Next
    FileClose($fRand)
    _ArrayDisplay($aCoords, Default, Default, 1)
    For $iXc = 0 To $iX - 1
    For $iYc = 0 To $iY - 1
    If $aCoords[$iXc][$iYc] = 777777 Then
    For $iYc2 = $iYc To $iY - 1
    If $aCoords[$iXc][$iYc2] = 0 Then
    If $aCoords[$iXc][$iYc + Ceiling(Round(($iYc2 - $iYc) / 2) - 1)] = 777777 Then
    $aCoords[$iXc][$iYc + Ceiling(Round(($iYc2 - $iYc) / 2) - 1)] = 777777
    $iYc = $iYc2
    ExitLoop
    Else
    $aCoords[$iXc][$iYc + Ceiling(Round(($iYc2 - $iYc) / 2) - 1)] = 111111 ; eher rechts ausgerichtet
    $iYc = $iYc2
    ExitLoop
    EndIf
    EndIf
    Next
    EndIf
    Next
    Next
    For $iYc = 0 To $iY - 1
    For $iXc = 0 To $iX - 1
    If $aCoords[$iXc][$iYc] = 777777 Then
    For $iXc2 = $iXc To $iX - 1
    If $aCoords[$iXc2][$iYc] = 0 Then
    If $aCoords[($iXc - 1) + Ceiling(Round(($iXc2 - $iXc) / 2))][$iYc] = 777777 Then
    $aCoords[($iXc - 1) + Ceiling(Round(($iXc2 - $iXc) / 2))][$iYc] = 777777
    $iXc = $iXc2
    ExitLoop
    Else
    $aCoords[($iXc - 1) + Ceiling(Round(($iXc2 - $iXc) / 2))][$iYc] = 111111 ; eher rechts ausgerichtet
    $iXc = $iXc2
    ExitLoop
    EndIf
    EndIf
    Next
    EndIf
    Next
    Next
    ;_ArrayDisplay($aCoords, Default, Default, 1)
    For $iXc = 0 To $iX - 1
    For $iYc = 0 To $iY - 1
    If $aCoords[$iXc][$iYc] = 777777 Or $aCoords[$iXc][$iYc] = 999999 Then
    $aCoords[$iXc][$iYc] = 0
    Else
    ;$aCoords[$iXc][$iYc] = 888888
    EndIf
    Next
    Next
    For $iXc = 0 To $iX - 1
    For $iYc = 0 To $iY - 1
    If $aCoords[$iXc][$iYc] = 111111 Then
    For $iYc2 = $iYc To $iY - 1
    If $aCoords[$iXc][$iYc2] = 0 Then
    $aCoords[$iXc][$iYc + Ceiling(Round(($iYc2 - $iYc) / 2))] = 111111
    $iYc = $iYc2
    ExitLoop
    ElseIf $aCoords[$iXc][$iYc2] = 111111 Then
    $aCoords[$iXc][$iYc2] = 0
    EndIf
    Next
    EndIf
    Next
    Next
    For $iYc = 0 To $iY - 1
    For $iXc = 0 To $iX - 1
    If $aCoords[$iXc][$iYc] = 111111 Then
    For $iXc2 = $iXc To $iX - 1
    If $aCoords[$iXc2][$iYc] = 0 Then
    $aCoords[$iXc + Ceiling(Round(($iXc2 - $iXc) / 2))][$iYc] = 111111
    $iXc = $iXc2
    ExitLoop
    ElseIf $aCoords[$iXc2][$iYc] = 111111 Then
    $aCoords[$iXc2][$iYc] = 0
    EndIf
    Next
    EndIf
    Next
    Next
    ;_ArrayDisplay($aCoords, Default, Default, 1)
    For $iXc = 0 To $iX - 1
    For $iYc = 0 To $iY - 1
    If $aCoords[$iXc][$iYc] = 111111 Then
    FileWrite($File, $iXc & "," & $iYc & @CRLF)
    EndIf
    Next
    Next

    Dim $aRec
    If Not _FileReadToArray(@ScriptDir & "\cRand.txt", $aRec) Then
    MsgBox(4096, "Fehler", "Fehler beim Einlesen der Datei in das Array!" & @CRLF & "Fehlercode: " & @error)
    Exit
    EndIf
    For $x = 1 To $aRec[0]
    $split = StringSplit($aRec[$x], ',', 1)
    $aCoords[$split[1]][$split[2]] = 999999
    ;MsgBox(0, 'Datensatz ' & $x & ':', $aRec[$x])
    Next

    ;_ArrayDisplay($aCoords, Default, Default, 1)
    FileClose($File)
    EndFunc ;==>_Main


    ; Gibt eine Zeile im Memo-Fenster aus
    Func MemoWrite($sMessage = '')
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
    EndFunc ;==>MemoWrite
    ; _GDIPlus_GetPixel
    Func _GDIPlus_GetPixel($hBitmap, $x, $Y)
    Local $result = DllCall($ghGDIPDLL, "int", "GdipBitmapGetPixel", "ptr", $hBitmap, "int", $x, "int", $Y, "dword*", 0)
    If @error Then Return SetError(1, 0, 0)
    Return SetError($result[0], 1, $result[4])
    EndFunc ;==>_GDIPlus_GetPixel
    ;SetPixel
    Func SetPixel($oForm, $x, $Y, $color)
    $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", $oForm)
    $setpixel = DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $x, "long", $Y, "long", $color)
    $realesedc = DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $dc[0])
    EndFunc ;==>SetPixel
    [/autoit]

  • Es geht um Schrifterkennung bzw. Schriftartenerkennung...

    Ich will in einer Schleife für alle Schriften die ich habe für jeden "Type" einer Schrift bestimmte Daten festhalten. Und dazu gehört auch die Mittellinie.

    Die soll das "nackte" Zeichen darstellen, sodass wenn man die Linie "nachgeht" das gescannte "Type" wiedererkannt werden kann.


    Neues Edit:

    Spoiler anzeigen
    [autoit]

    #include <GuiConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    #include <ScreenCapture.au3>
    #include <WinAPI.au3>
    #include <File.au3>
    #include <Array.au3>
    Opt('MustDeclareVars', 1)
    Local $hBitmap, $hImage, $sImageType, $iX, $iY, $iXc, $iYc, $iMemo, $iPixelColor, $count, $File, $color1, $oForm, $color, $dc, $setpixel, $realesedc
    Local $hGraphic, $hBitmap, $hBackbuffer, $save, $hPen, $hWind, $cPix, $line, $split, $split0, $split12, $split17, $split1, $split2, $split3, $fRand
    Local $midY[1]
    Local $midX[1]
    Local $found[1]
    $File = FileOpen(@ScriptDir & "\coords.txt", 2)
    $fRand = FileOpen(@ScriptDir & "\cRand.txt", 2)
    _Main()
    Func _Main()
    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\Picaa.jpg')
    $sImageType = _GDIPlus_EncodersGetCLSID("JPG")
    $iX = _GDIPlus_ImageGetWidth($hImage)
    $iY = _GDIPlus_ImageGetHeight($hImage)
    Local $aCoords[$iX][$iY]
    $oForm = GUICreate("GDI+", ($iX), ($iY))
    GUISetBkColor(0xFFFFFF)
    GUISetState()
    $hWind = WinGetHandle($oForm)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWind)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iX, $iY, $hGraphic)
    $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsClear($hBackbuffer, 0xFFFFFFFF)
    For $iXc = 0 To $iX - 1
    For $iYc = 0 To $iY - 1
    $iPixelColor = Hex(_GDIPlus_GetPixel($hImage, $iXc, $iYc), 6)
    If Dec($iPixelColor) < Dec('999999') Then
    ;$count = $count + 1
    ;FileWrite($File, $iXc & "," & $iYc & @CRLF)
    $aCoords[$iXc][$iYc] = 999999
    SetPixel($oForm, $iXc, $iYc, $color)
    $hPen = _GDIPlus_PenCreate(0xFF000000);
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $iXc, $iYc, $iXc + 1, $iYc + 1, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iXc, $iYc, $iXc + 1, $iYc + 1, $hPen)
    Else
    $aCoords[$iXc][$iYc] = 0
    EndIf
    Next
    Next
    ;$save = _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & '\Image1.jpg')
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ;FileClose($File)
    _GDIPlus_Shutdown()
    _ArrayDisplay($aCoords, Default, Default, 1)

    [/autoit] [autoit][/autoit] [autoit]

    For $iXc = 0 To $iX - 1
    For $iYc = 0 To $iY - 1
    If $aCoords[$iXc][$iYc] = 999999 Then
    If $aCoords[$iXc - 1][$iYc] = 0 Or $aCoords[$iXc + 1][$iYc] = 0 Or $aCoords[$iXc][$iYc - 1] = 0 Or $aCoords[$iXc][$iYc + 1] = 0 Then
    $aCoords[$iXc][$iYc] = 777777
    FileWrite($fRand, $iXc & "," & $iYc & @CRLF)
    EndIf
    EndIf
    Next
    Next
    FileClose($fRand)
    _ArrayDisplay($aCoords, Default, Default, 1)
    For $iXc = 0 To $iX - 1
    For $iYc = 0 To $iY - 1
    If $aCoords[$iXc][$iYc] = 777777 And $count = 0 Then
    $split17 = StringSplit($aCoords[$iXc][$iYc], ',', 1)
    $count = $count + 1
    For $iYc2 = $iYc To $iY
    If $aCoords[$iXc][$iYc2] = 0 Then
    $split0 = StringSplit($aCoords[$iXc][$iYc2], ',', 1)
    $split1 = StringSplit($aCoords[$iXc][$iYc + 1], ',', 1)
    $split2 = StringSplit($aCoords[$iXc][$iYc2 - 1], ',', 1)
    $split3 = StringSplit($aCoords[$iXc][$iYc2 - 2], ',', 1)
    If $split17[1] <> $split2[1] Then
    $aCoords[$iXc][$iYc] = 0
    $aCoords[$iXc][$iYc + 1] = 777777
    $aCoords[$iXc][$iYc2 - 1] = 0
    If $split3[1] = $split17[1] Then
    $aCoords[$iXc][$iYc2 - 2] = 777777
    $iYc = $iYc2
    ExitLoop
    EndIf
    EndIf
    EndIf
    Next
    EndIf
    $count = 0
    Next
    Next
    For $iYc = 0 To $iY - 1
    For $iXc = 0 To $iX - 1
    If $aCoords[$iXc][$iYc] = 999999 Then
    ;
    If $aCoords[$iXc][$iYc] = 777777 And $count = 0 Then
    $count = $count + 1
    $split17 = StringSplit($aCoords[$iXc][$iYc], ',', 1)
    For $iXc2 = $iXc To $iX
    If $aCoords[$iXc2][$iYc] = 0 Then
    $split0 = StringSplit($aCoords[$iXc2][$iYc], ',', 1)
    $split1 = StringSplit($aCoords[$iXc + 1][$iYc], ',', 1)
    $split2 = StringSplit($aCoords[$iXc2 - 1][$iYc], ',', 1)
    $split3 = StringSplit($aCoords[$iXc2 - 2][$iYc], ',', 1)
    If $split17[1] <> $split2[1] Then
    $aCoords[$iXc][$iYc] = 0
    $aCoords[$iXc + 1][$iYc] = 777777
    $aCoords[$iXc2 - 1][$iYc] = 0
    If $split3[1] = $split17[1] Then
    $aCoords[$iXc2 - 2][$iYc] = 777777
    $iXc = $iXc2
    ExitLoop
    EndIf
    $iXc = $iXc2
    ExitLoop
    EndIf
    EndIf
    Next
    EndIf
    EndIf
    $count = 0
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _ArrayDisplay($aCoords, Default, Default, 1)
    For $iXc = 0 To $iX - 1
    For $iYc = 0 To $iY - 1
    If $aCoords[$iXc][$iYc] = 777777 Then
    For $iYc2 = $iYc To $iY - 1
    If $aCoords[$iXc][$iYc2] = 0 Then
    If $aCoords[$iXc][$iYc + Ceiling(Round(($iYc2 - $iYc) / 2) - 1)] = 777777 Then
    $aCoords[$iXc][$iYc + Ceiling(Round(($iYc2 - $iYc) / 2) - 1)] = 777777
    $iYc = $iYc2
    ExitLoop
    Else
    $aCoords[$iXc][$iYc + Ceiling(Round(($iYc2 - $iYc) / 2) - 1)] = 111111 ; eher rechts ausgerichtet
    $iYc = $iYc2
    ExitLoop
    EndIf
    EndIf
    Next
    EndIf
    Next
    Next
    For $iYc = 0 To $iY - 1
    For $iXc = 0 To $iX - 1
    If $aCoords[$iXc][$iYc] = 777777 Then
    For $iXc2 = $iXc To $iX - 1
    If $aCoords[$iXc2][$iYc] = 0 Then
    If $aCoords[($iXc - 1) + Ceiling(Round(($iXc2 - $iXc) / 2))][$iYc] = 777777 Then
    $aCoords[($iXc - 1) + Ceiling(Round(($iXc2 - $iXc) / 2))][$iYc] = 777777
    $iXc = $iXc2
    ExitLoop
    Else
    $aCoords[($iXc - 1) + Ceiling(Round(($iXc2 - $iXc) / 2))][$iYc] = 222222 ; eher rechts ausgerichtet
    $iXc = $iXc2
    ExitLoop
    EndIf
    EndIf
    Next
    EndIf
    Next
    Next
    _ArrayDisplay($aCoords, Default, Default, 1)
    For $iXc = 0 To $iX - 1
    For $iYc = 0 To $iY - 1
    If $aCoords[$iXc][$iYc] = 777777 Or $aCoords[$iXc][$iYc] = 999999 Then
    $aCoords[$iXc][$iYc] = 0
    Else
    ;$aCoords[$iXc][$iYc] = 888888
    EndIf
    Next
    Next
    For $iXc = 0 To $iX - 1
    For $iYc = 0 To $iY - 1
    If $aCoords[$iXc][$iYc] = 111111 Then
    For $iYc2 = $iYc To $iY - 1
    If $aCoords[$iXc][$iYc2] = 0 Then
    $aCoords[$iXc][$iYc + Ceiling(Round(($iYc2 - $iYc) / 2))] = 111111
    $iYc = $iYc2
    ExitLoop
    ElseIf $aCoords[$iXc][$iYc2] = 111111 Then
    $aCoords[$iXc][$iYc2] = 0
    EndIf
    Next
    EndIf
    Next
    Next
    For $iYc = 0 To $iY - 1
    For $iXc = 0 To $iX - 1
    If $aCoords[$iXc][$iYc] = 111111 Then
    For $iXc2 = $iXc To $iX - 1
    If $aCoords[$iXc2][$iYc] = 0 Then
    $aCoords[$iXc + Ceiling(Round(($iXc2 - $iXc) / 2))][$iYc] = 111111
    $iXc = $iXc2
    ExitLoop
    ElseIf $aCoords[$iXc2][$iYc] = 111111 Then
    $aCoords[$iXc2][$iYc] = 0
    EndIf
    Next
    EndIf
    Next
    Next
    _ArrayDisplay($aCoords, Default, Default, 1)
    For $iXc = 0 To $iX - 1
    For $iYc = 0 To $iY - 1
    If $aCoords[$iXc][$iYc] = 111111 Then
    FileWrite($File, $iXc & "," & $iYc & @CRLF)
    EndIf
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Dim $aRec
    If Not _FileReadToArray(@ScriptDir & "\cRand.txt", $aRec) Then
    MsgBox(4096, "Fehler", "Fehler beim Einlesen der Datei in das Array!" & @CRLF & "Fehlercode: " & @error)
    Exit
    EndIf
    For $x = 1 To $aRec[0]
    $split = StringSplit($aRec[$x], ',', 1)
    $aCoords[$split[1]][$split[2]] = 999999
    ;MsgBox(0, 'Datensatz ' & $x & ':', $aRec[$x])
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _ArrayDisplay($aCoords, Default, Default, 1)
    FileClose($File)
    EndFunc ;==>_Main

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; Gibt eine Zeile im Memo-Fenster aus
    Func MemoWrite($sMessage = '')
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
    EndFunc ;==>MemoWrite
    ; _GDIPlus_GetPixel
    Func _GDIPlus_GetPixel($hBitmap, $x, $Y)
    Local $result = DllCall($ghGDIPDLL, "int", "GdipBitmapGetPixel", "ptr", $hBitmap, "int", $x, "int", $Y, "dword*", 0)
    If @error Then Return SetError(1, 0, 0)
    Return SetError($result[0], 1, $result[4])
    EndFunc ;==>_GDIPlus_GetPixel
    ;SetPixel
    Func SetPixel($oForm, $x, $Y, $color)
    $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", $oForm)
    $setpixel = DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $x, "long", $Y, "long", $color)
    $realesedc = DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $dc[0])
    EndFunc ;==>SetPixel

    [/autoit]


    Hier ein früheres "Werk":

    Spoiler anzeigen
    [autoit]

    #include <File.au3>
    #include <Array.au3>
    $count = 0
    $count = 0
    $count2 = 0
    $double = 0
    $start = 0
    $cDifferences = 0
    $cYzush = 0
    $cut = 0
    $cONE = 0
    $cTWO = 0
    Local $a1, $b1, $a2, $b2, $c1, $c2, $c3, $newLine, $akt, $aXY, $mR, $sX, $sY, $look, $Set
    Local $aNxy[1][8]
    Local $cC[1][2]
    Opt('MouseClickDownDelay', 1)
    Opt('MouseClickDelay', 1)
    ;Koordinaten in Array lesen
    If Not _FileReadToArray(@ScriptDir & '\coords.txt', $aXY) Then
    Dim $nofile = 0
    MsgBox(4096, "Fehler", "Keine Koordinaten vorhanden. error:" & @error)
    ElseIf _FileReadToArray(@ScriptDir & '\coords.txt', $aXY) Then
    $nofile = 1
    EndIf
    If Not _FileCreate(@ScriptDir & '\midCoords.txt') Then
    MsgBox(4096, "Fehler", "Fehler beim Erstellen/Zurücksetzen der txt.-Datei: " & @error)
    EndIf
    ;Ausgabedatei
    $fNewCoords = FileOpen(@ScriptDir & '\midCoords.txt', 9)
    If $fNewCoords = -1 Then
    MsgBox(0, "Fehler", "Die Datei konnte nicht geöffnet werden.")
    Exit
    EndIf
    Local $aCoords[($aXY[0] + 1)][7]
    $aNxy[0][0] = 'Nr.'
    $aNxy[0][1] = 'x'
    $aNxy[0][2] = 'y'
    $aNxy[0][3] = 'Times'
    $aNxy[0][4] = '1st X,y'
    $aNxy[0][5] = 'mid x'
    $aNxy[0][6] = 'last x,y'
    $aNxy[0][7] = 'mid-y'
    $aCoords[0][0] = 'Nr.'
    $aCoords[0][1] = 'x'
    $aCoords[0][2] = 'y'
    $aCoords[0][3] = 'Times'
    $aCoords[0][4] = 'cDiff'
    $aCoords[0][5] = 'Y-zus'
    $aCoords[0][6] = 'Y-Punkt' ; Punkt auf Strich
    For $n = 1 To $aXY[0]
    ReDim $cC[UBound($cC) + 1][2]
    $split = StringSplit($aXY[$n], ',', 1)
    $cC[$n][0] = $split[1]
    $cC[$n][1] = $split[2]
    ;Wenn nebenliegendes Y auch vorhanden
    If $split[2] - 1 = $cC[$n - 1][1] Then
    $cYzush = $cYzush + 1
    Else
    $cYzush = 0
    EndIf
    If $n - 1 = 0 Then
    $aCoords[$n][0] = $n
    $aCoords[$n][1] = $split[1]
    $aCoords[$n][2] = $split[2]
    $aCoords[$n][3] = 1
    $aCoords[$n][4] = $cDifferences
    $aCoords[$n][6] = 1
    $count = $count + 1
    Else
    If $split[1] = $aCoords[($n - 1)][1] Then
    $count = $count + 1
    $aCoords[$n][0] = $n
    $aCoords[$n][1] = $split[1]
    $aCoords[$n][2] = $split[2]
    $aCoords[$n][3] = $count
    $aCoords[$n - 1][4] = $cDifferences + 1
    ;$aCoords[$n][5] = $YConn ;Y-conn
    $sXold = $aCoords[$n][1]
    $sYold = $aCoords[$n][2]
    If $count = 2 Then
    $aCoords[$n][6] = 1
    EndIf
    ElseIf $split[1] <> $aCoords[($n - 1)][1] And $n > 1 Then
    $cDifferences = $cDifferences + 1
    $aCoords[$n][0] = $n ;Stelle
    $aCoords[$n][1] = $split[1] ;X Coord
    $aCoords[$n][2] = $split[2] ;Y Coord
    $aCoords[$n][3] = 1 ;x n-mal
    $aCoords[$n - 1][4] = $cDifferences ;diff n-mal
    ;$aCoords[$n][5] = $YConn ;Y-conn
    $aCoords[$n - 2][6] = 1
    ReDim $aNxy[UBound($aNxy) + 1][8]
    $aNxy[0][0] = 'Nr.'
    $aNxy[0][1] = 'M-x'
    $aNxy[0][2] = 'M-y'
    $aNxy[0][3] = 'Times'
    $aNxy[0][4] = '1st X,y'
    $aNxy[0][5] = 'mid x,y'
    $aNxy[0][6] = 'last x,y'
    $aNxy[0][7] = 'mid-y'
    ;Declare X-diff Array
    $aNxy[$cDifferences][0] = $cDifferences ;Stelle
    $aNxy[$cDifferences][3] = $count ;Times
    $aNxy[$cDifferences][4] = $aXY[$n - $count] ;1st X,y
    $aNxy[$cDifferences][5] = $aXY[$n - Ceiling($count / 2)] ;mid X,y
    $aNxy[$cDifferences][6] = $aXY[$n - 1] ;last X,y
    $count = 1
    EndIf
    If $split[1] = $aCoords[($n - 1)][1] And $split[2] <> ($aCoords[($n - 1)][1] + 2) And $count > 2 And $aCoords[$n][6] = 1 Then
    $aCoords[$n - 2][6] = 1
    EndIf
    EndIf
    ;Wenn 2 Y nebeneinander
    If $cYzush >= 2 Then
    $YConn = 1
    Else
    $YConn = 0
    EndIf
    If $cYzush = 0 Then
    $aCoords[$n - 1][5] = $YConn ;Y-conn
    EndIf
    ;Wenn Y mehr/gleich 2 nebeneinanderliegende
    If $YConn = 0 Then
    $aNxy[$cDifferences][7] = 1 ;Y verbunden
    Else
    $aCoords[$n - 1][5] = $YConn ;Y-conn
    $aNxy[$cDifferences][7] = 0 ;Y getrennt
    EndIf
    $aCoords[$n][5] = $YConn ;Y-conn
    If $aCoords[$n][2] = ($aCoords[$n - 1][2] + 1) And $n > 2 Then
    $cXzush = 1
    Else
    $cXzush = 0
    EndIf
    If $aCoords[$n][5] = 1 And $aCoords[$n - 1][5] = 0 Then
    $start = $aCoords[$n - 1][0]
    EndIf
    If $aCoords[$n][5] = 0 And $aCoords[$n - 1][5] = 1 Then
    $end = $aCoords[$n][0]
    $mid = Ceiling(Round(($end - $start) / 2))
    $aCoords[$n - $mid][6] = 1
    EndIf
    If $aCoords[$n][1] = $aCoords[$n - 1][1] And $aCoords[$n][2] <> ($aCoords[$n - 1][2] + 1) Then
    $cutA = $aCoords[$n][0]
    $aCoords[$n - 2][6] = 1
    EndIf
    Next
    For $n = 1 To $aXY[0]
    If $aCoords[$n][1] = $aCoords[$n - 1][1] And $aCoords[$n][2] <> ($aCoords[$n - 1][2] + 1) Then
    $newLine = 1
    EndIf
    If $aCoords[$n][1] <> $aCoords[$n - 1][1] Or $aCoords[$n][2] <> ($aCoords[$n - 1][2] + 1) Then
    $newLine = 0
    $set = 0
    EndIf
    Next
    For $n = 1 To $aXY[0]
    If $aCoords[$n][6] = 1 And $aCoords[$n][5] = 1 And $akt = 0 Then
    $start = $aCoords[$n - 1][0]
    ;ConsoleWrite($start & ',')
    $akt = 1
    EndIf
    If $aCoords[$n][1] <> $aCoords[$n - 1][1] Or $aCoords[$n][4] <> $aCoords[$n - 1][4] Then
    $end = $aCoords[$n][0]
    $akt = 0
    EndIf
    If $aCoords[$n][5] = 0 And $akt = 1 Then
    $end = $aCoords[$n][0]
    $mid = Ceiling(Round((($end - $start) / 2)))
    $a = $aCoords[$n][0]
    If $aCoords[$end][3] > 4 Then
    If $set = 0 Then
    $aCoords[$n - $mid][6] = 2
    $a = $aCoords[$n - $mid][0]
    $set = 1
    EndIf
    If $set = 1 And $a <> $aCoords[$n - $mid][0] Then
    $aCoords[$n - $mid][6] = 3
    $set = 2
    EndIf
    Else
    $aCoords[$n - $mid][6] = 1
    EndIf
    $akt = 0
    EndIf
    If $aCoords[$n][2] <> ($aCoords[$n - 1][2] + 1) Then
    $set = 0
    EndIf
    Next
    For $n = 1 To $aXY[0]
    If $aCoords[$n][6] = 2 And $cTWO = 1 Then
    $aCoords[$n][6] = 3
    $cTWO = 0
    EndIf
    If $aCoords[$n][6] = 1 Then
    $cTWO = 0
    EndIf
    If $aCoords[$n][6] = 2 Then
    $cTWO = 1
    EndIf
    If $aCoords[$n - 1][6] = 1 And $aCoords[$n][6] = 1 Then
    $aCoords[$n - 1][6] = ''
    EndIf
    Next
    _ArrayDisplay($aCoords)
    ;_ArrayDisplay($aNxy)
    For $i = 1 To UBound($aNxy) - 1
    FileWrite($fNewCoords, $aNxy[$i][5] & @CRLF)
    Next
    ;_1_ende
    ;~ $pNotepad = Run(@WindowsDir & "\Notepad.exe")
    ;~ $hNP = WinGetHandle($pNotepad)
    ;~ WinWait($hNP)
    ;~ $NPSize = WinGetPos($hNP)
    ;~ $pX = $NPSize[0] + 150
    ;~ $pY = $NPSize[1] + 150
    ;~ If $nofile = 1 Then
    ;~ For $x = 1 To $aXY[0]
    ;~ $datasplit = StringSplit($aXY[$x], ',', 1)
    ;~ MouseMove(($datasplit[1] + $pX), ($datasplit[2] + $pY), 1)
    ;~ MouseDown('left')
    ;~ Sleep(1)
    ;~ If $datasplit[1] <> $oldXcoord Then
    ;~ MouseUp('left')
    ;~ EndIf
    ;~ If $datasplit[2] <> $oldYcoord + 1 Then
    ;~ MouseUp('left')
    ;~ EndIf
    ;~ Next
    ;~ EndIf
    ;~ MouseUp('left')

    [/autoit]