数字图像处理:对数变换

设置窗口大小的函数:

namedWindow("窗口名", 0);

resizeWindow("窗口名", width, height);

#include <iostream>
#include <cmath>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
void log_transfor(Mat &image, Mat &result)
{
	result = image.clone();
	int rows = image.rows, cols = image.cols;
	for (int i = 0; i < rows; i++)
	{
		for (int j = 0; j < cols; j++)
		{
			for (int k = 0; k < 3; k++)
			{
				result.at<Vec3b>(i, j)[k] = 31 * log2(1 + image.at<Vec3b>(i, j)[k]);
			}
		}
	}
}
int main()
{
	Mat image = imread("f:\\图片\\lucky.jpg");
	
	Mat result;
	log_transfor(image, result);
	namedWindow("原图", 0);
	namedWindow("对数变换", 0);
	resizeWindow("原图", 500, 600);
	resizeWindow("对数变换", 500, 600);
	imshow("原图", image);
	imshow("对数变换", result);
	waitKey(0);
	return 0;
}

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页