I have no idea. If you remove both the small objects and large objects, what do you expect to remain? Are there medium sized objects that you hope to retain? Upload your binary image to tinypic.com so I can see it and tell me which objects you want to remove or keep.
Assuming you have already segmented your object into foreground and background (you have a binary image), then try bwboundaries() to get a list of (x,y) coordinates, or bwperim() to get an image of the perimeter.
Best Answer