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

To get a boundary, image processing folks use a technique called Sobel filtering. The basic idea is to create an isotropic version of a gradient. First, convolve each pixel with the matrices
Vertical Kernel: -1 -2 -1 0 0 0 +1 +2 +1 Horizontal kernel: -1 0 +1 -2 0 +2 -1 0 +1
Take the results of the two convolutions, square them and add them. If the result is greater than a user-determined threshold, set the pixel black, otherwise white.

This works for 1-D, e.g., grayscale images. For color images, decide what you want to be the boundary: Brightness? Hue? Saturation? Then segnemt according to that property, Just taking the 3-D RGB vector distance isn't the greatest idea, because humans don't differentiate colors according to that metric. All other things being the same, I'd probably try the grayscale (brightness) metric first.

Update: I concur with blokhead that there are many edge detection algorithms, none unviersally applicable. The Sobel algorithm is fairly good on a wide range of images, so is worth a try.

-Mark

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

Replies are listed 'Best First'.
Re^2: the difference between two colors, and how to describe a color
by tachyon (Chancellor) on Oct 28, 2004 at 05:08 UTC

    For colour images the first step would be to convert to grayscale. The liminance formula used in the GIMP is pretty similar to the OPs formula:

    Y = 0.3R + 0.59G + 0.11B;
    see Re: convert image to greyscale (color to black and white) and particularly the link showing the effects of various grayscaling approaches.

    cheers

    tachyon

      "For colour images the first step would be to convert to grayscale"

      That's what was in my mind over night. When I used that formular, I kept thinking that I am calculating luminous.

      My major in university is related to this, and I kept thinking what's the difference now and then. One thing I remembered is that, the equipment we used only take black and white pictures, so I started to think that first thing today is to convert picture to black and white.

      Now your post is a great remind to me, and confirmed my thought. Thank you!

Re^2: the difference between two colors, and how to describe a color
by pg (Canon) on Oct 28, 2004 at 16:28 UTC
    "Brightness? Hue? Saturation? Then segnemt according to that property, Just taking the 3-D RGB vector distance isn't the greatest idea, because humans don't differentiate colors according to that metric."

    This concurs with what others said, so we are all pointing to the same direction that, RGB is not what human being used to find out edges. This is actually sort of AI, as part of it is to understand human behavior, and then think of how to repeat/simulate it.