MATLAB Answers

how to calculate the major and minor axis of an ellipse in contour plot

24 views (last 30 days)
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.

Accepted Answer

Image Analyst
Image Analyst on 14 Nov 2013
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.

More Answers (2)

Mohammad Bhat
Mohammad Bhat on 11 Feb 2018
How can I pass ellipse as an object to regionprops
Image Analyst
Image Analyst on 6 Jan 2020
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;

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!