支持jpg,png,tiff等图片格式
#include矩阵的掩膜操作(+逐像素遍历)using namespace cv; //加载图像 //显示图像 //修改图片 //保存图像
//获取图像像素指针 //获取当前行指针 const uchar* current = myImage.ptr(row); //获取当前像素点 P(row,col) = current[col]; //像素范围处理 saturate_cast //保证RGB值的范围在0-255之间 saturate_cast (-100);//return 0 saturate_cast (288);//return 255 saturate_cast (100);//return 100 //filter2D(src,dst,depth,kernel)
//提高对比度(通过3x3的掩膜相乘) #includeMat#include using namespace cv; using namespace std; int main(){ Mat src,dst; src = imread(“xxx.jpg”); if(src.empty()) { count<<“could not load image”< (row); const uchar* pre = src.ptr (row-1); const uchar* next = src.ptr (row+1); uchar* output = dst.ptr (row); for(int j = channels;j (current[j]*5-(current[j-channels]+current[j+channels]+pre[j]+next[j])); } } //上述操作等价于 //Mat kernel = (Mat_ (3,3)<<0,-1,0,-1,5,-1,0,-1,0); //filter2D(src,dst,src.depth(),kernel); nameWindow(“contrast img”,CV_WINDOW_AUTOSIZE); imshow(“contrast img”); waitKey(0); }



