in reply to the difference between two colors, and how to describe a color

Edge detection is not a trivial task. Just google for edge detection and see the many varied techniques. Instead of doing this yourself, why aren't you delegating out to ImageMagick or Gimp (both have edge-detection filters)? You get the advantage of having adjustable parameters so you can tune things for your data. You will still probably have to get the locations of the edges into Perl by looking at the pixels by hand, but it's much easier from the output of the edge-detection algorithm -- the result will be grayscale and the edges will correspond to very clear jumps in intensity that are easy to notice.

If you're hell-bent on doing this by hand the way you've suggested, I'd look to see how programs like Gimp calculate deltas between pixels. For instance, Gimp's Selective Gaussian Blur will blur pixels only within a certain delta "difference" and it seems to do a good job. From the source code, it's not clear how this is calculated, but it probably relies on Gimp's internal colorspace. Maybe there is an Gimp IRC channel you could consult to get pointers to the math they use.

In any case, just using luminosity (as in your last example) won't find many types of boundaries in between solid colors. The two 3-dimensional RGB metrics you use are probably better (and probably not too different from each other).

blokhead

  • Comment on Re: the difference between two colors, and how to describe a color