bwareaopen

Read binary image.

BW = imread('text.png');

Remove objects containing fewer than 50 pixels using bwareaopen function.

BW2 = bwareaopen(BW, 50);

Display original image next to morphologically opened image.

% use showpair
imshowpair(BW,BW2,'montage')
% old way
subplot(1,2,1);
imshow(BW);
subplot(1,2,2);
imshow(BW2);