Thread Subject: find Spots in the Image

Subject: find Spots in the Image

From: Yi

Date: 21 Sep, 2009 03:02:03

Message: 1 of 19

I wuold like to do a test by Using Matlab image processing.
1. find whether a white image contains black spots
2. if there are black spots in it, find whether black spots contain white hole.
    (should be able to detect and ignore blobs that touch the image boundary).
3. we should find there are any spots that touch the image boundary.and How many?

i really need help.
i hope i can get some ideas.

thanks every one

Subject: find Spots in the Image

From: Yi

Date: 21 Sep, 2009 03:14:05

Message: 2 of 19

the image is a grey level, so it is black and white only

"Yi " <heyinba0904@hotmail.com> wrote in message <h96qbb$ug$1@fred.mathworks.com>...
> I wuold like to do a test by Using Matlab image processing.
> 1. find whether a white image contains black spots
> 2. if there are black spots in it, find whether black spots contain white hole.
> (should be able to detect and ignore blobs that touch the image boundary).
> 3. we should find there are any spots that touch the image boundary.and How many?
>
> i really need help.
> i hope i can get some ideas.
>
> thanks every one

Subject: find Spots in the Image

From: Yi

Date: 21 Sep, 2009 04:36:04

Message: 3 of 19


gray-level
please help!!

Subject: find Spots in the Image

From: ImageAnalyst

Date: 21 Sep, 2009 10:15:00

Message: 4 of 19

On Sep 21, 12:36 am, "Yi " <heyinba0...@hotmail.com> wrote:
> gray-level
> please help!!

---------------------------------------------------------------------------
Try my image processing tutorial. It will do this. All you have to
do is a slight adaptation of it so that the threshold is 0 (or
whatever the brightest gray level of the black spots is).

http://www.mathworks.com/matlabcentral/fileexchange/25157

Good luck,
ImageAnalyst

Subject: find Spots in the Image

From: Yi

Date: 22 Sep, 2009 01:08:04

Message: 5 of 19

Hi ImageAnalyst:

what is reginprops function ? Does it give me the number of spots? how can i know the spots contain a white hole?

thanks ImageAnalyst


ImageAnalyst <imageanalyst@mailinator.com> wrote in message <89cfe21d-e61b-4989-be3e-77b50692c030@y20g2000vbk.googlegroups.com>...
> On Sep 21, 12:36?am, "Yi " <heyinba0...@hotmail.com> wrote:
> > gray-level
> > please help!!
>
> ---------------------------------------------------------------------------
> Try my image processing tutorial. It will do this. All you have to
> do is a slight adaptation of it so that the threshold is 0 (or
> whatever the brightest gray level of the black spots is).
>
> http://www.mathworks.com/matlabcentral/fileexchange/25157
>
> Good luck,
> ImageAnalyst

Subject: find Spots in the Image

From: ImageAnalyst

Date: 22 Sep, 2009 01:22:06

Message: 6 of 19

On Sep 21, 9:08 pm, "Yi " <heyinba0...@hotmail.com> wrote:
> Hi ImageAnalyst:
>
> what is reginprops function ? Does it give me the number of spots? how can i know the spots contain a white hole?
>
> thanks ImageAnalyst

------------------------------------------------------------------------------
Did you check out my tutorial in the link - it uses regionprops().
The demo image is basically white coins (spots) on a black background
- pretty similar to your situation I would think. Are you now saying
that you have black spots with a white hole in them so that they are
now black with white in the middle, or basically a black ring or "O"
shape on a white background? Why don't you post an image somewhere so
we don't have to guess?

regionprops is also described in the MATLAB help file. Basically it
makes measurements on an image given a segmented and labeled binary
image.

Subject: find Spots in the Image

From: Yi

Date: 22 Sep, 2009 01:59:06

Message: 7 of 19

Hi ImageAnalyst:
Sorry, I don't know How to post Image on this Website. I think they do not allow posting image. so Could I sent Image to your Email?

My image is white colour(white background), and it contains black blobs. The hole is white and it can be any shape, as long as it is included inside black blob.

thank you





ImageAnalyst <imageanalyst@mailinator.com> wrote in message <2ccdaea8-ab83-4439-86a2-36957876f227@g23g2000vbr.googlegroups.com>...
> On Sep 21, 9:08?pm, "Yi " <heyinba0...@hotmail.com> wrote:
> > Hi ImageAnalyst:
> >
> > what is reginprops function ? Does it give me the number of spots? how can i know the spots contain a white hole?
> >
> > thanks ImageAnalyst
>
> ------------------------------------------------------------------------------
> Did you check out my tutorial in the link - it uses regionprops().
> The demo image is basically white coins (spots) on a black background
> - pretty similar to your situation I would think. Are you now saying
> that you have black spots with a white hole in them so that they are
> now black with white in the middle, or basically a black ring or "O"
> shape on a white background? Why don't you post an image somewhere so
> we don't have to guess?
>
> regionprops is also described in the MATLAB help file. Basically it
> makes measurements on an image given a segmented and labeled binary
> image.

Subject: find Spots in the Image

From: ImageAnalyst

Date: 22 Sep, 2009 02:12:22

Message: 8 of 19

On Sep 21, 9:59 pm, "Yi " <heyinba0...@hotmail.com> wrote:
> Hi ImageAnalyst:
> Sorry, I don't know How to post Image on this Website. I think they do not allow posting image.  so Could I sent Image to your Email?
>
> My image is white colour(white background), and it contains black blobs. The hole is white and it can be any shape, as long as it is included inside black blob.
>
> thank you
>
>
>
> ImageAnalyst <imageanal...@mailinator.com> wrote in message <2ccdaea8-ab83-4439-86a2-36957876f...@g23g2000vbr.googlegroups.com>...
> > On Sep 21, 9:08?pm, "Yi " <heyinba0...@hotmail.com> wrote:
> > > Hi ImageAnalyst:
>
> > > what is reginprops function ? Does it give me the number of spots? how can i know the spots contain a white hole?
>
> > > thanks ImageAnalyst
>
> > ---------------------------------------------------------------------------­---
> > Did you check out my tutorial in the link - it uses regionprops().
> > The demo image is basically white coins (spots) on a black background
> > - pretty similar to your situation I would think.  Are you now saying
> > that you have black spots with a white hole in them so that they are
> > now black with white in the middle, or basically a black ring or "O"
> > shape on a white background?  Why don't you post an image somewhere so
> > we don't have to guess?
>
> > regionprops is also described in the MATLAB help file.  Basically it
> > makes measurements on an image given a segmented and labeled binary
> > image.- Hide quoted text -
>
> - Show quoted text -

----------------------------------------------------------------
Just google "free image hosting" and pick a site, such as flickr.com
or imageshack.us.

Subject: find Spots in the Image

From: Yi

Date: 22 Sep, 2009 02:33:04

Message: 9 of 19

Hi ImageAnalyst:
this is my image at:
http://img199.imageshack.us/img199/8948/testimageg.jpg
then you can see there are two blobs which contian the hole
and the other one doesn't.
so in my result, i need to tell user ,total is 3 blobs, two blobs contain hole, one doesn't contain.

thank you!!


ImageAnalyst <imageanalyst@mailinator.com> wrote in message <3aeaa406-d937-4807-a397-4e46c2ea46ec@s6g2000vbp.googlegroups.com>...
> On Sep 21, 9:59?pm, "Yi " <heyinba0...@hotmail.com> wrote:
> > Hi ImageAnalyst:
> > Sorry, I don't know How to post Image on this Website. I think they do not allow posting image. ?so Could I sent Image to your Email?
> >
> > My image is white colour(white background), and it contains black blobs. The hole is white and it can be any shape, as long as it is included inside black blob.
> >
> > thank you
> >
> >
> >
> > ImageAnalyst <imageanal...@mailinator.com> wrote in message <2ccdaea8-ab83-4439-86a2-36957876f...@g23g2000vbr.googlegroups.com>...
> > > On Sep 21, 9:08?pm, "Yi " <heyinba0...@hotmail.com> wrote:
> > > > Hi ImageAnalyst:
> >
> > > > what is reginprops function ? Does it give me the number of spots? how can i know the spots contain a white hole?
> >
> > > > thanks ImageAnalyst
> >
> > > ---------------------------------------------------------------------------?---
> > > Did you check out my tutorial in the link - it uses regionprops().
> > > The demo image is basically white coins (spots) on a black background
> > > - pretty similar to your situation I would think. ?Are you now saying
> > > that you have black spots with a white hole in them so that they are
> > > now black with white in the middle, or basically a black ring or "O"
> > > shape on a white background? ?Why don't you post an image somewhere so
> > > we don't have to guess?
> >
> > > regionprops is also described in the MATLAB help file. ?Basically it
> > > makes measurements on an image given a segmented and labeled binary
> > > image.- Hide quoted text -
> >
> > - Show quoted text -
>
> ----------------------------------------------------------------
> Just google "free image hosting" and pick a site, such as flickr.com
> or imageshack.us.

Subject: find Spots in the Image

From: Image Analyst

Date: 22 Sep, 2009 10:43:04

Message: 10 of 19

See my tutorial and adapt it to ask regionprops() for the EulerNumber:

'EulerNumber' — Scalar that specifies the number of objects in the region minus the number of holes in those objects. This property is supported only for 2-D input label matrices. regionprops uses 8-connectivity to compute the EulerNumber measurement. To learn more about connectivity, see Pixel Connectivity.

This should get you what you asked for.
Good luck,
ImageAnalyst

Subject: find Spots in the Image

From: Yi

Date: 22 Sep, 2009 23:14:02

Message: 11 of 19

hi ImageAnalyst
i have read your tutorial. this is the code what i learn from your tutorial:

% Read in standard MATLAB demo image
originalImageX = imread('testImage.JPG');
originalImage = rgb2gray(originalImageX);
thresholdValue = 1;
binaryImage = originalImage < thresholdValue;
binaryImage = imfill(binaryImage, 'holes');
labeledImage = bwlabel(binaryImage, 8);
blobMeasurements = regionprops(labeledImage, originalImage, 'EulerNumber');
numberOfBlobs = size(blobMeasurements, 1);

after i run this function
i got numberOfBlobs = 49 and each of them has a EulerNumber which equal to "1"
so i really can not understand the meaning of this result.
could you help me and give me some ideas?

thanks so much



"Image Analyst" <imageanalyst@mailinator.com> wrote in message <h9a9no$jni$1@fred.mathworks.com>...
> See my tutorial and adapt it to ask regionprops() for the EulerNumber:
>
> 'EulerNumber' — Scalar that specifies the number of objects in the region minus the number of holes in those objects. This property is supported only for 2-D input label matrices. regionprops uses 8-connectivity to compute the EulerNumber measurement. To learn more about connectivity, see Pixel Connectivity.
>
> This should get you what you asked for.
> Good luck,
> ImageAnalyst

Subject: find Spots in the Image

From: ImageAnalyst

Date: 23 Sep, 2009 02:26:17

Message: 12 of 19

On Sep 22, 7:14 pm, "Yi " <heyinba0...@hotmail.com> wrote:
> hi ImageAnalyst
> i have read your tutorial. this is the code what i learn from your tutorial:
>
> % Read in standard MATLAB demo image
> originalImageX = imread('testImage.JPG');
> originalImage = rgb2gray(originalImageX);
> thresholdValue = 1;
> binaryImage = originalImage < thresholdValue;
> binaryImage = imfill(binaryImage, 'holes');
> labeledImage = bwlabel(binaryImage, 8);
> blobMeasurements = regionprops(labeledImage, originalImage, 'EulerNumber');  
> numberOfBlobs = size(blobMeasurements, 1);
>
> after i run this function
> i got numberOfBlobs = 49 and each of them has a EulerNumber which equal to "1"
> so i really can not understand the meaning of this result.
> could you help me and give me some ideas?
>
> thanks so much
>
--------------------------------------------------------------------------------
Try this:

workspace;
% Read in demo image
originalImageX = imread('testimageg.jpg');
originalImage = rgb2gray(originalImageX);
subplot(3,1,1);
imshow(originalImage, []);
title('Original Image');

thresholdValue = 150;
binaryImage = originalImage < thresholdValue;
subplot(3,1,2);
imshow(binaryImage, []);
title('Binarized Image');

labeledImage = bwlabel(binaryImage, 8);
subplot(3,1,3);
imshow(labeledImage, []);
title('Labeled Image');

blobMeasurements = regionprops(labeledImage, originalImage,
'EulerNumber', 'Centroid');
numberOfBlobs = size(blobMeasurements, 1);
for blobNumber = 1 : numberOfBlobs
    thisBlobsEulerNumber = int32(blobMeasurements
(blobNumber).EulerNumber); % Get list of pixels in current blob.
numberOfHoles = int32(1 - thisBlobsEulerNumber);
blobCentroid = blobMeasurements(blobNumber).Centroid; % Get
centroid.
labelString = sprintf('Blob #%d', blobNumber);
text(blobCentroid(1), blobCentroid(2), labelString, 'Color', [1 .25 .
10], 'FontSize', 14);
    fprintf(1,'Blob #%d Euler Number = %d, number of Holes = %d \n',
blobNumber, thisBlobsEulerNumber, numberOfHoles);
end
set(gcf, 'Position', get(0, 'ScreenSize')); % Maximize figure.
uiwait(msgbox('Check out the command window'));

Subject: find Spots in the Image

From: ImageAnalyst

Date: 23 Sep, 2009 02:29:30

Message: 13 of 19

On Sep 22, 7:14 pm, "Yi " <heyinba0...@hotmail.com> wrote:
> hi ImageAnalyst
> i have read your tutorial. this is the code what i learn from your tutorial:
>
> % Read in standard MATLAB demo image
> originalImageX = imread('testImage.JPG');
> originalImage = rgb2gray(originalImageX);
> thresholdValue = 1;
> binaryImage = originalImage < thresholdValue;
> binaryImage = imfill(binaryImage, 'holes');
> labeledImage = bwlabel(binaryImage, 8);
> blobMeasurements = regionprops(labeledImage, originalImage, 'EulerNumber');  
> numberOfBlobs = size(blobMeasurements, 1);
>
> after i run this function
> i got numberOfBlobs = 49 and each of them has a EulerNumber which equal to "1"
> so i really can not understand the meaning of this result.
> could you help me and give me some ideas?
>
> thanks so much
---------------------------------------------------------------------------------
Your problem was that you called
binaryImage = imfill(binaryImage, 'holes');
for some reason. Why did you do that? You just filled the holes you
were hoping to count.

Subject: find Spots in the Image

From: Yi

Date: 23 Sep, 2009 03:28:02

Message: 14 of 19

Hi ImageAnalyst:
Thank you so much!!! You really help me a lots !!!
and last question, How can i detect the blobs which touch the image boundary?
Do i need use boundingbox of each blobs? or something else?

thanks ^_^

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <d0c0f9fb-b8b1-4ef9-aee2-b4af570ed60a@j9g2000vbp.googlegroups.com>...
> On Sep 22, 7:14?pm, "Yi " <heyinba0...@hotmail.com> wrote:
> > hi ImageAnalyst
> > i have read your tutorial. this is the code what i learn from your tutorial:
> >
> > % Read in standard MATLAB demo image
> > originalImageX = imread('testImage.JPG');
> > originalImage = rgb2gray(originalImageX);
> > thresholdValue = 1;
> > binaryImage = originalImage < thresholdValue;
> > binaryImage = imfill(binaryImage, 'holes');
> > labeledImage = bwlabel(binaryImage, 8);
> > blobMeasurements = regionprops(labeledImage, originalImage, 'EulerNumber'); ?
> > numberOfBlobs = size(blobMeasurements, 1);
> >
> > after i run this function
> > i got numberOfBlobs = 49 and each of them has a EulerNumber which equal to "1"
> > so i really can not understand the meaning of this result.
> > could you help me and give me some ideas?
> >
> > thanks so much
> ---------------------------------------------------------------------------------
> Your problem was that you called
> binaryImage = imfill(binaryImage, 'holes');
> for some reason. Why did you do that? You just filled the holes you
> were hoping to count.

Subject: find Spots in the Image

From: ImageAnalyst

Date: 23 Sep, 2009 09:59:47

Message: 15 of 19

On Sep 22, 11:28 pm, "Yi " <heyinba0...@hotmail.com> wrote:
> Hi ImageAnalyst:
> Thank you so much!!! You really help me a lots !!!
> and last question, How can i  detect the blobs which touch the image boundary?
> Do i need use boundingbox of each blobs? or something else?
>
> thanks ^_^
----------------------------------------------------------------------------------------------
No. You can use imclearborder(). Just call that and subtract it's
result from your original (input) binary image.

Subject: find Spots in the Image

From: Yi

Date: 23 Sep, 2009 11:07:04

Message: 16 of 19

Hi ImageAnalyst:
I don't understand what is "original(input)" meaning?
original()---- is it a function?
thanks



ImageAnalyst <imageanalyst@mailinator.com> wrote in message <7c927726-fa9e-4cd1-826a-089be7a6eb2c@v2g2000vbb.googlegroups.com>...
> On Sep 22, 11:28?pm, "Yi " <heyinba0...@hotmail.com> wrote:
> > Hi ImageAnalyst:
> > Thank you so much!!! You really help me a lots !!!
> > and last question, How can i ?detect the blobs which touch the image boundary?
> > Do i need use boundingbox of each blobs? or something else?
> >
> > thanks ^_^
> ----------------------------------------------------------------------------------------------
> No. You can use imclearborder(). Just call that and subtract it's
> result from your original (input) binary image.

Subject: find Spots in the Image

From: ImageAnalyst

Date: 23 Sep, 2009 12:30:12

Message: 17 of 19

On Sep 23, 7:07 am, "Yi " <heyinba0...@hotmail.com> wrote:
> Hi ImageAnalyst:
> I don't understand what is "original(input)" meaning?
> original()---- is it a function?
> thanks

-------------------------------------------------------------------------
Yi:
You have an image where blobs touch the border.
Let's call this the "original image." I just put it in parentheses to
mean that I'm giving an alternate name for it.
See http://en.wikipedia.org/wiki/Parenthesis_(rhetoric) for an
explanation of a "parenthesis" in a rhetorical sentence: "An
explanatory or qualifying word, clause, or sentence inserted into a
passage with which it doesn't necessarily have any grammatical
connection, and from which it is usually marked off by round or square
brackets, dashes, or commas according to the Oxford English
Dictionary."

Now let's run that image though imclearborder() and get back an image
with no border blobs in it.
Let's call that image the "output image."
outputImage = imclearborder(inputImage);
Make sense? Now simply subtract them:
borderBlobs = inputImage- outputImage;

Here's some more demo code. Just copy, paste, fix lines broken by the
newsreader, and run.
Best wishes,
ImageAnalyst

clc;
%clear all;
close all;
workspace;
% Read in demo image
originalImageX = imread('testimageg.jpg');
originalImage = rgb2gray(originalImageX);
subplot(3,2,1);
imshow(originalImage, []);
title('Original Image');

% Make a blob touch the border
originalImage(1:40, 100:140) = 0;
originalImage(180:230, 200:end) = 0;
subplot(3,2,2);
imshow(originalImage, []);
title('Image with border blobs');

thresholdValue = 150;
binaryImage = originalImage < thresholdValue;
subplot(3,2,3);
imshow(binaryImage, []);
title('Binarized Image');


labeledImage = bwlabel(binaryImage, 8);
subplot(3,2,4);
imshow(labeledImage, []);
title('Labeled Image');

blobMeasurements = regionprops(labeledImage, originalImage,
'EulerNumber', 'Centroid');
numberOfBlobs = size(blobMeasurements, 1);
for blobNumber = 1 : numberOfBlobs
    thisBlobsEulerNumber = int32(blobMeasurements
(blobNumber).EulerNumber); % Get list of pixels in current blob.
        numberOfHoles = int32(1 - thisBlobsEulerNumber);
        blobCentroid = blobMeasurements
(blobNumber).Centroid; % Get centroid.
        labelString = sprintf('Blob #%d', blobNumber);
        text(blobCentroid(1), blobCentroid(2), labelString, 'Color',
[1 .25 .10], 'FontSize', 14);
    fprintf(1,'Blob #%d Euler Number = %d, number of Holes = %d \n',
blobNumber, thisBlobsEulerNumber, numberOfHoles);
end

% Now get rid of the blobs that touch the border
noBorderBlobs = imclearborder(binaryImage);
subplot(3,2,5);
imshow(noBorderBlobs, []);
title('Border Blobs Removed');

% Now find the blobs that touched the border
borderBlobs = binaryImage - noBorderBlobs;
subplot(3,2,6);
imshow(borderBlobs, []);
title('Border Blobs Only');

% Relabel and measure ONLY the border blobs
labeledImageB = bwlabel(borderBlobs, 8);

blobMeasurementsB = regionprops(labeledImageB, originalImage, 'All');
numberOfBlobs = size(blobMeasurementsB, 1);

for blobNumber = 1 : numberOfBlobs
thisBlobsEulerNumber = int32(blobMeasurementsB
(blobNumber).EulerNumber); % Get list of pixels in current blob.
numberOfHoles = int32(1 - thisBlobsEulerNumber);
blobCentroid = blobMeasurementsB(blobNumber).Centroid; %
Get centroid.
labelString = sprintf('Blob #%d', blobNumber);
text(blobCentroid(1), blobCentroid(2), labelString, 'Color', [1 .25 .
10], 'FontSize', 14);
fprintf(1,'Border Blob #%d Euler Number = %d, number of Holes = %d
\n', blobNumber, thisBlobsEulerNumber, numberOfHoles);
end

set(gcf, 'Position', get(0, 'ScreenSize')); % Maximize figure.
uiwait(msgbox('Check out the command window'));

Subject: find Spots in the Image

From: Yi

Date: 24 Sep, 2009 01:30:22

Message: 18 of 19

HI ImageAnalyst:
Thank you so much!!!
All my problem are solved !!!
^_^


ImageAnalyst <imageanalyst@mailinator.com> wrote in message <9723e020-f741-435d-bca5-6cceb3e0814b@33g2000vbe.googlegroups.com>...
> On Sep 23, 7:07?am, "Yi " <heyinba0...@hotmail.com> wrote:
> > Hi ImageAnalyst:
> > I don't understand what is "original(input)" meaning?
> > original()---- is it a function?
> > thanks
>
> -------------------------------------------------------------------------
> Yi:
> You have an image where blobs touch the border.
> Let's call this the "original image." I just put it in parentheses to
> mean that I'm giving an alternate name for it.
> See http://en.wikipedia.org/wiki/Parenthesis_(rhetoric) for an
> explanation of a "parenthesis" in a rhetorical sentence: "An
> explanatory or qualifying word, clause, or sentence inserted into a
> passage with which it doesn't necessarily have any grammatical
> connection, and from which it is usually marked off by round or square
> brackets, dashes, or commas according to the Oxford English
> Dictionary."
>
> Now let's run that image though imclearborder() and get back an image
> with no border blobs in it.
> Let's call that image the "output image."
> outputImage = imclearborder(inputImage);
> Make sense? Now simply subtract them:
> borderBlobs = inputImage- outputImage;
>
> Here's some more demo code. Just copy, paste, fix lines broken by the
> newsreader, and run.
> Best wishes,
> ImageAnalyst
>
> clc;
> %clear all;
> close all;
> workspace;
> % Read in demo image
> originalImageX = imread('testimageg.jpg');
> originalImage = rgb2gray(originalImageX);
> subplot(3,2,1);
> imshow(originalImage, []);
> title('Original Image');
>
> % Make a blob touch the border
> originalImage(1:40, 100:140) = 0;
> originalImage(180:230, 200:end) = 0;
> subplot(3,2,2);
> imshow(originalImage, []);
> title('Image with border blobs');
>
> thresholdValue = 150;
> binaryImage = originalImage < thresholdValue;
> subplot(3,2,3);
> imshow(binaryImage, []);
> title('Binarized Image');
>
>
> labeledImage = bwlabel(binaryImage, 8);
> subplot(3,2,4);
> imshow(labeledImage, []);
> title('Labeled Image');
>
> blobMeasurements = regionprops(labeledImage, originalImage,
> 'EulerNumber', 'Centroid');
> numberOfBlobs = size(blobMeasurements, 1);
> for blobNumber = 1 : numberOfBlobs
> thisBlobsEulerNumber = int32(blobMeasurements
> (blobNumber).EulerNumber); % Get list of pixels in current blob.
> numberOfHoles = int32(1 - thisBlobsEulerNumber);
> blobCentroid = blobMeasurements
> (blobNumber).Centroid; % Get centroid.
> labelString = sprintf('Blob #%d', blobNumber);
> text(blobCentroid(1), blobCentroid(2), labelString, 'Color',
> [1 .25 .10], 'FontSize', 14);
> fprintf(1,'Blob #%d Euler Number = %d, number of Holes = %d \n',
> blobNumber, thisBlobsEulerNumber, numberOfHoles);
> end
>
> % Now get rid of the blobs that touch the border
> noBorderBlobs = imclearborder(binaryImage);
> subplot(3,2,5);
> imshow(noBorderBlobs, []);
> title('Border Blobs Removed');
>
> % Now find the blobs that touched the border
> borderBlobs = binaryImage - noBorderBlobs;
> subplot(3,2,6);
> imshow(borderBlobs, []);
> title('Border Blobs Only');
>
> % Relabel and measure ONLY the border blobs
> labeledImageB = bwlabel(borderBlobs, 8);
>
> blobMeasurementsB = regionprops(labeledImageB, originalImage, 'All');
> numberOfBlobs = size(blobMeasurementsB, 1);
>
> for blobNumber = 1 : numberOfBlobs
> thisBlobsEulerNumber = int32(blobMeasurementsB
> (blobNumber).EulerNumber); % Get list of pixels in current blob.
> numberOfHoles = int32(1 - thisBlobsEulerNumber);
> blobCentroid = blobMeasurementsB(blobNumber).Centroid; %
> Get centroid.
> labelString = sprintf('Blob #%d', blobNumber);
> text(blobCentroid(1), blobCentroid(2), labelString, 'Color', [1 .25 .
> 10], 'FontSize', 14);
> fprintf(1,'Border Blob #%d Euler Number = %d, number of Holes = %d
> \n', blobNumber, thisBlobsEulerNumber, numberOfHoles);
> end
>
> set(gcf, 'Position', get(0, 'ScreenSize')); % Maximize figure.
> uiwait(msgbox('Check out the command window'));

Subject: find Spots in the Image

From: Krysta

Date: 5 Aug, 2011 13:13:28

Message: 19 of 19

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <188a88d3-4aae-41d8-80bb-1dc1a3394ec8@d4g2000vbm.googlegroups.com>...
> On Sep 22, 7:14 pm, "Yi " <heyinba0...@hotmail.com> wrote:
> > hi ImageAnalyst
> > i have read your tutorial. this is the code what i learn from your tutorial:
> >
> > % Read in standard MATLAB demo image
> > originalImageX = imread('testImage.JPG');
> > originalImage = rgb2gray(originalImageX);
> > thresholdValue = 1;
> > binaryImage = originalImage < thresholdValue;
> > binaryImage = imfill(binaryImage, 'holes');
> > labeledImage = bwlabel(binaryImage, 8);
> > blobMeasurements = regionprops(labeledImage, originalImage, 'EulerNumber');  
> > numberOfBlobs = size(blobMeasurements, 1);
> >
> > after i run this function
> > i got numberOfBlobs = 49 and each of them has a EulerNumber which equal to "1"
> > so i really can not understand the meaning of this result.
> > could you help me and give me some ideas?
> >
> > thanks so much
> >
> --------------------------------------------------------------------------------
> Try this:
>
> workspace;
> % Read in demo image
> originalImageX = imread('testimageg.jpg');
> originalImage = rgb2gray(originalImageX);
> subplot(3,1,1);
> imshow(originalImage, []);
> title('Original Image');
>
> thresholdValue = 150;
> binaryImage = originalImage < thresholdValue;
> subplot(3,1,2);
> imshow(binaryImage, []);
> title('Binarized Image');
>
> labeledImage = bwlabel(binaryImage, 8);
> subplot(3,1,3);
> imshow(labeledImage, []);
> title('Labeled Image');
>
> blobMeasurements = regionprops(labeledImage, originalImage,
> 'EulerNumber', 'Centroid');
> numberOfBlobs = size(blobMeasurements, 1);
> for blobNumber = 1 : numberOfBlobs
> thisBlobsEulerNumber = int32(blobMeasurements
> (blobNumber).EulerNumber); % Get list of pixels in current blob.
> numberOfHoles = int32(1 - thisBlobsEulerNumber);
> blobCentroid = blobMeasurements(blobNumber).Centroid; % Get
> centroid.
> labelString = sprintf('Blob #%d', blobNumber);
> text(blobCentroid(1), blobCentroid(2), labelString, 'Color', [1 .25 .
> 10], 'FontSize', 14);
> fprintf(1,'Blob #%d Euler Number = %d, number of Holes = %d \n',
> blobNumber, thisBlobsEulerNumber, numberOfHoles);
> end
> set(gcf, 'Position', get(0, 'ScreenSize')); % Maximize figure.
> uiwait(msgbox('Check out the command window'));



I am attempting to find spots in an image in version 2008, and when I use the above code I get:

??? Undefined function or method
'imageDisplayParseInputs' for input arguments of
type 'uint8'.

Error in ==> imshow at 144
  [cdata, cdatamapping, clim, map, xdata, ydata, ...

Is there a way to modify the .jpg I'm using to make this work properly?

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
centroid sanjay 1 Mar, 2010 14:05:11
eulernumber Image Analyst 22 Sep, 2009 06:44:24
matlab image pr... Yi 20 Sep, 2009 23:04:02
rssFeed for this Thread

Contact us at files@mathworks.com