What's the most efficient way to isolate a connected region in a binary image given a point contained within that region?

I have a series of binary images with various numbers of 8-connected regions within them. Given a single coordinate lying within one of those regions, what is the most efficient way to generate a binary image that isolates only the connected region containing that point?
For example, given the top image and a single coordinate somewhere in the central region, how can I most efficiently produce the bottom image?
I'm currently doing this using progressive imdilate operations with a 3x3 square SE until I find a stable image. This method seems very inefficient, though, and since I'm doing this kind of operation millions of times within my program, I want to know if I can be doing much better. Any advice from the image processing experts out there?
Thanks,
Andrew
...

 Accepted Answer

There is a morphological function specially made for this . It's call imreconstruct(). You pass in a binary image, and a marker image. The marker image has at least one pixel for all the blobs you want to extract/keep out of your binary image. For example the marker image could be all false/0 except true/1 at the one single dot that you mentioned. Any blob in yoru binary image that has a pixel in it from the marker image will be kept (extracted). See this example:
markerImage = false(size(binaryImage)); % Initialize to all false.
markerImage(row, column) = true; % Set one pixel to be true.
% Now extract only the blob that has the dot in it.
keeperBlobs = imreconstruct(binaryImage, markerImage);

Asked:

on 28 Feb 2014

Commented:

on 28 Feb 2014

Community Treasure Hunt

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

Start Hunting!