删除图像中的一个形状

huangapple go评论74阅读模式
英文:

Delete a shape from an image

问题

以下是您要翻译的内容:

I am working on pictures like this:

删除图像中的一个形状

My final goal is to detect if the very end of the stem is in the circle or not on new pictures (position and size of the circle may vary a bit), and I wanted to try it with image processing only (no ML for a first try because it seems not necessary) but I don't have knowledge in it.

The problem is that on a part of the dataset, the clear trapezium is not present, and on the other part it is present. The problem without the trapeze seems pretty simple (find if the end of the stem is in the circle), so I want to find a way to "erase" the trapeze of the pictures where it is present because I need my algorithm to work on both images (with and without the trapezium). I am able to know if the trapeze is present with the name of the picture.

First, I denoised the images and by looking at the intensity of the pixel you can see below (intensity in ordinate, count in abscissa), I literally just merged the pixel values into 5 groups.
删除图像中的一个形状

删除图像中的一个形状
But as you can see, a part of the stem is closer to the intensity of the trapezium than to the rest of the stem. Moreover, the values of the edges are also problematic.

Just if it can provide more information, I also tried edge detection and achieved to detect the circle whatever his position and size is. Here is a sneak peek of the edge detection result:
删除图像中的一个形状

I'm open to any idea (I know the initial question is how to erase the trapeze, but if you think this is not necessary and a lack of time, I'll consider every option) 删除图像中的一个形状

英文:

I am working on pictures like this :

删除图像中的一个形状

My final goal is to detect if the very end of the stem is in the circle or not on new pictures (position and size of the circle may vary a bit), and I wanted to try it with image processing only (no ML for a first try because it seems not necessary) but I don't have knowledge in it.

The problem is that on a part of the dataset, the clear trapezium is not present, and on the other part it is present. The problem without the trapeze seems pretty simple (find if the end of the stem is in the circle), so I want to find a way to "erase" the trapeze of the pictures where it is present because I need my algorithm to work on both images (with and without the trapezium). I am able to know if the trapeze is present with the name of the picture.

First, I denoised the images and by looking at the intensity of the pixel you can see below (intensity in ordinate, count in abscissa), I litteraly just merged the pixel values into 5 groups.
删除图像中的一个形状

删除图像中的一个形状
But as you can see, a part of the stem is closer to the intensity of the trapezium than to the rest of the stem. Moreover, the values of the edges are also problematic.

Just if it can provide more information, I also tried edge detection and achieve to detect the circle whatever his position and size is. Here is a sneak peak of the edge detection result :
删除图像中的一个形状

I'm open to any idea (I know the initial question is how to erase the trapeze, but if you think this is not necessary and a lack of time, I'll consider every option) 删除图像中的一个形状

答案1

得分: 0

自你说问题在没有较轻的形状的情况下似乎很容易,我将假设你知道如何检测圆和直线/线段(例如,使用Hough变换的变种,正如评论中所建议的)。

在你展示的边缘图像中,圆很清晰可见。你应该能够定位它(如果我理解你的意思正确的话,你已经做到了)。

有多条线,你应该能够找到它们。剩下的问题是找出你感兴趣的那一条。
有很多方法可以解决这个问题,例如:

  • 注意到茎两侧的强度相似,但你想要忽略的一条线两侧的强度非常不同。利用这一点找出差异最小的线。
  • 梯形的边缘相交。遍历所有线段的组合,并丢弃那些形成角的线段。你还可以限制角度在某个期望范围内。
  • 在你的图像中,茎由两条几乎平行的线组成。如果这总是成立(并且线条总是可以区分开的),你可以利用这一点来找出你要找的线。
  • 检查是否有一条线段在圆内结束,而没有触及其他线段。如果找到一个,你就知道尖端在圆内。

量化这些条件并检查是否有一个或它们的组合能够可靠地从所有线条中挑选出茎。

最棘手的情况当然是茎与边缘对齐。其他特殊但不太棘手的情况包括茎横穿一个或多个边缘,或者茎在边缘结束。我不清楚这些情况哪些会发生 - 如果可能的话,确保你考虑并测试这些情况。

英文:

Since you say that the problem seems easy without the lighter shape I'm going to assume that you know how to detect circles and lines / line segments (e.g. using variants of the Hough transform, as has been suggested in the comments).

In the edge image you show the circle is clearly visible. You should be able to locate it (and if I understand you correctly, you have already achieved that).

There are multiple lines which you should be able to find. The remaining problem is to figure out which one is the one you are interested in.
There are quite a few ways you could go about this, for example:

  • Notice that the intensity is similar on both sides of the stem but very different on both sides of one of the lines you want to ignore. Use this to find the line where the difference is smallest.
  • The edges of the trapezoid meet. Go through all combinations of line segments and discard those that form a corner. You could also limit the angle to some expected range.
  • In your image the stem consists of two mostly parallel lines. If that is always the case (and the lines can always be differentiated), you can use that to figure out which line is the one you are looking for.
  • Check if there is a line segment which ends inside the circle without also touching another line segment. If you find one, you know that the tip is inside the circle.

Quantify these conditions and check if one or a combination of them allows you to reliably pick out the stem from all lines.

The most problematic case would of course be if stem and edges align. Other special but less problematic cases would be if the stem crosses one or more of the edges, or if the stem ends at an edge. It is not clear to me which of these can happen - if they are possible, make sure you consider and test these scenarios.

huangapple
  • 本文由 发表于 2023年2月23日 21:56:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/75545766.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定