フィルターのクリア

How to find the X axis length and Yaxis length of the object

6 ビュー (過去 30 日間)
saravanakumar D
saravanakumar D 2013 年 12 月 27 日
コメント済み: Image Analyst 2013 年 12 月 30 日
I have to find the shape of the object so i have to find the length of the x and y axis length of the shape. So please help me

採用された回答

Sean de Wolski
Sean de Wolski 2013 年 12 月 27 日
doc regionprops
  4 件のコメント
saravanakumar D
saravanakumar D 2013 年 12 月 27 日
But i think there is major difference between X&Y axis length and Major&Minor axis length
Sean de Wolski
Sean de Wolski 2013 年 12 月 27 日
Then use 'Orientation' property to convert between the direction of the ellipse and x/y.

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2013 年 12 月 27 日
You could use bounding box, or MajorAxisLength and MinorAxisLength, which is the axes of an ellipse fitted to the blob. There is no farthest end-to-end measurement available. And there is no definitive crossways width. If you had an elongated, irregularly-shaped blob and the major axis was where you think it would be, then what is the minor axis? The narrowest one? The cross distance at the midpoint (which may be at the widest point, the narrowest point, or something else)?
  11 件のコメント
Sean de Wolski
Sean de Wolski 2013 年 12 月 30 日
Either way, you could just replace the nan's with zeros.
D(isnan(D)) = 0;
Image Analyst
Image Analyst 2013 年 12 月 30 日
Sorry Sean, I found the problem. I had a file called rice.png that was a binary mask file in a folder (that I had created for a project I was working on) and that was earlier on the path. It used that instead. That's the danger of not specifying the full path. It's not your fault - how could you know that I'd just happen to have a different image called that? - but I'm showing the more robust code below:
% Define folder where rice.png lives.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'rice.png';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
I = imread(fullFileName);
imshow(I);
rice = imclearborder(stdfilt(I)<15);
skel = bwmorph(rice,'skel',inf);
endpoints = bwmorph(skel,'endpoints');
L = bwlabel(rice);
L(~endpoints) = 0;
for ii = 2:max(L(:))
idx = find(L == ii);
endpoints(idx(2:end)) = 0; %keep only one end point per object
end
D = bwdistgeodesic(rice,endpoints,'quasi-euclidean');
imshow(D,[]);
colormap(jet);

サインインしてコメントする。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by