forked from gcamp-hub/Jetson-OpenCV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSobelDerivatives.cpp
28 lines (22 loc) · 921 Bytes
/
SobelDerivatives.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
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat input_image = imread("images/Fig04_house.tif", IMREAD_GRAYSCALE);
Mat sobel_filtered_horizontal, sobel_filtered_vertical;
Mat horizontal_der_scaled, vertical_der_scaled;
Sobel(input_image, sobel_filtered_horizontal, CV_16S, 1, 0);
Sobel(input_image, sobel_filtered_vertical, CV_16S, 0, 1);
convertScaleAbs(sobel_filtered_horizontal, horizontal_der_scaled);
convertScaleAbs(sobel_filtered_vertical, vertical_der_scaled);
imshow("Horizontal_Derivative", horizontal_der_scaled);
imshow("Vertical_Derivative", vertical_der_scaled);
// imshow("Horizontal_Derivative", sobel_filtered_horizontal);
// imshow("Vertical_Derivative", sobel_filtered_vertical);
waitKey(0);
return 0;
}