how i could obtain connected component gray scale with format that diffrence the percentage of gray

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

how i could obtain connected component gray scale with format that diffrence the percentage of gray

Post by diegomage » 2019-04-30T18:57:45-07:00

i have this image

Image
when i use this code i obtain

Code: Select all

 convert fragresultc.png -define connected-components:area-threshold=0  -define connected-components:verbose=true  -connected-components 8   tmp.png >  data.cc

Code: Select all

Objects (id: bounding-box centroid area mean-color):
  0: 242x330+0+0 132.6,99.5 28190 gray(0)
  2: 192x279+24+51 122.9,167.5 11332 gray(1%)
  104: 136x160+59+167 126.8,245.3 11064 gray(75%)
  1: 165x300+69+30 176.1,146.4 6022 gray(1%)
  24: 90x245+0+85 46.4,217.8 5201 gray(17%)
  134: 59x108+0+222 22.1,281.5 4085 gray(96%)
  135: 75x82+88+248 126.6,288.7 2164 gray(97%)
  32: 62x80+145+102 172.2,136.6 1908 gray(23%)
  11: 78x58+132+71 166.2,103.1 1237 gray(8%)
  123: 54x44+16+191 37.8,215.7 1232 gray(88%)
  36: 42x28+86+105 104.9,117.9 800 gray(26%)
  138: 69x14+91+316 125.5,323.4 780 gray(99%)
  27: 51x32+53+88 74.2,103.5 728 gray(19%)
  47: 24x41+56+123 67.5,144.0 656 gray(34%)
  136: 36x43+112+273 127.3,298.1 444 gray(98%)
  137: 25x26+117+284 128.2,299.1 440 gray(99%)
  106: 35x25+173+168 193.6,182.2 396 gray(76%)
  101: 32x30+44+164 61.0,175.6 383 gray(73%)

i need to obatin the color in format similar to this

2: (50919,50919,50919) #C6E7C6E7C6E7 gray(78%)
3: (51391,51391,51391) #C8BFC8BFC8BF gray(78%)

for recognizing the diffrence in gray of same percentage

User avatar
fmw42
Posts: 25144
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how i could obtain connected component gray scale with format that diffrence the percentage of gray

Post by fmw42 » 2019-04-30T19:30:02-07:00

add -define connected-components:mean-color=true

See https://imagemagick.org/script/connected-components.php

diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: how i could obtain connected component gray scale with format that diffrence the percentage of gray

Post by diegomage » 2019-04-30T19:36:39-07:00

i add but obtain the same results

Code: Select all

convert fragresultc.png -define connected-components:area-threshold=0  -define connected-components:verbose=true  -connected-components 8   -define connected-components:mean-color=true  tmp.png

Code: Select all

Objects (id: bounding-box centroid area mean-color):
  0: 242x330+0+0 132.6,99.5 28223 gray(0)
  2: 192x279+24+51 123.0,167.2 11352 gray(1%)
  104: 136x160+59+167 126.8,245.3 11052 gray(75%)
  1: 165x300+69+30 176.1,146.6 6010 gray(1%)
  24: 90x245+0+85 46.4,218.0 5189 gray(17%)
  134: 59x108+0+222 22.1,281.5 4090 gray(96%)
  135: 76x82+88+248 126.6,288.7 2179 gray(97%)
  33: 62x80+145+102 172.2,136.6 1912 gray(24%)
  124: 54x44+16+191 37.8,215.7 1232 gray(89%)
  38: 42x28+86+105 104.8,117.9 799 gray(27%)
  138: 69x14+91+316 125.4,323.4 785 gray(99%)
  11: 71x42+139+71 178.2,97.1 782 gray(8%)
  28: 51x32+53+88 74.2,103.5 724 gray(20%)
  49: 24x41+56+123 67.5,143.9 653 gray(35%)
  37: 36x25+132+104 145.3,113.8 447 gray(27%)
  136: 36x43+112+273 127.3,298.2 444 gray(98%)
  137: 25x26+117+284 128.2,299.1 437 gray(99%)
  106: 35x25+173+168 193.6,182.2 396 gray(76%)
  101: 32x30+44+164 61.1,175.6 382 gray(73%)
  67: 28x19+115+134 128.0,142.8 371 gray(48%)
  13: 34x20+113+72 130.2,80.1 317 gray(9%)

diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: how i could obtain connected component gray scale with format that diffrence the percentage of gray

Post by diegomage » 2019-04-30T19:37:09-07:00

catn get difference between percetange gray

User avatar
fmw42
Posts: 25144
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how i could obtain connected component gray scale with format that diffrence the percentage of gray

Post by fmw42 » 2019-04-30T19:57:03-07:00

It has to be added before -connected-components, the same as the other -define.

Perhaps I misunderstand. That define makes the output resemble the input after doing area filtering.

What is that you want. The text data will not be in the format of txt:. This is the only format. It will not show pixel coordinated, nor raw color values, nor hex values. Only gray() or srgb()

If you do not threshold, you will get the same output as the input when using mean-color=true, since your regions are constant colors. So there will be no change or difference. If your input is JPG, then compression will cause some fluctuation in color and the output will be slightly different from the input depending upon if you have used a fuzz value or not.

Once you do area-threshold other than 0 and mean-color=true, then you can do a compare of the input with the output using compare or with -compose difference -composite.

diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: how i could obtain connected component gray scale with format that diffrence the percentage of gray

Post by diegomage » 2019-04-30T20:02:22-07:00

i need gray with more decimal like gray(98,51%) because some gray color are repeat and not are the same colors

diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: how i could obtain connected component gray scale with format that diffrence the percentage of gray

Post by diegomage » 2019-04-30T20:13:02-07:00

this are repeated and not the same color have less 1% of difference

2: 192x279+24+51 123.0,167.2 11352 gray(1%)
104: 136x160+59+167 126.8,245.3 11052 gray(75%)
1: 165x300+69+30 176.1,146.6 6010 gray(1%)

User avatar
fmw42
Posts: 25144
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how i could obtain connected component gray scale with format that diffrence the percentage of gray

Post by fmw42 » 2019-04-30T23:03:27-07:00

There is no current control over the decimal place. You will need to ask on the Developers forum for an enhancement.

Post Reply