HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelDevelopmentTutorial Source codeReport an issue
Category
Example

is pixel similar

← isSimilar   isPixelSimilar →
Returns true if the distance between two colors is less than the specified distance. The fuzz value should be in the range 0-QuantumRange. The maximum value represents the longest possible distance in the colorspace. e.g. from RGB(0, 0, 0) to RGB(255, 255, 255) for the RGB colorspace

A distance of '1' is the maximum distance in the color space e.g. from 0, 0, 0 to 255, 255, 255 in RGB color space.

The only difference between ImagickPixel::isSimilar and ImagickPixel::isPixelSimilar is that isSimilar needs to be scaled by the quantum value.


Color 1 Color 2 Test distance * 255 Is within distance
rgb(245, 0, 0) rgb(255, 0, 0) 5.196152423 no
rgb(245, 0, 0) rgb(255, 0, 0) 5.773502692 yes
rgb(0, 0, 0) rgb(7, 7, 0) 5.196152423 no
rgb(0, 0, 0) rgb(7, 7, 0) 5.773502692 yes
rgba(0, 0, 0, 1) rgba(7, 7, 0, 1) 5.196152423 no
rgba(0, 0, 0, 1) rgba(7, 7, 0, 1) 5.773502692 yes
rgb(128, 128, 128) rgb(128, 128, 120) 4.041451884 no
rgb(128, 128, 128) rgb(128, 128, 120) 4.618802154 yes
rgb(0, 0, 0) rgb(255, 255, 255) 254.9 no
rgb(0, 0, 0) rgb(255, 255, 255) 255 yes
rgb(255, 0, 0) rgb(0, 255, 255) 254.9 no
rgb(255, 0, 0) rgb(0, 255, 255) 255 yes
black rgba(0, 0, 0) 0 yes
black rgba(10, 0, 0, 1.0) 5.773502692 yes