M
M
Matweytt2019-07-28 15:31:44
Python
Matweytt, 2019-07-28 15:31:44

How to find ellipses in an image?

There is a picture: 5d3d935f4d6e1614165215.jpeg
I need to highlight the butt of the trees.
I first do kmeans clustering, then I use Canny and I get this image:
5d3d9599c477e868010104.jpeg
How do I further select these ellipses? The contours may not be closed, only 2/3 of the ellipse may be visible due to snow, shadow or other obstructions. HoughCircles in OpenCV only works in ideal conditions and only with a circle, not an ellipse. How can I solve this problem?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
alternativshik, 2019-07-28
@alternativshik

maybe you need to process the image somehow else? like remove color, raise contrast, etc., so that there is less interference from shadows, snow, bark, etc.?

X
xmoonlight, 2019-07-28
@xmoonlight

It is necessary to look not for ellipses, but for chordal sectors - "segments" (an orange, for example).
1. After such a sector is found (at least 1/3 of the area of ​​the circle): you need to determine the center and fill it to the boundaries that do not go beyond the circle formed by this sector when rotating around the center of the circle (with the radius of this sector).
2. After finding - cut out the end of the log and again look for the sector.
How many of these will be - so many logs in the photo.
It is easy to find a "slice" - we find a light zone and check the geometry of the boundaries (we are looking for an arc) with a given accuracy. Along the arc - find the radius.
PS: If you complicate it, then along the contour of the found arc, you need to restore the contour of the ellipse to which it belongs.

T
tlbogdanov, 2019-07-31
@tlbogdanov

HoughCircles in OpenCV only works in ideal conditions and only with a circle, not an ellipse. How can I solve this problem?

I propose to climb into this class, see how the circle is defined there. If there is something around the circle formulas - replace it with the ellipse formula, if there is something around the error in determining the pixels - parts of the circle, try to increase this error, what will happen? - technically, a tree is not an ellipse, you need to remove such strictness from the open with handles ..
If it doesn’t work out with what I suggested, you can try to do everything yourself.
You don't have any garbage filtering in the examples of pictures, it's probably worth doing it.
There are erosion and dilation methods, applied in sequence, that will help you remove unnecessary artifacts where they are not needed and complete your ellipses to complete shapes.
this will be easier than finding the contour of an ellipse by the contour of the arc.
But, after the "circles" are completed, I think I will have to deal with chord sectors, but, personally, I would first try to stupidly find a circle on the pixel matrix ..
Please write what you got in the end, I'm interested

A
Andrey Dugin, 2019-10-04
@adugin

Wrong tool selected.
The problem is easily solved using neural networks like Unet, focused on image segmentation.

S
Sergey Sokolov, 2019-10-04
@sergiks

Solving this problem using histogram oriented gradients and random forest ceur-ws.org/Vol-1909/paper2.pdf Ekaterinburg University.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question