Extract one object from bunch of objects and detect edges

心不动则不痛 提交于 2019-11-30 10:19:27
Luis Enrique

Well there is a similar question that was asked here:

It seems that edge information is not a good descriptor for the image, still if you want to try it I'll do the following steps:

  1. Load image and convert it to grayscale
  2. Detect edges - Canny, Sobel try them and find what it suits you best
  3. Set threshold to a given value that eliminates most background - Binarize image
  4. Close the image - Morphological close dont close the window!
  5. Count and identify objects in the image (Blobs, Watershed)
  6. Check each object for a shape (assuming you have described shapes of the leaf you could find before or a standard shape like an ellipse) features like:
  7. If a given object has a given shape that you described as a leaf then you detected the leaf!.

I believe that given images are taken in the real world these algorithm will perform poorly but it's a start. Well hope it helps :).

-- POST EDIT 06/07

Well since you have no prior information about the leaf, I think the best we could do is the following:

  • Load image
  • Bilateral filter
  • Canny
  • Extract contours
  • Assume: that the contour with the largest perimeter is the leaf
  • Convex hull the 3 or 2 largest contours (the blue line is the convex hull done)
  • Use this convex hull to do a graph cut on the image and segmentate it

If you do those steps, you'll end up with images like these:

I won't post the code here, but you can check it out in my messy github. I hope you don't mind it was made in python.

Leaf - Github

Still, I have a couple of things to finish that could improve the result.. Roadmap would be:

  • Define the mask in the graphcut (like its described in the doc)
  • Apply region grow may give a better convex hull
  • Remove all edges that touch the border of the image can help to identify larger edges

Well, again, I hope it helps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!