I am fairly new to matlab and i saw a program on internet. it was regarding finding the centroid of an image. I have pasted it bellow. My question is that what is the line "disp(features.Centroid)". what is the period in between the features and centroid mean? when should it be used?
% read the image
i = imread('ball.bmp');
% convert to double
i = double(i);
% invert the image so that we can label the image
% the invert function is not given in the DIP toolbox
% i am attaching it with this email
i = invert(i);
% apply 8-connected algo
[labels,count] = bwlabel(i,8);
% calculate features. For more type help imfeature
features = imfeature(labels,'Centroid');
i = 1;
while i <= count
% display centroid of all the subimages in the image
disp(features.Centroid);
i = i + 1;
end
|
|
0
|
|
|
|
Reply
|
Hamed
|
11/12/2010 1:45:41 AM |
|
imfeature is the really old name of regionprops(). regionprops
returns a structure with all the various measurements as members of
that structure. For example, from my image processing demo at
http://www.mathworks.com/matlabcentral/fileexchange/25157
% Get all the blob properties. Can only pass in originalImage in
version R2008a and later.
blobMeasurements = regionprops(labeledImage, originalImage, 'all');
% Print header line in the command window.
fprintf(1,'Blob # Mean Intensity Area Perimeter
Centroid Diameter\n');
% Loop over all blobs printing their measurements to the command
window.
for k = 1 : numberOfBlobs % Loop through all blobs.
% Find the mean of each blob. (R2008a has a better way where you can
pass the original image
% directly into regionprops. The way below works for all versions
including earlier versions.)
thisBlobsPixels = blobMeasurements(k).PixelIdxList; % Get list of
pixels in current blob.
meanGL = mean(originalImage(thisBlobsPixels)); % Find mean
intensity (in original image!)
meanGL2008a = blobMeasurements(k).MeanIntensity; % Mean again, but
only for version >= R2008a
blobArea = blobMeasurements(k).Area; % Get area.
blobPerimeter = blobMeasurements(k).Perimeter; % Get perimeter.
blobCentroid = blobMeasurements(k).Centroid; % Get centroid.
blobECD(k) = sqrt(4 * blobArea / pi); % Compute ECD - Equivalent
Circular Diameter.
fprintf(1,'#%2d %17.1f %11.1f %8.1f %8.1f %8.1f % 8.1f\n', k,
meanGL, blobArea, blobPerimeter, blobCentroid, blobECD(k));
% Put the "blob number" labels on the "boundaries" grayscale image.
text(blobCentroid(1) + labelShiftX, blobCentroid(2), num2str(k),
'FontSize', fontSize, 'FontWeight', 'Bold');
end
See blobMeasurements? It has lots of measurements, such as Area,
Centroid, Perimeter, etc. But they're all collected under one
variable called blobMeasurements, which is a structure.
To get to the individual measurements in blobMeasurements, you use the
"dot" to separate the structure name from it's member name, just as in
every other programming language out there.
By the way, bwlabel is supposed to take a cinary (logical) image, not
some inverted double image. And invert is not a function in the Image
Processing Toolbox or base MATLAB (at least not anymore if it ever
was), at least it doesn't show up in my help.
|
|
0
|
|
|
|
Reply
|
ImageAnalyst
|
11/12/2010 1:58:03 AM
|
|
i truly can not thank you enough.
Thanks
ImageAnalyst <imageanalyst@mailinator.com> wrote in message <d8610599-7b9c-45cd-a48d-f441323a9fc1@g4g2000prj.googlegroups.com>...
> imfeature is the really old name of regionprops(). regionprops
> returns a structure with all the various measurements as members of
> that structure. For example, from my image processing demo at
> http://www.mathworks.com/matlabcentral/fileexchange/25157
>
> % Get all the blob properties. Can only pass in originalImage in
> version R2008a and later.
> blobMeasurements = regionprops(labeledImage, originalImage, 'all');
>
> % Print header line in the command window.
> fprintf(1,'Blob # Mean Intensity Area Perimeter
> Centroid Diameter\n');
> % Loop over all blobs printing their measurements to the command
> window.
> for k = 1 : numberOfBlobs % Loop through all blobs.
> % Find the mean of each blob. (R2008a has a better way where you can
> pass the original image
> % directly into regionprops. The way below works for all versions
> including earlier versions.)
> thisBlobsPixels = blobMeasurements(k).PixelIdxList; % Get list of
> pixels in current blob.
> meanGL = mean(originalImage(thisBlobsPixels)); % Find mean
> intensity (in original image!)
> meanGL2008a = blobMeasurements(k).MeanIntensity; % Mean again, but
> only for version >= R2008a
>
> blobArea = blobMeasurements(k).Area; % Get area.
> blobPerimeter = blobMeasurements(k).Perimeter; % Get perimeter.
> blobCentroid = blobMeasurements(k).Centroid; % Get centroid.
> blobECD(k) = sqrt(4 * blobArea / pi); % Compute ECD - Equivalent
> Circular Diameter.
> fprintf(1,'#%2d %17.1f %11.1f %8.1f %8.1f %8.1f % 8.1f\n', k,
> meanGL, blobArea, blobPerimeter, blobCentroid, blobECD(k));
> % Put the "blob number" labels on the "boundaries" grayscale image.
> text(blobCentroid(1) + labelShiftX, blobCentroid(2), num2str(k),
> 'FontSize', fontSize, 'FontWeight', 'Bold');
> end
>
>
> See blobMeasurements? It has lots of measurements, such as Area,
> Centroid, Perimeter, etc. But they're all collected under one
> variable called blobMeasurements, which is a structure.
>
> To get to the individual measurements in blobMeasurements, you use the
> "dot" to separate the structure name from it's member name, just as in
> every other programming language out there.
>
> By the way, bwlabel is supposed to take a cinary (logical) image, not
> some inverted double image. And invert is not a function in the Image
> Processing Toolbox or base MATLAB (at least not anymore if it ever
> was), at least it doesn't show up in my help.
|
|
0
|
|
|
|
Reply
|
Hamed
|
11/12/2010 3:08:03 AM
|
|
|
2 Replies
185 Views
(page loaded in 0.107 seconds)
Similiar Articles: Distance calculation in sphere - comp.soft-sys.matlabd = 8*atan2(norm(cross(P1,P2)),dot(P1,P2)); Roger Stafford ... Distance calculation in sphere - comp.soft-sys.matlab I have used the following code to ... agent-based modelling with Matlab - comp.soft-sys.matlab ...Can you please send me your contact details > at das dot santanu at gmail dot ... The images are sent from VB and Matlab is used ... A Multi Agent Approach for Texture ... Plot points on map as varying size dots or circles. - comp.soft ...Hello, I know this function exists in matlab but i can't locate it's name. ... I want display the values in the form of different size dots with a small dot = 1 ... factor analysis: rotated axes angle - comp.soft-sys.matlab ...The dot product of two vectors is equal to the lengths times the cos of ... soft-sys.matlab factor analysis: rotated axes angle - comp.soft-sys.matlab ... Hi, I have used ... Re: fast angle calculation between 2D vectors - comp.soft-sys ...This function calculates angels between to groups of vectors function angle=Angle(vects1, vects2)%Unit vectors beam_dot=sum(vects1'.*vec... Plot "smaller" dot - comp.soft-sys.matlabPlot "smaller" dot - comp.soft-sys.matlab Export graph from a GUI is not working - comp.soft-sys.matlab ... Plot "smaller" dot - comp.soft-sys.matlab Export graph from a ... How to save figure image as .png - comp.soft-sys.matlab... from image and show the denoised image, I have used ... image is almost blank, a white background with few dot ... How to save figure image as .png - comp.soft-sys.matlab ... symbolic variables - comp.soft-sys.matlabi would like to know what is the use of the symbolic variables and where they are used....can anyone clarfy my doubt pls... ... How can I rename a structure name inside a loop? - comp.soft-sys ...Is there a function in MATLAB for this purpose? I tried saving the new structures ... -- Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link ... QPSK BER modulation - comp.soft-sys.matlabI wrote a mfile that it simulates the qpsk modulation in an AWGN channel, but after 6dB SNR its probability of error is equal to "0", I used matlab f... what is the dot used for in matlab - Newsreader - MATLAB CentralFile exchange, MATLAB Answers, newsgroup access, Links, and Blogs for the MATLAB & Simulink user community Matlab Frequently Asked Questions! - The University of UtahWhat has happened is Matlab tried to do MATRIX MULTIPLICATION. Not element by element array multiplication. So we should us the DOT '.' operator. 7/28/2012 6:29:26 AM
|