You can also use connected components to make the colors a small unique set, since your image has thousands of colors. See
http://magick.imagemagick.org/script/co ... onents.php
Code: Select all
convert 143.png \
-define connected-components:verbose=true \
-connected-components 8 \
null:
Code: Select all
Objects (id: bounding-box centroid area mean-color):
0: 800x800+0+0 349.2,420.7 494667 graya(255,1)
31: 313x357+420+72 578.4,202.9 49630 graya(55,1)
1040: 144x194+504+221 576.5,302.7 13546 graya(49,1)
869: 342x252+401+193 550.9,317.9 13268 graya(70,1)
4948: 354x113+388+446 581.3,516.3 11492 graya(239,1)
4077: 358x116+387+411 573.5,481.3 9070 graya(224,1)
1441: 352x194+393+265 551.4,365.9 8545 graya(106,1)
3311: 360x128+387+377 565.6,451.1 7918 graya(207,1)
2080: 359x165+388+309 559.2,398.0 7852 graya(139,1)
1746: 91x110+529+287 573.6,341.9 7731 graya(37,1)
2673: 359x143+387+346 565.5,425.7 7436 graya(172,1)
3455: 1x29+746+382 746.0,396.0 29 graya(170,1)
3456: 1x28+747+382 747.0,395.5 28 graya(202,1)
4317: 19x19+662+419 671.0,428.0 19 graya(144,1)
4303: 18x18+451+419 459.5,427.5 18 graya(173,1)
6548: 18x1+572+505 580.5,505.0 18 graya(210,1)
4342: 18x18+663+420 671.5,428.5 18 graya(164,1)
6563: 18x1+572+506 580.5,506.0 18 graya(223,1)
6829: 18x1+582+527 590.5,527.0 18 graya(234,1)
4327: 17x17+451+420 459.0,428.0 17 graya(191,1)
4076: 1x17+386+411 386.0,419.0 17 graya(227,1)
3285: 1x16+385+376 385.0,383.5 16 graya(248,1)
3712: 1x16+386+393 386.0,400.5 16 graya(206,1)
4075: 1x16+385+411 385.0,418.5 16 graya(250,1)
...
But you can see a big change in the area between id 2673 and 3455. So if you pick the area 7436, you can merge all the smaller areas into the larger ones so that you can have an image with a small fixed number of graylevels.
Code: Select all
convert 143.png \
-define connected-components:area-threshold=7436 \
-define connected-components:verbose=true \
-define connected-components:mean-color=true \
-connected-components 8 \
143b.png
Code: Select all
Objects (id: bounding-box centroid area mean-color):
0: 800x800+0+0 349.9,420.2 496464 graya(255,1)
31: 313x357+420+72 578.6,204.6 50855 graya(55,1)
869: 343x253+400+193 552.6,320.2 14215 graya(70,1)
1040: 144x194+504+221 576.5,303.9 14047 graya(49,1)
4948: 354x113+388+446 581.1,516.7 11952 graya(239,1)
4077: 359x116+387+411 573.5,481.7 9638 graya(224,1)
1441: 354x195+392+265 553.0,367.9 9436 graya(106,1)
2080: 359x167+388+308 560.3,399.6 8679 graya(139,1)
3311: 361x129+386+377 565.9,451.9 8572 graya(207,1)
2673: 360x145+387+346 565.4,426.9 8262 graya(172,1)
1746: 92x110+529+287 573.7,342.0 7880 graya(37,1)
So image 143b.png has only 12 different graylevels and you can threshold to isolate those.