编程语言
首页 > 编程语言> > OpenCV Java 直方图均衡化

OpenCV Java 直方图均衡化

作者:互联网





../../../../../_images/Histogram_Equalization_Theory_1.jpg

Java Code实现:


package com.gitee.dgw.lesson8;

import com.gitee.dgw.lesson1.platformUtils;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

/**
 * @program: learn-opencv
 * @description:
 * @author: Mr.Dai
 * @create: 2020-03-10 18:41
 **/
public class equalizeHist {


    private final  static String path=System.getProperty("user.dir")+"\\catton.jpg";
    static{
        platformUtils.loadLibraries();
    }


    public static void main(String[] args) {
        Mat srcimage;
        Mat dstimg=new Mat();
        //读取一张图片
        //image=Imgcodecs.imread(path);

        //读取一张灰度图片
        srcimage= Imgcodecs.imread(path,Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);

        if (srcimage.empty()) {
            System.err.println("加载图片出错,请检查图片路径!");
            return;
        }

        Imgproc.equalizeHist(srcimage,dstimg);

        //显示出来  对namedWindos 与cv::imshow 封装
        HighGui.imshow("dstimg showimg",dstimg);
        HighGui.imshow("srcimage showimg",srcimage);
        // 无限等待按键按下
        HighGui.waitKey(0);

    }
}




image

标签:srcimage,OpenCV,均衡化,dstimg,opencv,直方图,import
来源: https://www.cnblogs.com/dgwblog/p/12458167.html