Its possible filter by area colored image with connected components?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Its possible filter by area colored image with connected components?

Post by diegomage »

Im triying filter by area but i dont know how with a colored image

Image

please give me a help
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Its possible filter by area colored image with connected components?

Post by fmw42 »

Please explain further. If you have only a few colors, you can get the area of each isolated region of each color. If you have too many colors, then you will get too many regions and the connected components will fail.

Code: Select all

convert 7r3T4.png -define connected-components:verbose=true -connected-components 4 null:
Objects (id: bounding-box centroid area mean-color):
  0: 216x120+0+0 107.9,58.5 18344 srgb(0,0,0)
  1: 71x55+17+24 55.2,52.4 2578 srgb(255,255,255)
  4: 64x58+136+24 172.4,46.8 2164 srgb(255,255,255)
  64: 56x27+128+77 155.3,94.2 906 srgb(255,0,0)
  62: 66x27+16+77 50.0,90.4 605 srgb(255,0,0)
  43: 72x28+16+59 56.8,78.9 531 srgb(255,255,0)
  40: 38x35+138+55 153.1,80.6 314 srgb(255,255,0)
  41: 13x16+43+56 49.1,63.3 153 srgb(255,255,0)
  25: 11x19+157+40 162.9,47.6 114 srgb(255,0,0)
  22: 13x18+24+40 28.4,48.3 40 srgb(255,0,0)
  36: 8x12+25+46 28.4,51.5 26 srgb(255,255,0)
  2: 10x9+136+24 138.8,26.4 24 srgb(255,0,0)
  46: 7x12+81+62 84.9,66.7 23 srgb(255,0,0)
  5: 7x5+138+25 140.5,26.7 13 srgb(255,255,0)
  11: 3x7+85+32 86.3,35.3 9 srgb(255,255,0)
  10: 4x4+41+32 42.3,33.3 7 srgb(255,255,0)
  38: 5x1+90+53 92.0,53.0 5 srgb(255,255,0)
  37: 5x1+90+50 92.0,50.0 5 srgb(255,255,255)
  59: 2x3+144+74 144.5,75.0 4 srgb(255,0,0)
  8: 1x2+137+30 137.0,30.5 2 srgb(255,255,0)
  12: 1x2+136+33 136.0,33.5 2 srgb(255,255,0)
  14: 1x2+40+36 40.0,36.5 2 srgb(255,255,0)
  21: 2x1+83+39 83.5,39.0 2 srgb(255,255,0)
  34: 1x2+33+44 33.0,44.5 2 srgb(255,255,0)
  49: 2x1+155+64 155.5,64.0 2 srgb(255,0,0)
  52: 1x2+152+67 152.0,67.5 2 srgb(255,0,0)
  56: 2x1+147+72 147.5,72.0 2 srgb(255,0,0)
  26: 1x1+163+40 163.0,40.0 1 srgb(255,255,0)
  28: 1x1+81+41 81.0,41.0 1 srgb(255,255,0)
  29: 1x1+165+41 165.0,41.0 1 srgb(255,255,0)
  30: 1x1+35+42 35.0,42.0 1 srgb(255,255,0)
  31: 1x1+166+42 166.0,42.0 1 srgb(255,255,0)
  32: 1x1+34+43 34.0,43.0 1 srgb(255,255,0)
  33: 1x1+80+43 80.0,43.0 1 srgb(255,255,0)
  6: 1x1+47+29 47.0,29.0 1 srgb(255,255,0)
  35: 1x1+167+44 167.0,44.0 1 srgb(255,255,0)
  19: 1x1+37+39 37.0,39.0 1 srgb(255,0,0)
  18: 1x1+39+38 39.0,38.0 1 srgb(255,255,0)
  17: 1x1+38+38 38.0,38.0 1 srgb(255,0,0)
  39: 1x1+166+54 166.0,54.0 1 srgb(255,255,0)
  16: 1x1+39+37 39.0,37.0 1 srgb(255,0,0)
  15: 1x1+136+36 136.0,36.0 1 srgb(255,0,0)
  42: 1x1+24+58 24.0,58.0 1 srgb(255,255,0)
  13: 1x1+40+35 40.0,35.0 1 srgb(255,0,0)
  44: 1x1+23+60 23.0,60.0 1 srgb(255,0,0)
  45: 1x1+80+61 80.0,61.0 1 srgb(255,0,0)
  9: 1x1+45+31 45.0,31.0 1 srgb(255,255,0)
  47: 1x1+158+62 158.0,62.0 1 srgb(255,0,0)
  48: 1x1+157+63 157.0,63.0 1 srgb(255,0,0)
  63: 1x1+86+77 86.0,77.0 1 srgb(255,0,0)
  50: 1x1+154+65 154.0,65.0 1 srgb(255,0,0)
  51: 1x1+153+66 153.0,66.0 1 srgb(255,0,0)
  3: 1x1+146+24 146.0,24.0 1 srgb(255,255,0)
  53: 1x1+151+69 151.0,69.0 1 srgb(255,0,0)
  54: 1x1+150+70 150.0,70.0 1 srgb(255,0,0)
  55: 1x1+149+71 149.0,71.0 1 srgb(255,0,0)
  65: 1x1+82+80 82.0,80.0 1 srgb(255,0,0)
  57: 1x1+146+73 146.0,73.0 1 srgb(255,0,0)
  58: 1x1+177+73 177.0,73.0 1 srgb(255,255,0)
  7: 1x1+46+30 46.0,30.0 1 srgb(255,255,0)
  60: 1x1+176+74 176.0,74.0 1 srgb(255,255,0)
  61: 1x1+176+75 176.0,75.0 1 srgb(255,0,0)
  23: 1x1+37+40 37.0,40.0 1 srgb(255,255,0)
  24: 1x1+82+40 82.0,40.0 1 srgb(255,255,0)
  20: 1x1+38+39 38.0,39.0 1 srgb(255,255,0)
  27: 1x1+36+41 36.0,41.0 1 srgb(255,255,0)
Fred-Weinhauss-Mac-mini:desktop fred$ 
You have regions that are:

black = srgb(0,0,0)
white = srgb(255,255,255)
red = srgb(255,0,0)
yellow = srgb(255,255,0)
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: Its possible filter by area colored image with connected components?

Post by diegomage »

i need extract the areas aproximate os size of the hollow blob
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Its possible filter by area colored image with connected components?

Post by fmw42 »

The bounding boxes and centers (centroids) are there in the list. You will have to either figure out which one it is or isolate that area in your image as white and make the rest black, so you have only one white area and the rest black. Then connected components will provide the location.

What hollow blob? If the center of the 4, then it is one of the yellow items in the list. There are not that many yellow ones.
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: Its possible filter by area colored image with connected components?

Post by diegomage »

yes Its possible using awk and sed I dont before thankyou for help me whit this
Post Reply