how to calculate the major and minor axis of an ellipse in contour plot
5 次查看(过去 30 天)
显示 更早的评论
I have a contour plot which is more of a ellipse.I would like to know its major and minor axis...a and b respectively.How do i go about.I am naive user please guide me.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/153012/image.png)
0 个评论
采纳的回答
Image Analyst
2013-11-14
You need the Image Processing Toolbox. Type ver to see if you have it.
It looks like an indexed image with a jet colormap being applied. Get one "ring" by thresholding
binaryImage = grayImage == theValue; % Different rings will have different intensity values.
% Now get the ellipse parameters with regionprops.
measurements = regionprops(binaryImage, 'MajorAxisLength', 'MinorAxisLength', 'Orientation');
majorAxisLength = measurements.MajorAxisLength;
minorAxisLength = measurements.MinorAxisLength;
% Repeat for other rings.
更多回答(2 个)
Mohammad Bhat
2018-2-11
How can I pass ellipse as an object to regionprops
3 个评论
Rahul Verma
2020-1-6
I am having a similar contour image which I converted to grayscale as attached...
a=imread('test1.png');
grayImage = rgb2gray(a);
![grayscale.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259950/grayscale.png)
measurements = regionprops(binaryImage, 'MajorAxisLength', 'MinorAxisLength', 'Orientation');
However, on calling regionprops, I get an empty matrix
0×1 empty struct array with fields:
MajorAxisLength
MinorAxisLength
Orientation
As a result, I cannot get the major and minor axis lengths...
Any suggestions :)![test1.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259951/test1.png)
![test1.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/259951/test1.png)
Image Analyst
2020-1-6
You probably don't have anything that is EXACTLY 0.4. Try
binaryImage = grayImage >= 0.40;
Do it again for a different value and AND the images if you just want the ring.
binaryImage = grayImage >= 0.40 & grayImage <= someOtherValue;
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Red 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!