Thread Subject: outer perimeter binary blobs - vectorisation

Subject: outer perimeter binary blobs - vectorisation

From: Brendan

Date: 8 Sep, 2009 12:47:41

Message: 1 of 6

I have a binary image with many (~2000) blobs. Each blob is separated
by at least two pixels. The image has been despurred and cleaned with
bwmorph and bwlabeled. I need to extract the outer perimeter(1 pixel
width) of each blob and give it the same label as its blob. This is
easily done by looping through the blobs, and taking the difference of
the blob and the blob enlarged by one pixel. Easily done but very
slow.

The above would extract the 8-connected outer perimeter. How would I
extract the 4-connected perimeter?

Any suggestions to vectorise or otherwise speed up this operation?

Thanks

Subject: outer perimeter binary blobs - vectorisation

From: Brendan

Date: 8 Sep, 2009 13:10:08

Message: 2 of 6

On Sep 8, 9:47 am, Brendan <brendandetra...@yahoo.com> wrote:
> I have a binary image with many (~2000) blobs. Each blob is separated
> by at least two pixels. The image has been despurred and cleaned with
> bwmorph and bwlabeled. I need to extract the outer perimeter(1 pixel
> width) of each blob and give it the same label as its blob. This is
> easily done by looping through the blobs, and taking the difference of
> the blob and the blob enlarged by one pixel. Easily done but very
> slow.
>
> The above would extract the 8-connected outer perimeter. How would I
> extract the 4-connected perimeter?
>
> Any suggestions to vectorise or otherwise speed up this operation?
>
> Thanks

Scratch the stupid 4-connected vs 8-connected perimeter question.
Suggestions on speed would still be appreciated.

Subject: outer perimeter binary blobs - vectorisation

From: ImageAnalyst

Date: 8 Sep, 2009 14:03:53

Message: 3 of 6

Brendan:
Your algorithm gets the enclosing perimeter - pixels that are outside
the blob, not part of the blob. You can erode the entire image (no
need to loop over individual blobs), and then subtract that from the
original image to get the perimeters. This way the perimeters will
actually be a part of your blob - the outermost layer of pixels that
are still contained within your blob. You can race that algorithm
against the built-in bwboundaries() to see which is faster.
Good luck,
ImageAnalyst

Subject: outer perimeter binary blobs - vectorisation

From: Brendan

Date: 9 Sep, 2009 00:04:07

Message: 4 of 6

On Sep 8, 11:03 am, ImageAnalyst <imageanal...@mailinator.com> wrote:
> Brendan:
> Your algorithm gets the enclosing perimeter - pixels that are outside
> the blob, not part of the blob.  You can erode the entire image (no
> need to loop over individual blobs), and then subtract that from the
> original image to get the perimeters.  This way the perimeters will
> actually be a part of your blob - the outermost layer of pixels that
> are still contained within your blob.  You can race that algorithm
> against the built-in bwboundaries() to see which is faster.
> Good luck,
> ImageAnalyst

Thanks for the answer.

I am trying replicate a cloud masking paper in which edge pixels are
determined by thresholding cluster shade. The paper then compares the
mean pixel value for each edge against the mean pixel value for each
interior. My starting point is a bitmap of unsorted edge pixels. I
think I am stuck with looping unless I use the inner perimeter,
however this will disqualify small blobs.

Subject: outer perimeter binary blobs - vectorisation

From: ImageAnalyst

Date: 9 Sep, 2009 01:27:53

Message: 5 of 6

On Sep 8, 8:04 pm, Brendan <brendandetra...@yahoo.com> wrote:
> Thanks for the answer.
>
> I am trying replicate a cloud masking paper in which edge pixels are
> determined by thresholding cluster shade. The paper then compares the
> mean pixel value for each edge against the mean pixel value for each
> interior. My starting point is a bitmap of unsorted edge pixels. I
> think I am stuck with looping unless I use the inner perimeter,
> however this will disqualify small blobs.
-------------------------------------------------------------------------------------------------------------
Brendan:
I thought your starting point was the labeled image like you said in
your first post. Well either way, I just don't see how looping over
individual blobs is necessary. You can process the whole image just
by doing what I said. The only way that this could be considered
looping is if you write the erosion routine by yourself and by looping
you mean that you raster scan over every pixel in the image (which is
a nested for loop) and then scan an n-by-n window in there (another
nested for loop). but I just can't understand how you'd need to do
looping over blobs like this
for blobNumber = 1 : totalNumberOfBlobs
   % Extract the portion of the image that is the blob into a small
sub-image.
    % process that sub image
end
I just don't think you need to do this. You CAN but I believe it's
unnecessary and may take longer. imerode() may have the 4 nested for
loops internally but as far as you're concerned, it's a one line
function call.

I also don't see why you say that subtracting the eroded image from
the original image will "disqualify" small blobs. The outlines of the
small blobs will be there using that algorithm even if they are only
1, 2, 3, etc. pixels big. Not sure what you mean by disqualify as
this will get their outlines.

And if you want the boundaries as separate objects instead of a binary
image, just use bwboundaries() on the binary image like I said.

But your description of the "cloud masking paper" didn't sound like a
pure binary operation - it sounded like it had some candidate edge
pixels (a binary image found by some preprocessing) and then it's
trying to refine whether an edge pixel in that binary image really IS
a true edge pixel by doing some gray scale processing on the original
image.
Regards,
ImageAnalyst

Subject: outer perimeter binary blobs - vectorisation

From: Brendan

Date: 10 Sep, 2009 18:36:47

Message: 6 of 6

On Sep 8, 10:27 pm, ImageAnalyst <imageanal...@mailinator.com> wrote:
> On Sep 8, 8:04 pm, Brendan <brendandetra...@yahoo.com> wrote:> Thanks for the answer.
>
> > I am trying replicate a cloud masking paper in which edge pixels are
> > determined by thresholding cluster shade. The paper then compares the
> > mean pixel value for each edge against the mean pixel value for each
> > interior. My starting point is a bitmap of unsorted edge pixels. I
> > think I am stuck with looping unless I use the inner perimeter,
> > however this will disqualify small blobs.
>
> ---------------------------------------------------------------------------­----------------------------------
> Brendan:
> I thought your starting point was the labeled image like you said in
> your first post.  Well either way, I just don't see how looping over
> individual blobs is necessary.  You can process the whole image just
> by doing what I said.  The only way that this could be considered
> looping is if you write the erosion routine by yourself and by looping
> you mean that you raster scan over every pixel in the image (which is
> a nested for loop) and then scan an n-by-n window in there (another
> nested for loop).  but I just can't understand how you'd need to do
> looping over blobs like this
> for blobNumber = 1 : totalNumberOfBlobs
>    % Extract the portion of the image that is the blob into a small
> sub-image.
>     % process that sub image
> end
> I just don't think you need to do this.  You CAN but I believe it's
> unnecessary and may take longer.  imerode() may have the 4 nested for
> loops internally but as far as you're concerned, it's a one line
> function call.
>
> I also don't see why you say that subtracting the eroded image from
> the original image will "disqualify" small blobs.  The outlines of the
> small blobs will be there using that algorithm even if they are only
> 1, 2, 3, etc. pixels big.  Not sure what you mean by disqualify as
> this will get their outlines.
>
> And if you want the boundaries as separate objects instead of a binary
> image, just use bwboundaries() on the binary image like I said.
>
> But your description of the "cloud masking paper" didn't sound like a
> pure binary operation - it sounded like it had some candidate edge
> pixels (a binary image found by some preprocessing) and then it's
> trying to refine whether an edge pixel in that binary image really IS
> a true edge pixel by doing some gray scale processing on the original
> image.
> Regards,
> ImageAnalyst

If I erode the image, blobs will all merge since they are separated by
two pixels. Sounds like if can decide to define only one pixel as
edge, then life will be easier. My problem, however, remains the same.
I need a common label for a blob boundary and its interior.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
perimeter binar... Sprinceana 8 Sep, 2009 11:17:12
blobs Sprinceana 8 Sep, 2009 11:17:12
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com