what is the dot used for in matlab

  • Follow


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:













7/28/2012 6:29:26 AM


Reply: