// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<opencv2\opencv.hpp>
#include<opencv2\highgui\highgui.hpp>
using namespace cv;
int main()
{
Mat src, dst;
src = imread("C:\\Users\\精锐视觉\\Desktop\\方案\\博奥模组端板检测\\新建文件夹\\新建文件夹\\2D大光效果\\5.bmp");
namedWindow("qq", CV_WINDOW_AUTOSIZE);
int c = src.cols;
int w = src.rows;
int nc = src.channels();
for (int i = 0; i <w; i++)
{
for (int j = 0; j < c; j++)
{
if (nc == 1)
{
int gray = src.at<uchar>(i, j);
src.at<uchar>(i, j) = 255 - gray;//b通道
}
if (nc == 3)
{
int b = src.at<Vec3b>(i, j)[0];
int g = src.at<Vec3b>(i, j)[1];
int r = src.at<Vec3b>(i, j)[2];
src.at<Vec3b>(i, j)[0] = 255 - b;
src.at<Vec3b>(i, j)[1] = 255 - g;
src.at<Vec3b>(i, j)[2] = 255 - r;
}
}
}
pyrDown(src, src,Size(src.cols / 2, src.rows / 2));
pyrDown(src, src, Size(src.cols / 2, src.rows / 2));
imshow("qq", src);
imwrite("C:\\Users\\精锐视觉\\Desktop\\方案\\博奥模组端板检测\\新建文件夹\\新建文件夹\\2D大光效果\\5.bmp",src);
cvWaitKey(0);
return 0;
}