Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <opencv2/core/core.hpp>
- #include <opencv2/highgui/highgui.hpp>
- #include <opencv2/imgproc/imgproc.hpp>
- #include <iostream>
- int main()
- {
- cv::Mat img = cv::imread("E:/Dropbox/IMERSO/stainless-cube01_1024x1024.jpg");
- cv::namedWindow("FunnyEffectsLol9ga!!!111", cv::WINDOW_AUTOSIZE);
- cv::Mat grey;
- cv::cvtColor(img, grey, cv::COLOR_BGR2GRAY);
- cv::Mat sobel1;
- cv::Sobel(grey, sobel1, CV_32F, 0, 1);
- double minVal, maxVal;
- minMaxLoc(sobel1, &minVal, &maxVal); //find minimum and maximum intensities
- cv::Mat draw1;
- sobel1.convertTo(draw1, CV_8U, 255.0 / (maxVal - minVal), -minVal * 255.0 / (maxVal - minVal));
- cv::Mat sobel2;
- cv::Sobel(grey, sobel2, CV_32F, 1, 0);
- minMaxLoc(sobel2, &minVal, &maxVal); //find minimum and maximum intensities
- cv::Mat draw2;
- sobel2.convertTo(draw2, CV_8U, 255.0 / (maxVal - minVal), -minVal * 255.0 / (maxVal - minVal));
- cv::Mat height(draw2);
- //cv::min(draw1, draw2, height);
- for (size_t y = 1; y < height.rows-1; y++) {
- for (size_t x = 1; x < height.cols-1; x++) {
- height.at<uchar>(y, x) = (draw1.at<uchar>(y, x) + draw2.at<uchar>(y, x)) / 2;
- }
- }
- cv::GaussianBlur(height, height, cv::Size(3, 3), 1, 1);
- imshow("FunnyEffectsLol9ga!!!111", height);
- cv::waitKey(0);
- cv::destroyWindow("FunnyEffectsLol9ga!!!111");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment