Automatic calculation of low and high thresholds for the Canny operation in opencv

后端 未结 7 898
孤独总比滥情好
孤独总比滥情好 2020-11-28 03:15

In openCV, the low and high thresholds for the canny operator are mandatory:

cvCanny(input,output,thresh1,thresh2)

In Matlab, there\'s an o

7条回答
  •  春和景丽
    2020-11-28 03:37

    As Luca Del Tongo has suggested, you can calculate the thresholds from the grey image, e.g. in Java using OpenCV...

    MatOfDouble mu = new MatOfDouble();
    MatOfDouble stddev = new MatOfDouble();
    Core.meanStdDev(greyMat, mu, stddev);
    threshold1 = mu.get(0, 0)[0];
    threshold2 = stddev.get(0, 0)[0];
    Imgproc.Canny(greyMat, outputMat, threshold1, threshold2);
    

提交回复
热议问题