cv::MatIterator_

应用1:图像补运算:MatIterator_迭代器反色处理:

 1 #include <opencv2/video/background_segm.hpp>
 2 #include <iostream>    
 3 #include<core/core.hpp>    
 4 #include<highgui/highgui.hpp>  
 5 
 6 // 注意srcImage为3通道的彩色图片
 7 cv::Mat inverseColor4(cv::Mat &srcImage)
 8 {
 9     cv::Mat tempImage = srcImage.clone();
10     // 初始化源图像迭代器  
11     cv::MatConstIterator_<cv::Vec3b> srcIterStart =
12         srcImage.begin<cv::Vec3b>();
13     cv::MatConstIterator_<cv::Vec3b> srcIterEnd =
14         srcImage.end<cv::Vec3b>();
15     // 初始化输出图像迭代器  
16     cv::MatIterator_<cv::Vec3b> resIterStart =
17         tempImage.begin<cv::Vec3b>();
18     cv::MatIterator_<cv::Vec3b> resIterEnd =
19         tempImage.end<cv::Vec3b>();
20     // 遍历图像反色处理  
21     while (srcIterStart != srcIterEnd)
22     {
23         (*resIterStart)[0] = 255 - (*srcIterStart)[0];
24         (*resIterStart)[1] = 255 - (*srcIterStart)[1];
25         (*resIterStart)[2] = 255 - (*srcIterStart)[2];
26         // 迭代器递增  
27         srcIterStart++;
28         resIterStart++;
29     }
30     return tempImage;
31 }
32 
33 int main(void)
34 //int test01()
35 {
36     cv::Mat image = cv::imread("D:\\小女孩与熊.jpg");
37     if (image.empty())
38     {
39         std::cerr << "Load image failed!" << std::endl;
40         return 0;
41     }
42 
43     cv::Mat result = inverseColor4(image);
44     cv::imshow("src", image);
45     cv::imshow("result", result);
46     cv::waitKey();
47 
48     return 0;
49 }
View Code

https://blog.csdn.net/gone_huilin/article/details/53222573

Gamma校正原理及实现:

https://blog.csdn.net/linqianbi/article/details/78617615

opencv 3.0 Mat STL 迭代器的使用:https://blog.csdn.net/billbliss/article/details/42806459

posted @ 2018-08-16 19:59  BreakofDawn  阅读(836)  评论(0编辑  收藏  举报