且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Matlab进行图像形状检测

更新时间:2023-02-26 14:23:01

如果我从你的评论中理解,矩形可以有任何大小。我认为只有当其他形状具有固定大小时才能询问,因为要求您使用strel,imclose和bwareaopen。简要说明一下,

If I understood right from your comment, rectangle may have any size. I think this can be asked only if the other shapes have fixed size since you are asked to use strel, imclose and bwareaopen. To briefly explain,

strel 函数为矩形,磁盘或任何其他形状创建一个给定大小的结构元素在您添加的图片上。

strel function creates a structuring element with given size for rectangle, disk or any other shape on the picture you added.

imclose 应该用于连接您提供的类似形状作为输入(基本上是您应该找到的结构元素) strel函数)。

imclose should be used to connect the similar shapes you give as input(basically the structuring element you should find from the strel function).

bwareaopen 将用于删除少于P -given作为输入像素的对象。

bwareaopen will be used to delete the objects which has less than P -given as input- pixels.

因此,如果可以为此图像指定任何大小的矩形,则其他形状应保持不变,以便能够使用strel函数定义它们,并通过使用连接imclose功能。通过这种方式,您可以将它们全部连接起来,取反之,使用bwareaopen删除并再次反向以矩形结束。

So, if the rectangle can be given in any size for this image, the other shapes should stay the same in order to be able to define them with strel function, and connect by using imclose function. In this way, you may connect them all, take inverse, remove using bwareaopen and take inverse once again to end up with rectangle.

我无法想到任何其他解决方案希望它有所帮助!

I could not think about any other solution, hope it helps!