calculate fuzzyness
Posted: 2010-12-19T06:11:40-07:00
Dear image enchanting people,
For my online collage machine I need to make transparent a range of colors between colour X and color Y.
Before that I need to calculate the fuzzyness between these colors. The common function to calculate the color distance does not work. It gives too high values.
Strangely enough the Q16 compiled Imagick gives 8 bits RGB values in the ImagickPixel class, while the fuzzyness needs a 16 bit value, but well, that isn't the question here.
I then tried a rather boorish function that also gave to high values (according to some visual tests) and took too long to calculate the fuzzyness between a whole histogram of colors.
Please don't laugh!
Does anyone know how Image Magick determines the fuzzyness between two colors?
Thanks in advance,
Fabian
For my online collage machine I need to make transparent a range of colors between colour X and color Y.
Code: Select all
$image->paintTransparentImage ( $color_x , 0 , $fuzzyness );
Code: Select all
$col_x = $color_x->getColor();
$col_y = $color_y->getColor();
$fuzzyness = sqrt( pow ($col_x['r'] - $col_y['r'] , 2) + pow( $col_x['g'] - $col_y['g'] , 2) + pow( $col_x['b'] - $col_y['b'] , 2) ) * 256;
I then tried a rather boorish function that also gave to high values (according to some visual tests) and took too long to calculate the fuzzyness between a whole histogram of colors.
Code: Select all
function fuzz($a,$b){
//$a:ImagickPixel
//$b:ImagickPixel
//returns:float
if (is_object($a) && is_object($b)){
$i =0;
$hit = false;
while (!$hit){
$hit = $a->isSimilar ($b, $i);
$i ++;
}
return $i;
}
else{
return 0;
}
}
Does anyone know how Image Magick determines the fuzzyness between two colors?
Thanks in advance,
Fabian