Fit Ellipse to structure in image

5 vues (au cours des 30 derniers jours)
Vivek
Vivek le 27 Mar 2025
I have an image and a reference with many structures similar to below and I want to fit an ellipse on each strcuture such as the one below (in a single image). Once I have a ellipese on all of them , I want to use the ellipse on the difference image (image - reference) and do some computations. How can this segmentation be done in matlab.
Below is a sample image taken from

Réponses (2)

Matt J
Matt J le 27 Mar 2025
Modifié(e) : Matt J le 28 Mar 2025
I recommend downloading this,
IM=im2gray(imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1830257/image.png'));
BW=imbinarize(IM);
B=bwboundaries(BW,CoordinateOrder="xy");
fitobj=ellipticalFit(B{1}')
fitobj =
ellipticalFit with properties: center: [143.6913 104.6159] a: 58.7019 b: 49.6830 angle: 65.6680
imshow(IM);hold on
plot(fitobj); hold off
  1 commentaire
Matt J
Matt J le 28 Mar 2025
Modifié(e) : Matt J le 28 Mar 2025
If you want to exclude the small protrusions from the main lobe from the fit, you can also download,
IM=im2gray(imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1830257/image.png'));
BW=~bwlalphaclose(~imbinarize(IM),15);
B=bwboundaries(BW,CoordinateOrder="xy");
fitobj=ellipticalFit(B{1}')
fitobj =
ellipticalFit with properties: center: [146.5065 106.9114] a: 55.9204 b: 46.0753 angle: -85.1879
imshow(IM);hold on
plot(fitobj); hold off

Connectez-vous pour commenter.


Image Analyst
Image Analyst le 28 Mar 2025
See the FAQ:
or see the attached function. You can get the (x,y) coordinates, once you have segmented the gray scale image into a binary image like this:
boundaries = bwboundaries(mask, CoordinateOrder="xy");
%visboundaries(boundaries); % Optional, if you'd like to see them overlaid on the image.
xy = boundaries{1};

Community Treasure Hunt

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

Start Hunting!

Translated by