Path: news.mathworks.com!not-for-mail
From: "Ashish Uthama" <first.last@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: damage measurement in a micrograph
Date: Tue, 03 Nov 2009 16:36:36 -0500
Organization: TMW
Lines: 42
Message-ID: <op.u2t8zakya5ziv5@uthamaa.dhcp.mathworks.com>
References: <hcadg1$3m1$1@fred.mathworks.com>
 <op.u2kwubcja5ziv5@uthamaa.dhcp.mathworks.com>
 <79aec1bd-0d70-4fbb-bf15-5c8274ab70dc@j24g2000yqa.googlegroups.com>
 <hcq35r$d3f$1@fred.mathworks.com>
NNTP-Posting-Host: uthamaa.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257284196 1223 172.31.57.126 (3 Nov 2009 21:36:36 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 3 Nov 2009 21:36:36 +0000 (UTC)
User-Agent: Opera Mail/10.01 (Win32)
Xref: news.mathworks.com comp.soft-sys.matlab:582180


On Tue, 03 Nov 2009 15:18:04 -0500, Krishna Chaitanya  
<chaitanya.alur@gmail.com> wrote:

> Can some one help me out in finding the centroid of each grain in the  
> figure below..
>
> http://www.flickr.com/photos/30274557@N05/4056558292/..

I hope you studied the previous example I posted. Going through the help  
for the functions used might give you some better ideas to implement on  
your own.


in=imread('in.jpg');

%intensity image
hsv=rgb2hsv(in);
v=hsv(:,:,3);
%imtool(v); %Used to objectively seletc the threshold

%threshold
v_bw=v>.6;
%imshow(v_bw);

%remove lines by closing
v_close=imclose(v_bw,strel('disk',2));
%imshow(v_close);

[v_labeled numLabels]= bwlabel(~v_close,4);

imtool(v_labeled); %place your cursor on the largest blob, note the label  
value (the intensity value)


%look up doc - this would give you the area of individual blobs. You could  
threshold the 'size' of the blobs if you wish..
stats=regionprops(v_labeled,'Area','Centroid')

%plot([stats.Area]); %You could use the area criterion to filter out the  
smaller potential false positives.

stats(58) %The label value of the largest blob