单通道的可以更改,Vec3b中用at只能修改当前像素并在当前显示,一存像素就还原了,网上找了很多方法,存不进去,求解!
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
using namespace std;
using namespace cv;
Mat img=imread("D:/opencvm/openeye/wearhouse/tujiuhp.jpg");
void Matin(Mat img)
{
int k3,k4,k5;
Mat temp(img.rows,img.cols,CV_8UC3);
Vec3b a;
for(int i = 0; i <img.rows; i++)
{
//Vec3b* ptr=a.ptr<Vec3b>(i);
a[0]=img.at<Vec3b>(i,j)[0];
a[1]=img.at<Vec3b>(i,j)[1];
a[2]=img.at<Vec3b>(i,j)[2];
temp.at<Vec3b>(i,j) = a;
cout <<(int)temp.at<Vec3b>(i,j)[0]<<" ";
}
}