fmw42 wrote:I am still not sure what results you really would like to have when alpha is involved and both are not opaque. But what is wrong with just considering the alpha channel as one more color dimension, so that for rgba, one would simply have:
%[fx:(100)*sqrt(((u.r-v.r)^2+(u.g-v.g)^2+(u.b-v.b)^2+(u.a-v.a)^2)/4)]%%"
The problem with that is two different fully transparent colors will NOT be classed as being the same. They are both transparent so they should be considered to have zero distance.
Also the scale is wrong as 100% should be the distance from black to white.
With the alternative method (multiply colors by alpha)...
%[fx:(100)*sqrt(((u.r*u.a-v.r*v.a)^2+(u.g*u.a-v.g*v.a)^2+(u.b*u.a-v.b*v.a)^2)/3)]%%"
This thinks Black and transparent are the same thing! That is Black == None
Can you explain what you think you need by way of examples for cases where both rgb values are different (say for black and white or some other simple change of one of the rgb components) for alpha cases of:
1) both alpha=0
Colors should have zero distance -- all transparent colors are the same
2) both alpha=5
Assuming you me 0.5 colors have some distance but are closer than their fully opaque counterparts.
3) one alpha=0, and one alpha=1
Any opaque color should be different to any transparent color.
Better still all opaque colors should be the same distance from any transparent color
4) non-zero and non-unity alpha for both
The closer the alpha values the closer the color, but it should only reach zero if either
they both become fully transparent, or they are both the same color.
More transparent colors should be closer together than less transparent colors.
5) both alpha=1
color distance should reflect the color space (EG: RGB or CMY color cubes, or HSL cones etc)
Also consider the effects of changing the fuzz computation regarding backward compatibility. It is such a commonly used thing that many scripts will change.
opaque color handling is correct, it must remain correct. But transparency handling is not
quite correct!
Hmmm
Download the colorwheel....
Code: Select all
wget http://www.imagemagick.org/Usage/images/colorwheel.png
Now run this whcih compares the opaque colors with a color 'none' (fully transparent black)
Code: Select all
convert colorwheel.png -alpha set -channel RGBA \
-fuzz 80% -fill none -opaque none show:
The result shows that darker (near black) colors are 'closer' than 80% of fully transparent black
(none). If you repeat with 50% you will see that all opaque colors are further than 50%
try it again with fully-transparent white!
Code: Select all
convert colorwheel.png -alpha set -channel RGBA \
-fuzz 80% -fill '#FFF0' -opaque '#FFF0' show:
Again opaque black colors are closer to fully-transparent white than white is!
Note that black and none are not zero distance (somewhere between 50 and 80%,
And we do know that 'fuzz' does consider all fully-transparent colors to be the same.
In other words the current fuzz model does handle ALL points. But it does not make all opaque colors the same distance from none. It is ALMOST right, but not quite right, but only with respect to alpha handling.
The question is then, should we correct that last 'inconsistancy'.
That is transparent and black is closer than transparent and white?
I have noted this problem in
http://www.imagemagick.org/Usage/bugs/fuzz_distance/