BW2 = imfill(BW)
BW2 = imfill(BW, 'holes')
BW2 = imfill(BW, conn, 'holes')
| Parameter | Description |
|---|---|
| BW | Input binary image. Nonzero values are treated as true. |
| conn | Connectivity, either 4 or 8. |
| 'holes' | Fill holes in foreground objects. |
| Parameter | Description |
|---|---|
| BW2 | Logical image with holes filled. |
Fill holes in a 2-D binary image. Supported connectivities are 4 and 8.
BW=false(64,64); BW(12:52,12:52)=true; BW(24:40,24:40)=false;
BW2=imfill(BW,'holes');
figure; subplot(1,2,1); imagesc(BW); title('Input');
subplot(1,2,2); imagesc(BW2); title('Filled');
| Version | Description |
|---|---|
| 2.0.0 | initial version |