Retaining the largest blob in an image

'bwlargestblob' reads in a 2-d binary image and outputs a binary image, retaining only the largest b

You are now following this Submission

'bwlargestblob' reads in a 2-d binary image and outputs a binary image, retaining only the largest blob.

Usage: [outim] = bwlargestblob(im,connectivity)

im - 2-d binary image
conenctivity - Accepts 4/8 connectivity
outim - Output binary image (with 1s and 0s)

Example:

im = imread('text.png');
outim = bwlargestblob(im,8);
figure;
subplot(1,2,1); imshow(im);
subplot(1,2,2); imshow(255*outim);

Cite As

Ani (2026). Retaining the largest blob in an image (https://au.mathworks.com/matlabcentral/fileexchange/15596-retaining-the-largest-blob-in-an-image), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0