Kreiserkennung verbessern

Ich versuche, Kreise in meinen Bildern zu erkennen. Ich habe den folgenden Code in C # mit EmguCV geschrieben. Meistens funktioniert es, aber in einigen Fällen werden kleinere oder größere Kreise erkannt, die leicht zur Seite verschoben sind.

Hier ist mein Code:

        Thread.Sleep(1000);
        imgCrp.Save(DateTime.Now.ToString("yyMMddHHmmss") + ".jpg");

        imgCrpLab = imgCrp.Convert<Lab, Byte>();
        imgIsolatedCathNTipBW = new Image<Gray, Byte>(imgCrp.Size);
        CvInvoke.cvInRangeS(imgCrpLab.Split()[2], new MCvScalar(0), new MCvScalar(100), imgIsolatedCathNTipBW);

        imgCrpNoBgrnd = imgCrp.Copy(imgIsolatedCathNTipBW.Not());
        imgCrpNoBgrndGray = imgCrpNoBgrnd.Convert<Gray, Byte>().PyrUp().PyrDown();
        Thread.Sleep(1000);
        imgCrpNoBgrndGray.Save(DateTime.Now.ToString("yyMMddHHmmss") + ".jpg");

        Gray cannyThreshold = new Gray(150);
        Gray cannyThresholdLinking = new Gray(85);
        Gray circleAccumulatorThreshold = new Gray(15);

        imgCrpNoBgrndGrayCanny = imgCrpNoBgrndGray.Canny(cannyThreshold.Intensity, cannyThresholdLinking.Intensity);
        Thread.Sleep(1000);
        imgCrpNoBgrndGrayCanny.Save(DateTime.Now.ToString("yyMMddHHmmss") + ".jpg");

        circarrTip = imgCrpNoBgrndGrayCanny.HoughCircles(
            cannyThreshold,
            circleAccumulatorThreshold,
            1, //Resolution of the accumulator used to detect centers of the circles
            500, //min distance 
            15, //min radius
            42 //max radius
            )[0]; //Get the circles from the first channel

        imgCathNoTip = imgIsolatedCathNTipBW.Copy().Not();
        foreach (CircleF circle in circarrTip)
        {
            circLarger2RemTip = circle;
            circLarger2RemTip.Radius = circle.Radius;
            imgCathNoTip.Draw(circLarger2RemTip, new Gray(140), 1); // -1 IS TO FILL THE CIRCLE
        }
        Thread.Sleep(1000);
        imgCathNoTip.Save(DateTime.Now.ToString("yyMMddHHmmss") + ".jpg");

it @Sleep-Befehlen soll nur sichergestellt werden, dass die Dateinamen unterschiedlich sind und später entfernt werden. Ich habe auch die Bilder angehängt, die durch diesen Code während des Vorgangs gespeichert wurden. Das letzte Bild zeigt den erkannten Kreis, der größer und ebenfalls nach rechts verschoben ist.

ann jemand freundlich meinen Code überprüfen und mich wissen lassen, wie ich ihn verbessern kann, um Kreise genauer zu erkenne

Danke im Voraus

Antworten auf die Frage(2)

Ihre Antwort auf die Frage