1 | initial version |
As @Tetragramm mentioned, morphology will be faster than connected components. If you use a morphological open (i.e. erosion followed by dilate), the size of the larger objects will be preserved whilst the noise will be removed.
However, this won't get of the object on the right. Does your bwareaopen get rid of this, or are you doing further processing to remove it?