Hi all,
I have a fixed foci in an image in Matlab, and I am wondering how to draw a ellipses with this known foci and get the pixels within the ellipses, and finally group these pixels into several sets according to their different distances to one foci point?
Thanks.

 Réponse acceptée

Image Analyst
Image Analyst le 12 Nov 2014
Joy, you can use the FAQ http://matlab.wikia.com/wiki/FAQ#How_do_I_create_an_ellipse.3F to get x and y coordinates, or use Joseph's code - either way. Then, to write into an image, you can just run through your x,y list:
for k = 1 : length(y);
row = round(y);
column = round(x);
binaryImage(row, column) = true;
end

5 commentaires

Image Analyst
Image Analyst le 12 Nov 2014
Or you can just use imellipse like in the attached example.
Ramesh Bala
Ramesh Bala le 7 Août 2018
But the question is, he has just 2 focus and no major, minor length nor radii? So how is the burn_overlay_into_image.m (above) gonna be useful here?
Image Analyst
Image Analyst le 7 Août 2018
I presume there are formulas in geometry that will give you the major and minor axis lengths given the foci.
Ramesh Bala
Ramesh Bala le 8 Août 2018
Thanks, I found this imellipse(gca,[10 10 50 150]) which literally needs xlim and ylim and not the focus values.
I believe with only foci values an ellipse can't be drawn.
Image Analyst
Image Analyst le 8 Août 2018
It does not need xlim and ylim. It needs the width and height of the ellipse - those are different things. I'm sure a web search will provide the formula, which will involve another parameter. As you know, just having the foci doesn't define the ellipse. Remember the analogy of putting a string loop around the foci and drawing the ellipse with your pen? Well if the string is different lengths, you will get different size ellipses, right? So foci are not enough.

Connectez-vous pour commenter.

Plus de réponses (1)

Joseph Cheng
Joseph Cheng le 12 Nov 2014
To start your question you can do something like this where you setup your knowns. Here i don't know anything about your image so here i use one of the built in demo images where i say i know where i want my foci to be and then offset the plotted ellipse.
P = imread('bag.png');
imagesc(P),colormap gray,hold on;
axis equal
axis tight
%%location of foci
% foci to "center" ellipse onto
fociposxy = [123 165];
% ellipse parameters
a = 36;
b = 27;
%find the foci
foci = sqrt(a^2-b^2);
foci = [-foci foci];
%define ellipse
theta = 0:.1:2*pi;
x=a*sin(theta)+fociposxy(1)-foci(2);
y=b*cos(theta)+fociposxy(2);
plot(x,y,'r')
to find the pixels inside of the ellipse you can use the ellipse equation (x-offset)^2/a^2+(y-offset)^2/b^2<=1. where you would insert the x,y location of all the pixels and see if the equation hold true. Dunno what you mean by grouping by distance? are you looking for a bullseye coloring or actual grouping like region props does?

3 commentaires

Joy
Joy le 12 Nov 2014
I tried your code, and it did help me draw an ellipse, but what I want here is to draw the ellipse on my binary image(matrix). Do you know how to achieve that?
Thanks!
Joseph Cheng
Joseph Cheng le 12 Nov 2014
sooo... you would swap out my image. since i do not have yours. and my ellipsis parameters for yours.
Joy
Joy le 23 Nov 2014
Thank you. I will try.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Read, Write, and Modify Image dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by