日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

c++ opencv实现图像对比度增强

發(fā)布時(shí)間:2023/12/29 c/c++ 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c++ opencv实现图像对比度增强 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
#include<iostream> #include<opencv2/opencv.hpp> #include<math.h>using namespace cv;int main() {Mat example = imread("D:\\VC項(xiàng)目\\img1.jpg");if (!example.data){printf("無法打開圖像!!!");return -1;}imshow("example", example);Mat outexample;// "********方式一(源碼對(duì)圖像進(jìn)行掩膜操作)*********************"example.copyTo(outexample);//把原圖片拷貝給outexampleint example_c = example.channels();//獲取圖片的通道數(shù) int height = example.rows;//得到圖片的高度int width = example.cols;//得到圖片的寬度 int cols = example.cols * example_c;//利用通道數(shù)*圖片的寬度for (int row = 1; row < height - 1; row++){const uchar* previous = example.ptr<uchar>(row - 1); //獲取前一行的指針const uchar* current = example.ptr<uchar>(row);//獲取當(dāng)前行的指針const uchar* next = example.ptr<uchar>(row +1);// 獲取下一行的指針uchar* output = outexample.ptr<uchar>(row);for (int col = example_c; col < example_c * (example.cols - 1); col++){*output = saturate_cast<uchar>(5 * current[col] - previous[col] - next[col] - current[col - example_c] - current[col + example_c]);output++;}} printf("輸入圖片的信息:\n");std::cout << "通道數(shù):"<<example_c<<"\n";std::cout << "圖片的大小:" << width << "*" << height;// "********方式二(直接利用cv種的filter2D對(duì)圖像進(jìn)行掩膜操作)*********************"Mat kernel = (Mat_<char>(3, 3) << 0, -1, 0, -1, 10, -1, 0, -1, 0);filter2D(example, outexample, example.depth(), kernel);imshow("outexample", outexample);waitKey(0);return 0; }

總結(jié)

以上是生活随笔為你收集整理的c++ opencv实现图像对比度增强的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。