graph_00
graph_01(first deravative of horizontal and vertical sobel)
Generally, there are three kind of approximation of deravative in image processing, they are backward difference(3), forward difference(4) and central difference(5).
openCV2 provide us a function filter2D to apply correlation on the images, below are the codes which apply the x direction(graph_03) and y direction(graph_04) sobel on graph_00.
cv::Mat sobel_x_filter_ = (cv::Mat_<float>(3, 3)
<< -1, 0, 1,
-2, 0, 2,
-1, 0, 1),
cv::Mat sobel_y_filter_ = (cv::Mat_<float>(3, 3)
<< -1, -2, -1,
0, 0, 0,
1, 2, 1);
cv::Mat input = cv::imread("flower.png");
cv::Mat dst;
cv::filter2D(input_, dst, CV_8U, sobel_x_filter_);
cv::imwrite("sobel_x1.png", dst);
cv::filter2D(input_, dst, CV_8U, sobel_y_filter_);
cv::imwrite("sobel_y1.png", dst);







No comments:
Post a Comment