I'm implementing an ellipse detector using some pdf I found on the internet, but I encounter some difficulties in understanding one of the equations.
Here is the pdf: http://hci.iwr.uni-heidelberg.de/publications/dip/2002/ICPR2002/DATA/07_3_20.PDF
The equations I'm not being able to understand are numbers $5$ and $6$ on the second page, especially number $6$ where i can't figure out how $f$ is calculated.
This is what I've done for now, using C++ with Qt:
for(int i = 0; i < edgePixels.size(); ++i){
for(int j = 0; j < edgePixels.size(); ++j){
majorAxeLength = sqrt(pow((edgePixels.at(j).x() - edgePixels.at(i).x()), 2) + pow((edgePixels.at(j).y() - edgePixels.at(i).y()), 2));
if(majorAxeLength >= 148.9)
{
qDebug() << " Aux points : " << edgePixels.at(i) << " , " << edgePixels.at(j) << " L'axe majeur = " << majorAxeLength;
majorAxeHalfLength = majorAxeLength / 2;
centerX = edgePixels.at(i).x() + edgePixels.at(j).x() / 2.0;
centerY = edgePixels.at(i).y() + edgePixels.at(j).y() / 2.0;
ellipseOrientation = atan(((edgePixels.at(j).y() - edgePixels.at(i).y()) / (edgePixels.at(j).x() - edgePixels.at(i).x())));
for (int k = 0; k < edgePixels.size(); ++k) {
centerToPointDistance = sqrt(pow((edgePixels.at(k).x() - centerX), 2) + pow((edgePixels.at(k).y() - centerY), 2));
if(centerToPointDistance >= 50)
{
qDebug() << " Aux points : " << centerX << " , " << centerY << " , " << edgePixels.at(k) << " L'axe majeur = " << centerToPointDistance;
}
}
}
}
}
Hope you can help me ! Thank you in advance !
I found the equations a bit hard to understand. However, I can tell you how to find the other axis of an ellipse if you know one axis and one more point on the ellipse.
An ellipse is obtained by stretching or expanding a circle along two perpendicular directions. Consider two perpendiculars trough the center of a circle. The distances from a point on the circle to these axes satisfy $x^2 + y^2 = r^2$ or $\frac{x^2}{r^2}+ \frac{x^2} {r^2} =1$. Contract the circle along one of the axes and get an ellipse. The $r$ becomes $a$, $b$, the semiaxes. The ratios $\frac{x}{a}$, $\frac{y}{b}$ are like the ones for the circle. Therefore $$\frac{x^2}{a^2} + \frac{y^2}{b^2}=1$$
This allows you to find $b$ if you know $a$ and $(x,y)$.
The picture below illustrates why we have the equality $\frac{x^2}{a^2} + \frac{y^2}{b^2}=1$
We took a circle of radius $10$ and a point on it with distances to two perpedicular diameters $x=8$, $y=6$. Contracting along the vertical direction by a factor $1/2$ produces an ellipse with semi-axes $a=10$ and $b=5$. The corresponding point has distances to the axes $x=8$ and $y=3$. We have again $\frac{8^2}{10^2} + \frac{3^2}{5^2}=1$.