Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab function equivalent for Python (Flood Fill)

Quick question, I'm looking for a python function that performs the equivalent job that matlab's imfill.m does. I realize that python has openCV but I have been unable to get that to work properly and am trying to find a substitute for it. The part of imfill that I'm trying to replicate is the 'holes' part of it.

I have a mask that I've generated but I'm trying to fill in all regions that are surrounded by 'land' and leave only the water regions unfilled in.

If this isn't clear enough please let me know and I can try and be more specific. Thank you for your time.

like image 854
Doomchinchilla Avatar asked Aug 04 '11 17:08

Doomchinchilla


1 Answers

I was able to find a function within scipy that performed similar to what imfill does. It's called binary_fill_holes and it can be found here for anyone that is having the same problem as myself.

Although I can't take full/any real credit for finding it since it was answered here to one of my other questions PIL Plus/imToolkit replacements by unutbu.

like image 181
Doomchinchilla Avatar answered Oct 07 '22 14:10

Doomchinchilla