Skip to content

Commit fbeac3d

Browse files
authoredAug 20, 2019
Add files via upload
1 parent b66e361 commit fbeac3d

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
 

‎pixels.cpp

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include <opencv2/opencv.hpp>
2+
#include <iostream>
3+
4+
int main(int args, char** argv) {
5+
6+
cv::namedWindow("Input Image", cv::WINDOW_AUTOSIZE);
7+
cv::namedWindow("Downscaled Image", cv::WINDOW_AUTOSIZE);
8+
cv::namedWindow("GreyScale Image", cv::WINDOW_AUTOSIZE);
9+
cv::namedWindow("Canny Image", cv::WINDOW_AUTOSIZE);
10+
11+
cv::Mat input, gry, pyr, cny;
12+
13+
input = cv::imread(argv[1]);
14+
cv::imshow("Input Image", input);
15+
16+
cv::cvtColor(input, gry, cv::COLOR_BGR2GRAY);
17+
cv::pyrDown(gry, pyr);
18+
cv::Canny(pyr, cny, 10, 100, 3, true);
19+
20+
cv::imshow("GreyScale Image", gry);
21+
cv::imshow("Downscaled Image", pyr);
22+
cv::imshow("Canny Image", cny);
23+
24+
int x = 16, y = 32;
25+
cv::Vec3b intensity = input.at< cv::Vec3b >(y, x);
26+
27+
uchar blue = intensity[0];
28+
uchar green = intensity[1];
29+
uchar red = intensity[2];
30+
31+
std::cout << "At (x, y) = (" << x << ", " << y << "): (blue, green, red) = (" << (unsigned int)blue << ", " << (unsigned int)green << ", " << (unsigned int)red << ")" << std::endl;
32+
33+
std::cout << "Gray pixel there is: " << (unsigned int)gry.at<uchar>(y, x) << std::endl;
34+
35+
x = x/4;
36+
y = y/4;
37+
38+
std::cout << "Downscaled pixel there is: " << (unsigned int)pyr.at<uchar>(y, x) << std::endl;
39+
40+
cny.at<uchar>(x, y) = 128;
41+
42+
cv::namedWindow("New Canny", cv::WINDOW_AUTOSIZE);
43+
cv::imshow("New Canny", cny);
44+
45+
cv::waitKey(0);
46+
47+
return 0;
48+
}

0 commit comments

Comments
 (0)
Please sign in to comment.