问题
I have an image with many shapes and I need to write some Matlab code which remove all the shapes except the rectangle.. Does it availabe to do it using only with strel,imclose and bwareaopen? if you think yes i will be very happy to hear your opinion.
Image:
回答1:
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 function creates a structuring element with given size for rectangle, disk or any other shape on the picture you added.
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 will be used to delete the objects which has less than P -given as input- pixels.
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!
来源:https://stackoverflow.com/questions/32787534/shape-detection-in-image-using-matlab