图像处理技术及相应C++代码

1、直方图均衡化

 //直方图均衡化
Mat equalizeHist_src;
Mat imageRGB[3];
split(src, imageRGB);
for (int i = 0; i < 3; i++)
{
	equalizeHist(imageRGB[i], imageRGB[i]);
}
merge(imageRGB, 3, equalizeHist_src);
//imshow("直方图均衡化图像增强效果", equalizeHist_src);

2、拉普拉斯变换

//拉普拉斯算子图像增强
Mat imageEnhance;
Mat kernel = (Mat_(3, 3) << 0, -1, 0, 0, 5, 0, 0, -1, 0);
filter2D(src, imageEnhance, CV_8UC3, kernel);

3、高反差保留

//高反差保留
Mat temp;
GaussianBlur(src, temp, Size(7, 7), 1.6, 1.6);
int r = 3;
Mat diff = src + r*(src - temp); //高反差保留算法

4、二值化

//二值化
Mat img_gray, img_binary;
cvtColor(src, img_gray, CV_BGR2GRAY);
threshold(img_gray, img_binary, 0, 255, THRESH_BINARY);

5、亮度调节

Mat new_image = Mat::zeros(image.size(), image.type());
double alpha = 1.0; 
int beta = 0; 
for( int y = 0; y < image.rows; y++ ) 
{
        for( int x = 0; x < image.cols; x++ ) 
        {
            for( int c = 0; c < image.channels(); c++ ) 
            {
                new_image.at(y,x)[c] =
                  saturate_cast(alpha*image.at(y,x)[c] + beta);
            }
        }
}

参考文献:

  1. https://blog.csdn.net/hhaowang/article/details/86593941

你可能感兴趣的:(图像处理)