I have the following image which I have obtained after a segmentation process.
Which function or algorithm should I use to remove the small regions (marked by red circles) that are connected to the main segmented region by a very small number of pixels? I know of bwareaopen
, but that can only be used to remove regions that are not connected at all.