possible bug or clarification requested for -fuzz
Posted: 2009-09-13T17:43:33-07:00
I would expect the following gradient image to be completely converted to a constant specified new graylevel of 60% when using a -fuzz of 50% and starting graylevel of 50%. But I have to add a slight amount to the fuzz of a minimum of 50.001% to make it work.
convert -size 256x256 gradient: -fuzz 50% -fill "gray(60%)" -opaque "gray(50%)" grad_g60pct_A.png
identify -verbose grad_g60pct_A.png
Channel statistics:
gray:
min: 0 (0)
max: 39321 (0.6)
mean: 39167.4 (0.597656)
So it is not a constant result of gray(60%). Graylevel 0 is not covered by the combination of midval=gray(50%) and fuzz=50%
But
convert -size 256x256 gradient: -fuzz 50.001% -fill "gray(60%)" -opaque "gray(50%)" grad_g60pct_B.png
identify -verbose grad_g60pct_B.png
Channel statistics:
gray:
min: 39321 (0.6)
max: 39321 (0.6)
mean: 39321 (0.6)
Which is a constant image of value gray(60%)!
Am I missing something? Is this a bug? If not, and I am not missing something, can this be easily corrected to give an exact conversion without fudging the fuzz value?
The motivation for this is a script that I am trying to create that will map a range of colors in to some new color, by processing graylevel ranges channel-by-channel. I thought I could take the range of channel graylevels and find the midvalue and half difference both in percent and use the half difference percent as the fuzz value. But this does not convert right now exactly as above. If this will not be an accurate way to compute the fuzz, then I need to look at other approaches for the script. This seemed like the easiest and most efficient way to do this, if the fuzz value can be accurately extracted and be equivalent to the half range difference.
Note the gradient was just a test image to see how well the fuzz worked.
It appears that either the mid value of gray(50%) is not truly midway or a fuzz of 50% does not full cover all graylevels down to zero. It seems that 0 is missed in the fuzz coverage.
convert -size 256x256 gradient: -fuzz 50% -fill "gray(60%)" -opaque "gray(50%)" grad_g60pct_A.png
identify -verbose grad_g60pct_A.png
Channel statistics:
gray:
min: 0 (0)
max: 39321 (0.6)
mean: 39167.4 (0.597656)
So it is not a constant result of gray(60%). Graylevel 0 is not covered by the combination of midval=gray(50%) and fuzz=50%
But
convert -size 256x256 gradient: -fuzz 50.001% -fill "gray(60%)" -opaque "gray(50%)" grad_g60pct_B.png
identify -verbose grad_g60pct_B.png
Channel statistics:
gray:
min: 39321 (0.6)
max: 39321 (0.6)
mean: 39321 (0.6)
Which is a constant image of value gray(60%)!
Am I missing something? Is this a bug? If not, and I am not missing something, can this be easily corrected to give an exact conversion without fudging the fuzz value?
The motivation for this is a script that I am trying to create that will map a range of colors in to some new color, by processing graylevel ranges channel-by-channel. I thought I could take the range of channel graylevels and find the midvalue and half difference both in percent and use the half difference percent as the fuzz value. But this does not convert right now exactly as above. If this will not be an accurate way to compute the fuzz, then I need to look at other approaches for the script. This seemed like the easiest and most efficient way to do this, if the fuzz value can be accurately extracted and be equivalent to the half range difference.
Note the gradient was just a test image to see how well the fuzz worked.
It appears that either the mid value of gray(50%) is not truly midway or a fuzz of 50% does not full cover all graylevels down to zero. It seems that 0 is missed in the fuzz coverage.