Optimisation de la transformé de Hough pour un cercle
Bonjour,
Voila j'ai codé ma transformé de Hough pour les cercles cependant elle est très longue. Pour une image 1280x1024, il me faut 1h pour l'analyser...
Ce qui est long, c'est le remplissage de l'accumulateur car j'ai une quadruple boucle for :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| for (int i = 0; i < width; ++i)
{
monTest.getMaBarre().setValue ( i * height * (rayonMax-rayonMin) * 90 );
for (int j = 0; j < height; ++j)
{
for (int k = rayonMin; k <= rayonMax; ++k)
{
for (int theta = 0 ; theta < 360 ; theta += (2*Math.PI*k < 60)?2:4)
{
t = (theta * Math.PI) / 180;
x0 = (int)Math.round(i - k * Math.cos(t));
y0 = (int)Math.round(j - k * Math.sin(t));
// System.out.println("Theta : " + theta);
// System.out.println("x0 : " + x0);
// System.out.println("y0 : " + y0);
if(x0 < width && x0 > 0 && y0 < height && y0 > 0)
{
code = Code_Color(-img.getRGB(x0, y0));
// System.out.println("Calcul : " + (code [0] + code [1] + code [2]) / 3);
if ((code [0] + code [1] + code [2]) / 3 > 150)
{
++ accu[i][j][k];
}
}
}
}
}
} |
J'aimerai savoir si vous avez un moyen d'optimiser ce traitement notamment en séparer ces 4 for en 2 + 2 ou un truc du genre.
Merci d'avance.