MATLAB: How do you use roifill if the mask you have specifies all the pixels you want replaced

image maskImage Processing Toolboxroifill

I would like to use roifill to replace pixels in an image. I know exactly which pixels I want replaced so I can specify a mask in the second argument. But because I have specified a region with edges that are within the region I want replaced roifill does nothing (it's using these edge values to estimate the interior). I really want roifill to take pixels just outside of that masked region and map them to all values within. Is there anyway to identify all pixels 'just outside of' my mask region and define an 'augmented' mask?

Best Answer

You could dilate the mask to make it bigger or use the distance transform to identify pixels within n pixels of your mask.
doc imdilate
doc bwdist
Related Question