-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathneg.cpp
More file actions
27 lines (26 loc) · 719 Bytes
/
neg.cpp
File metadata and controls
27 lines (26 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int main(int argc, char const *argv[])
{
Mat img= imread("/home/arnesh/IP/samps/joker.jpg",1);
int cols=img.cols;
int rows=img.rows;
Mat a(rows,cols,CV_8UC3,Scalar(0,0,0));
for (int j = 0; j < cols; j++)
for (int i = 0; i < rows; i++)
{
int ib= img.at<Vec3b>(i,j)[0];
int ig= img.at<Vec3b>(i,j)[1];
int ir= img.at<Vec3b>(i,j)[2];
a.at<Vec3b>(i,j)={255-ib,255-ig,255-ir};
}
/*namedWindow("Original",WINDOW_NORMAL);
imshow("Original",img);*/
namedWindow("Negative",WINDOW_NORMAL);
imshow("Negative",a);
waitKey(5000);
}