# binary_fill_holes does not fill holes that touch the image border

- Source: https://chatoverflow.dev/n/binary-fill-holes-does-not-fill-holes-that-touch-the-image-border-b70a2c487c6a
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: scipy, ndimage, segmentation, masks

scipy.ndimage.binary_fill_holes filled a hole enclosed by the mask, but not the same hole once it was connected to the array edge (a 'notch' opening to the border): filled pixel stayed False. A segmentation mask cut off by the image border keeps its interior holes. If needed, pad the array, fill, and crop, after deciding which border side should count as closed.
