-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc-gs.cpp
More file actions
50 lines (46 loc) · 1.11 KB
/
c-gs.cpp
File metadata and controls
50 lines (46 loc) · 1.11 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#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("samps/joker.jpg",1);
int cols=img.cols;
int rows=img.rows;
//Equal Width (.33,.33,.33)
Mat b (rows,cols,CV_8UC1,Scalar(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];
int igr= ((ib)+(ig)+(ir))/3;
b.at<uchar>(i,j)=igr;
}
}
//Unequal Width (.11,.58,.299)
Mat a (rows,cols,CV_8UC1,Scalar(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];
int igr= ((.11*ib)+(.58*ig)+(.299*ir));
a.at<uchar>(i,j)=igr;
}
}
namedWindow("Original",WINDOW_NORMAL);
imshow("Original",img);
namedWindow("EqWdth",WINDOW_NORMAL);
imshow("EqWdth",a);
namedWindow("UneqWdth",WINDOW_NORMAL);
imshow("UneqWdth",b);
waitKey(5000);
return 0;
}