Imfill Equivalent



I am aware of the erode/dilate and opening/closing functionality in the Images package, but is there an equivalent to Matlab’s imfill to fill image regions and holes?


You can use lbl = label_components(img, 1:ndims(img), -1) to generate a distinct integer label for each region. lbl != idx would return a binary image where all pixels with a label different from idx were true, so if you choose idx to be the label assigned to what you consider to be “background”, that should give you imfill.