Is there any way to get the range of colors used in ImageMagick's -fuzz option? -
i'm trying hack image search uses color "distance," (or "tolerance", or "variance") similar what's done in imagemagick's -fuzz
option: http://www.imagemagick.org/usage/color_basics/#fuzz_distance.
what i'm hoping a range or array of rgb values single initial pixel can use match against comparison points in database.
obviously what's happening -fuzz
euclidean distance formula describing sphere in rgb cube, i'm not sure find mathematics or how use imagemagick (or other library) accomplish this.
thoughts?
as stated here in magemagick's forums, color b
within fuzz range r
of color a
if euclidian distance lower r:
sqrt((b.r - a.r)^2 + (b.g - a.g)^2 + (b.b - a.b)^2) < r
r
, g
, b
stand colors' respective red, blue , green values.
if don't have transparency, that's it. if need consider transparency, have multiply colors respective alpha channel value before using them in formula.
in 3-dimensional rgb color space, colors within fuzz range of color indeed form sphere (of radius r
).
for checking agains points in database, can check formula if inside sphere.
regarding color ranges: since range of "fuzzy" (= within fuzz range :-) ) colors 1 dimension depends on position in other 2 dimensions, thing generate enclosing cube around fuzzy sphere. won't give right colors, use reject colors lie outside of cube. ranges cube are:
(a.r - r) <= b.r <= (a.r + r) (a.g - r) <= b.g <= (a.g + r) (a.b - r) <= b.b <= (a.b + r)
update:
here code reference calculation. looks bit more complicated, because has handle cmyk colors. rgb, reduces above-mentioned case.
Comments
Post a Comment