欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

opencv 图像直方图匹配

程序员文章站 2022-04-01 07:56:09
...
  Mat img1 = Imgcodecs.imread("/sdcard/c.jpg");
        Mat img2 = Imgcodecs.imread("/sdcard/d.jpg");

        Mat hist0 = new Mat();
        Mat hist1 = new Mat();
        MatOfFloat ranges = new MatOfFloat(0f, 256f);

        MatOfInt histSize = new MatOfInt(25);

        Imgproc.calcHist(Arrays.asList(img1), new MatOfInt(0), new Mat(), hist0, histSize, ranges);
        Imgproc.calcHist(Arrays.asList(img2), new MatOfInt(0), new Mat(), hist1, histSize, ranges);

        double res = Imgproc.compareHist(hist0, hist1, Imgproc.CV_COMP_CORREL);