Avoiding identifying objects within previously identified objects in MATLAB
There are two alternatives to this.


Adjust your opening parameter so that you end up with a fully connected shape. Say, instead of 15 you can use 25.
You can find the areas of all intersecting polygons using e.g. this. If the area of an intersection is higher than a given threshold, discard the polygon. 


After finding overlapping polygons, you could consider averaging the hypothesis so that you end up with a more correct shape pose.