1

--------------以下の編集を読む---------------さまざまな画像内の瞳孔と虹彩のエッジを検出しようとしています。パラメータなどを変更していますが、虹彩/瞳孔のアウトラインを 1 つだけ正しく取得するか、バックグラウンドで不要なアウトラインを取得するか、またはまったく取得できません。正しいアウトラインを取得するために試してみる必要があるいくつかの特定のパラメーターです。または、システムがその部分に焦点を合わせることができるように、画像を目だけにトリミングする方法はありますか?

これは私のUPDATEDメソッドです:

private void findPupilIris() throws IOException {
    //converts and saves image in grayscale

    Mat newimg = Imgcodecs.imread("/Users/.../pic.jpg");
    Mat des = new Mat(newimg.rows(), newimg.cols(), newimg.type());
    Mat norm = new Mat();

    Imgproc.cvtColor(newimg, des, Imgproc.COLOR_BGR2HSV);
    List<Mat> hsv = new ArrayList<Mat>();
    Core.split(des, hsv);
    Mat v = hsv.get(2); //gets the grey scale version

    Imgcodecs.imwrite("/Users/Lisa-Maria/Documents/CapturedImages/B&Wpic.jpg", v); //only writes mats

    CLAHE clahe = Imgproc.createCLAHE(2.0, new Size(8,8) ); //2.0, new Size(8,8) 
    clahe.apply(v,v);
//    Imgproc.GaussianBlur(v, v, new Size(9,9), 3); //adds left pupil boundary and random circle on 'a'
 //   Imgproc.GaussianBlur(v, v, new Size(9,9), 13); //adds right outer iris boundary and random circle on 'a'
    Imgproc.GaussianBlur(v, v, new Size(9,9), 7);  //adds left outer iris boundary and random circle on left by hair
  //  Imgproc.GaussianBlur(v, v, new Size(7,7), 15);
    Core.addWeighted(v, 1.5, v, -0.5, 0, v);


    Imgcodecs.imwrite("/Users/.../after.jpg", v); //only writes mats
    if (v != null) {
        Mat circles = new Mat();

        Imgproc.HoughCircles( v, circles, Imgproc.CV_HOUGH_GRADIENT, 2, v.rows(), 100, 20, 20, 200 );

        List<MatOfPoint> contours = new ArrayList<MatOfPoint>();

        System.out.println("circles.cols() " + circles.cols());
        if(circles.cols() > 0) {
            System.out.println("1");
            for (int x = 0; x < circles.cols(); x++) {
                System.out.println("2");
                double vCircle[] = circles.get(0, x);


                if(vCircle == null) {
                    break;
                }

                Point pt = new Point(Math.round(vCircle[0]), Math.round(vCircle[1]));
                int radius = (int) Math.round(vCircle[2]);

                //draw the found circle




                Imgproc.circle(v, pt, radius, new Scalar(255,0,0),2); //newimg
                //Imgproc.circle(des, pt, radius/3, new Scalar(225,0,0),2); //pupil
                Imgcodecs.imwrite("/Users/.../Houghpic.jpg", v); //newimg

                //draw the mask: white circle on black background
//                  Mat mask = new Mat( new Size( des.cols(), des.rows() ), CvType.CV_8UC1 );
//                  Imgproc.circle(mask, pt, radius, new Scalar(255,0,0),2); 

//                  des.copyTo(des,mask);
//                  Imgcodecs.imwrite("/Users/..../mask.jpg", des); //newimg


                Imgproc.logPolar(des, norm, pt, radius, Imgproc.WARP_FILL_OUTLIERS);
                Imgcodecs.imwrite("/Users/..../Normalised.jpg",norm);
            }
        }
    }
}

結果:ハフ pic

4

1 に答える 1