Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Defining criteria for blob analysis

Subject: Defining criteria for blob analysis

From: Nicolas

Date: 20 Apr, 2011 21:32:04

Message: 1 of 8

I've been doing some reading about various methods for blob analysis, and after applying many of them, I'm still not where I need to be. I've looked at IA's demos and fiddled with regionprops()...

In regards to regionprops, it is giving me way more centroids than what I'm looking for. For example, there may be 4 or 5 main blobs, and then a bunch of freckles scattered throughout (see: http://i92.photobucket.com/albums/l25/Affeyistruth/misc/test.jpg ) , and regionprops identifies centroids for every little spot.

My code (taken from Steve's blog):
s = regionprops(L, 'Centroid');
hold on
for k = 1:numel(s)
    plot(s(k).Centroid(1), s(k).Centroid(2), 'w*')
end
hold off
---------------------------
(How) can I set criteria for what defines a blob?

And lasty, another little issue I'm having - how do I find the maximum value/intensity in a given blob?

Thanks in advance for your help!

Subject: Defining criteria for blob analysis

From: Jeremy

Date: 20 Apr, 2011 22:41:05

Message: 2 of 8

Check out the function bwareaopen. It allows you to get rid of blobs containing less than a specified number of pixels.

Subject: Defining criteria for blob analysis

From: Jeremy

Date: 20 Apr, 2011 22:48:05

Message: 3 of 8

Also, look at the help for regionprops. You can also have it return a long list of properties about each region, including a list of pixels associated with each region, the min/max intensity of each region, etc.

Subject: Defining criteria for blob analysis

From: ImageAnalyst

Date: 20 Apr, 2011 22:53:00

Message: 4 of 8

On Apr 20, 5:32 pm, "Nicolas " <nickb...@yahoo.com> wrote:
> I've been doing some reading about various methods for blob analysis, and after applying many of them, I'm still not where I need to be.  I've looked at IA's demos and fiddled with regionprops()...
> (How) can I set criteria for what defines a blob?
>
> And lasty, another little issue I'm having - how do I find the maximum value/intensity in a given blob?
>
> Thanks in advance for your help!

---------------------------------------------------------------
My blobsdemo covers most of that. What was confusing to you? I
thought it was pretty extensively documented and explained.
To get the max intensity in any given blob, you'd have to do something
like

maxIntensityThisBlob = max(imageArray(measurements(k).PixelIdxList));
or something pretty close to that.

Subject: Defining criteria for blob analysis

From: Nicolas

Date: 21 Apr, 2011 19:47:05

Message: 5 of 8

Thanks very much; I went back to the demo and worked some stuff out. It's been a really big help.

One thing I would like to do is to highlight both bright AND dark blobs. I see in the BlobsDemo that I can choose one or the other... do I essentially need to duplicate the majority of the demo code to compute both cases?

Thanks again!

Subject: Defining criteria for blob analysis

From: ImageAnalyst

Date: 21 Apr, 2011 19:54:45

Message: 6 of 8

On Apr 21, 3:47 pm, "Nicolas " <nickb...@yahoo.com> wrote:
> Thanks very much; I went back to the demo and worked some stuff out. It's been a really big help.
>
> One thing I would like to do is to highlight both bright AND dark blobs.  I see in the BlobsDemo that I can choose one or the other... do I essentially need to duplicate the majority of the demo code to compute both cases?
>
> Thanks again!
------------------------------------------------------------------------------
No you don't to do that. You can do it all in a few lines.

Instead of
binaryImage = originalImage > thresholdValue; % Bright objects will be
the chosen if you use >.

you just have

  binaryImage = originalImage > highThresholdValue & ...
                  originalImage < lowThresholdValue;

For example you might have a gray background between 80 and 100 gray
levels, dark objects down around 50 and bright objects up around 200.
Then you'd do
lowThresholdValue = 80;
highThresholdValue = 100;
 binaryImage = originalImage > highThresholdValue & ...
                  originalImage < lowThresholdValue;

This would get both the dark and bright objects in the single image.
ImageAnalyst

Subject: Defining criteria for blob analysis

From: Nicolas

Date: 21 Apr, 2011 21:15:08

Message: 7 of 8


> Instead of
> binaryImage = originalImage > thresholdValue; % Bright objects will be
> the chosen if you use >.
>
> you just have
>
> binaryImage = originalImage > highThresholdValue & ...
> originalImage < lowThresholdValue;
>
> For example you might have a gray background between 80 and 100 gray
> levels, dark objects down around 50 and bright objects up around 200.
> Then you'd do
> lowThresholdValue = 80;
> highThresholdValue = 100;
> binaryImage = originalImage > highThresholdValue & ...
> originalImage < lowThresholdValue;
>
> This would get both the dark and bright objects in the single image.
> ImageAnalyst
------------------------------

Hmmm, for some reason that doesn't work for me. Doing either one alone works, but when I try to do both, binaryImage is full of zeros. For reference, I'm using Matlab 7.9.0, R2009b.

Subject: Defining criteria for blob analysis

From: ImageAnalyst

Date: 21 Apr, 2011 21:17:07

Message: 8 of 8

Sorry - should have been OR - I didn't test it.

binaryImage = originalImage > highThresholdValue | ...
                  originalImage < lowThresholdValue;

Tags for this Thread

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.

Contact us