Here is a single command that quickly outputs the location of the (aproximate) centres of all the white areas. Your image needs a black border, so the results need one to be subtracted from X and Y.
Windows BAT syntax.
Code: Select all
convert ^
test2.png ^
-bordercolor Black -border 1 ^
-channel RG ^
-morphology Erode Diamond ^
-morphology Thinning:-1 Skeleton:3 +channel ^
-channel G ^
-morphology Thinning:-1 LineEnds ^
-channel RGB ^
-auto-level ^
-write centres.png ^
+transparent White ^
sparse-color:
Result:
Code: Select all
37,7,white 255,14,white 343,32,white 321,368,white
"-write centres.png" isn't needed, but shows you what it has done: black stays black, the white areas have become blue, the skeleton is magenta, and the centre of the skeletons are single white pixels.
The channel commands make the colors.
See my Islands page for some more details.
EDIT: Silly me. Shaving off the added boundary removes the need to subtract one:
Code: Select all
convert ^
test2.png ^
-bordercolor Black -border 1 ^
-channel RG ^
-morphology Erode Diamond ^
-morphology Thinning:-1 Skeleton:3 +channel ^
-channel G ^
-morphology Thinning:-1 LineEnds ^
-channel RGB ^
-auto-level ^
-shave 1x1 ^
-write centres.png ^
+transparent White ^
sparse-color:
Code: Select all
36,6,white 254,13,white 342,31,white 320,367,white