Opposite of IMFILL Functionality (Working on Pixels) !!!!

Hey Guys.
As we all are aware of the functionality of IMFILL,that it basically perform floodfill functionality.Now I am working on a project,which requires the filling of holes with off/black pixels, I have white different spots,patches on the image.My project doesn't work according to my conditions by this current IMFILL working. *Basically I want that IMFILL function that works on foreground pixels to fill the object with black pixels. Is there any function like IMFILL which works on foreground pixels (white pixels).
Any solution will highly regarded.
Thank You

Answers (1)

Matt J
Matt J on 30 Jun 2015
Edited: Matt J on 30 Jun 2015
Why not just apply imfill to the complement,
~imfill( ~YourImage,... )

4 Comments

It's not working,it changes the nature of whole image.
If it is not working then you need to explain in more detail what your image is. From your description it sounds like a binary image and so there's no reason for it 'not working'.
I have attached sample image ,using IMFILL function (providing the coordinates) I want to fill any of these white spot with black pixels. Note = Must use the IMFILL function to do this.
Using the attached image:
testimg = im2bw(imread('test.jpg'));
filledimg = ~imfill(~testimg, 'holes')); %as per Matt's answer
imshow(filledimg);
does exactly what you want, fill the holes in white and leaves you with a black image.

Sign in to comment.

Asked:

on 30 Jun 2015

Commented:

on 30 Jun 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!