fmw42 wrote:You can use the following to extract the largest the crop areas corresponding to the largest white areas from the s.png image. You will have too many due to the large white region at the bottom right. But you can then throw out the ones not needed or examine the bounding box coordinates for shapes that are longer in x than y. Skip the first one, which has color gray(0) and is the black background. Then get the next ones that are gray(255) until you read one that is gray(0) again. See http://magick.imagemagick.org/script/co ... onents.php
Objects (id: bounding-box centroid area mean-color):Code: Select all
convert s.png -define connected-components:verbose=true -connected-components 4 null:
0: 885x1090+0+0 437.8,544.0 927407 gray(0)
286: 101x161+784+929 847.8,1024.5 9443 gray(255) <-- not likely what you want, not the right w/h aspect ratio
215: 176x32+278+359 365.2,373.9 4914 gray(255) <-- probably a good one
217: 193x29+524+384 618.3,398.1 4525 gray(255) <-- probably a good one
223: 130x35+361+544 425.3,561.1 3839 gray(255) <-- probably a good one
72: 207x28+469+170 575.2,182.4 3504 gray(255) <-- probably a good one
52: 157x25+239+115 316.9,126.7 3238 gray(255) <-- probably a good one
228: 83x26+347+636 387.0,648.5 1821 gray(255) <-- probably a good one
219: 84x25+136+421 177.2,432.4 1804 gray(255) <-- probably a good one
211: 80x26+139+228 177.3,240.4 1796 gray(255) <-- probably a good one
327: 17x21+836+939 843.5,950.1 168 gray(255) <-- probably too small and not the right w/h aspect ratio
505: 12x11+801+1045 807.2,1050.5 85 gray(255) <-- probably too small and not the right w/h aspect ratio
573: 26x8+774+1082 786.3,1086.6 75 gray(255) <-- probably too small and not the right w/h aspect ratio
96: 11x12+633+178 638.6,183.5 63 gray(0)
442: 12x13+793+1027 798.8,1033.4 63 gray(255)
377: 14x8+771+1000 777.9,1004.4 62 gray(255)
379: 9x7+804+1001 807.5,1004.3 55 gray(0)
...
And: How do I get the output above (with the areas) into a file.
It doesn't work if I use the ">" pipe.
There I get each pixel not the area.
Thank U