Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How should I find edges in the hue channel of an HSV image?

I'm trying to find edges in a color image--particularly to distinguish between a person and a background. I'll use them to refine the results from a depth sensor. I know that I can convert the image to grayscale and use Canny on that, but that sometimes misses important edges. I believe I could get better results by also using chroma information. I've experimented with different color spaces, and the best one I've found is HSV. However, there's an issue with detecting edges in the H channel. Because hue in HSV is an angular measurement from 0 to 180 (360 divided by 2 so it fits into 8 bits), the values wrap around, and the difference between different values isn't simply a subtraction. The difference between 0 and 180 is 1. The difference between 20 and 160 is 41. So, in the attached image, you can see a very strong boundary between the head and the background (around 15 vs. 105), which is real. But if you look around the mouth, there’s what looks to be a strong boundary, but since it’s around 5 vs. 175, it’s actually not a very large change.

Is there a way to detect edges in OpenCV that takes this into account? Or, is anyone aware of an open source program that implements this? Otherwise, the only thing I can think of would be to write a custom implementation of Canny or some other edge detection algorithm

C:\fakepath\srcImageH.png

How should I find edges in the hue channel of an HSV image?

I'm trying to find edges in a color image--particularly to distinguish between a person and a background. I'll use them to refine the results from a depth sensor. I know that I can convert the image to grayscale and use Canny on that, but that sometimes misses important edges. I believe I could get better results by also using chroma information. I've experimented with different color spaces, and the best one I've found is HSV. However, there's an issue with detecting edges in the H channel. Because hue in HSV is an angular measurement from 0 to 180 179 inclusive (360 divided by 2 so it fits into 8 bits), the values wrap around, and the difference between different values isn't simply a subtraction. The difference between 0 and 180 179 is 1. The difference between 20 and 160 is 41. 40. So, in the attached image, you can see a very strong boundary between the head and the background (around 15 vs. 105), which is real. But if you look around the mouth, there’s what looks to be a strong boundary, but since it’s around 5 vs. 175, it’s actually not a very large change.

Is there a way to detect edges in OpenCV that takes this into account? Or, is anyone aware of an open source program that implements this? Otherwise, the only thing I can think of would be to write a custom implementation of Canny or some other edge detection algorithm

C:\fakepath\srcImageH.png