Revision: 70074
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 17, 2015 02:37 by RicardoVarzim
Initial Code
#pragma region Laplacian Sobel Filters Mat LaplacianFilter(Mat img, int level){ namedWindow("Original image", CV_WINDOW_AUTOSIZE); imshow("Original image", img); Mat gray,draw,draw2; cvtColor(img, gray, CV_RGB2GRAY); /// Apply Laplace function Laplacian(gray, draw, CV_16S, 3, 1, 0, BORDER_DEFAULT); convertScaleAbs(draw, draw2); imwrite("../../result.jpg", draw2); namedWindow("Result image", CV_WINDOW_AUTOSIZE); imshow("Result image", draw2); waitKey(0); destroyWindow("Result image"); destroyWindow("Original image"); return draw; } Mat SobelFilter(Mat img, int level){ namedWindow("Original image", CV_WINDOW_AUTOSIZE); imshow("Original image", img); Mat grey; cvtColor(img, grey, CV_BGR2GRAY); Mat sobelx; Sobel(grey, sobelx, CV_32F, 1, 0); double minVal, maxVal; minMaxLoc(sobelx, &minVal, &maxVal); //find minimum and maximum intensities cout << "minVal : " << minVal << endl << "maxVal : " << maxVal << endl; Mat draw; sobelx.convertTo(draw, CV_8U, 255.0 / (maxVal - minVal), -minVal * 255.0 / (maxVal - minVal)); imwrite("../../result.jpg", draw); namedWindow("Result image", CV_WINDOW_AUTOSIZE); imshow("Result image", draw); waitKey(0); destroyWindow("Result image"); destroyWindow("Original image"); return draw; } #pragma endregion
Initial URL
Initial Description
OpenCV Laplacian and Sobel Filters Implementation
Initial Title
CG - OpenCV Laplacian and Sobel Filters Implementation
Initial Tags
c++
Initial Language
C++