标签:type 键盘 ++ asa bug using lan space and
Opencv图片明暗处理
#include <iostream> #include <opencv2/opencv.hpp> using namespace std; using namespace cv; //图片明暗处理 cv::Mat shadingTreatment(cv::Mat imgParam); int main() { double alpha; //对比度 int beta; //亮度 //Mat image = imread("F:\\OpencvProject\\CamerasAndSurveillance201910\\x64\\Debug\\face_data\\20191025143712025.jpg"); Mat image = imread("D:\\images\\特朗普\\0.jpg"); if (image.empty()) { return 0; } cv::Mat new_image = shadingTreatment(image); /// 目标图像空间预分配 /// 显示图像 imshow("原图像", image); imshow("新图像", new_image); /// 等待键盘事件 waitKey(0); return 0; } //图片明暗处理 cv::Mat shadingTreatment(cv::Mat imgParam) { Mat new_image = Mat::zeros(imgParam.size(), imgParam.type()); /// 输入初始化值 //cout << "请输入对比度1-3: "; //cin >> alpha; //cout << "请输入亮度1-100: "; //cin >> beta; double alpha = 1.2; int beta = 50; /// 执行变换 new_image(i,j) = alpha * image(i,j) + beta for (int y = 0; y < imgParam.rows; y++) { for (int x = 0; x < imgParam.cols; x++) { for (int c = 0; c < 3; c++) { new_image.at<Vec3b>(y, x)[c] = saturate_cast<uchar>(alpha * (imgParam.at<Vec3b>(y, x)[c]) + beta); } } } return new_image; }
标签:type 键盘 ++ asa bug using lan space and
原文地址:https://www.cnblogs.com/herd/p/11754654.html