Contour using Otsu Method giving different Threshold value each time

asked 2013-04-13 12:25:02 -0500

andern gravatar image

updated 2013-04-15 11:39:13 -0500

I am trying to get the Otsu Method to get the threshold value and then use findContour to get all of the clumping circles in the image. The problem is that when i run through my code it would get different threshold value each time. Any advice would be good i am still new to openCV. Do you think that circle clumping in the image would be best detected number and size by using findContour or a different method. I am working on android purely in java.

    mConCopy.convertTo(mConCopy,CvType.CV_8UC1);
    thresh=Imgproc.threshold( mConCopy, mContour, -1, 255, Imgproc.THRESH_BINARY+Imgproc.THRESH_OTSU);
    List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
    Mat mIntermediateMat = new Mat();
    Imgproc.Canny(mContour, mIntermediateMat, thresh*0.4, thresh);
    Imgproc.findContours(mIntermediateMat, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_NONE);
    int countCon = contours.size();
    for(int k=0; k<countCon; k++)
    {
    contourSize.add((int)Imgproc.contourArea(contours.get(k)));
    }

Sorry i did not say this but this is not a live feed and is just checking one image and each time it checks the same image it gets a different threshold

edit retag flag offensive close merge delete