forked from fanweng/Udacity-Sensor-Fusion-Nanodegree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchange_pixels.cpp
37 lines (30 loc) · 841 Bytes
/
change_pixels.cpp
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
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
using namespace std;
void changePixels()
{
// create matrix
int nrows = 480, ncols = 640;
cv::Mat m1_8u;
m1_8u.create(nrows, ncols, CV_8UC1); // two-channel matrix with 8bit unsigned elements
m1_8u.setTo(cv::Scalar(0)); //black
for (int r = 230; r < 250; r++)
{
// STUDENT TASK : loop over all columns and set matrix elements to 255
for (int c = 0; c <= ncols; c++)
{
m1_8u.at<int>(r, c) = 255;
}
}
// show result
string windowName = "First steps in OpenCV";
cv::namedWindow(windowName, 1); // create window
cv::imshow(windowName, m1_8u);
cv::waitKey(0); // wait for keyboard input before continuing
}
int main()
{
changePixels();
return 0;
}