EmguCV 形状检测受图像尺寸的影响

发布于 2024-12-05 15:48:08 字数 334 浏览 0 评论 0原文

我正在使用 Emgu 形状检测示例应用程序来检测给定图像上的矩形。即使纵横比保持不变,调整大小后的图像的尺寸似乎也会影响检测到的形状数量。我的意思是这样的:

使用 (400,400),实际图像大小 == 342,400

使用 (520,520),实际图像size == 445,520

为什么会这样呢?以及如何确定最优值?

谢谢

I'm using the Emgu shape detection example application to detect rectangles on a given image. The dimensions of the resized image appear to impact the number of shapes detected even though the aspect ratio remains the same. Here's what I mean:

Using (400,400), actual img size == 342,400

Using (520,520), actual img size == 445,520

Why is this so? And how can the optimal value be determined?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嗫嚅 2024-12-12 15:48:08

我回复了您在 EMGU 上的帖子,但我认为您还没有回来查看,但就是这样。形状检测的工作原理是阈值保留不太可能的匹配,这可以防止大量错误分类。对于许多图像处理算法来说都是如此。基本上没有完美的设置,设计师必须选择最合适的设置才能产生最理想的结果。 IE 会匹配最多的对象,但不会说有比实际更多的对象。

您需要单独调整每个变量,看看会得到什么样的结果。从边缘检测开始。

Image<Gray, Byte> cannyEdges = gray.Canny(cannyThreshold, cannyThresholdLinking);

看看你的小图像,看看检测到的矩形和未检测到的矩形之间有什么区别。您可能会丢失边缘或角落,这就是它不被分类的原因。如果您调整cannyThreshold并观察结果,如果好,则保留它:)如果不好:(返回到原始值。一旦满意,调整cannyThresholdLinking并观察。

您将不断重复此操作,直到获得首选图像,这里的优点是您有 3 个项目需要比较,您将继续进行,直到未识别的项目与其他两个项目匹配为止。

如果它们相似,则可能是因为它是黑白图像,所以您需要进行霍夫线检测

        LineSegment2D[] lines = cannyEdges.HoughLinesBinary(
            1, //Distance resolution in pixel-related units
            Math.PI / 45.0, //Angle resolution measured in radians.
            20, //threshold
            30, //min Line width
            10 //gap between lines
            )[0]; //Get the lines from the first channel

。一次调整一个值并观察输出的相同方法,您将有望找到所需的设置,因为您永远不会知道是否提高了准确性。否则无法查看检查矩形的霍夫结果的部分

                      if (angle < 80 || angle > 100)
                       {
                          isRectangle = false;
                          break;
                       }

,因为霍夫应该为您完成所有工作,但仍然可以在这里解决问题,

但很抱歉没有直接的答案 。我希望你能坚持下去并解决问题。否则,您每次都可以调整图像大小。

干杯

克里斯

I replied to your post on EMGU but figured you haven't checked back but this is it. The shape detection works on the principle of thresh-holding unlikely matches, this prevents lots of false classifications. This is true for many image processing algorithms. Basically there are no perfect setting and a designer must select the most appropriate settings to produce the most desirable results. I.E. match the most objects without saying there's more than there actually is.

You will need to adjust each variable individually to see what kind of results you get. Start of with the edge detection.

Image<Gray, Byte> cannyEdges = gray.Canny(cannyThreshold, cannyThresholdLinking);

Have a look at your smaller image see what the difference is between the rectangles detected and the one that isn't. You could be missing and edge or a corner which is why it's not classified. If you are adjust cannyThreshold and observe the results, if good then keep it :) if bad :( go back to the original value. Once satisfied adjust cannyThresholdLinking and observe.

You will keep repeating this until you get a preferred image the advantage here is that you have 3 items to compare you will continue until the item that's not being recognised matches the other two.

If they are the similar, likely as it is a black and white image you'll need to go onto the Hough lines detection.

        LineSegment2D[] lines = cannyEdges.HoughLinesBinary(
            1, //Distance resolution in pixel-related units
            Math.PI / 45.0, //Angle resolution measured in radians.
            20, //threshold
            30, //min Line width
            10 //gap between lines
            )[0]; //Get the lines from the first channel

Use the same method of adjusting one value at a time and observing the output you will hopefully find the settings you need. Never jump in with both feet and change all the values as you will never know if your improving the accuracy or not. Finally if all else fails look at the section that inspects the Hough results for a rectangle

                      if (angle < 80 || angle > 100)
                       {
                          isRectangle = false;
                          break;
                       }

Less variables to change as hough should do all the work for you. but still it could all work out here.

I'm sorry that there is no straight forward answer, but I hope you keep at it and solve the problem. Else you could always resize the image each time.

Cheers

Chris

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文