Search code examples
opencvimage-processingcomputer-visionedge-detection

Detecting horizontal round edges in color images


I'm trying to detect areas that contain a top portion of an oval shape in a color image.

Here are some examples I drew:

https://i.sstatic.net/I8MUh.jpg

https://i.sstatic.net/eNqN2.jpg

How would you accomplish this? I'm inexperienced in image processing, but I'm willing to read and learn. I'm mainly using OpenCV with C++ but I can use other libraries as well.


Solution

  • In general the thing you ask is a kind of big problem. In the real world images, you will need to find every oval shape, distinguish which has top (till what angle you tolerate and consider up ?). Then you need to segment those shapes very well so you can find areas with top portion oval shaped objects.

    However, if you need to find simpler images like in the example, but still a more general approach, you may first get edges by using any edge detection (for example Canny). Then, use Hough Transform for curves and ellipses. But I don't think there is function or library for that. So you may need implement your own Hough Transform. For that you must decide what exactly you mean by oval top. For your two images, if you successfully find oval top, just get the area under it. But to get more general you may want to segment shape under it with more sophisticated approach.

    For Hough Transform; http://en.wikipedia.org/wiki/Hough_transform#Circle_Detection_Process and for using it with ellipses http://en.wikipedia.org/wiki/Randomized_Hough_transform