标签:alt 模糊 module intern targe sans eth ini iss
收入囊中
|
This is done when ksize > 1 . When ksize == 1 ,
the Laplacian is computed by filtering the image with the following
aperture:

#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;
int main( int, char** argv )
{
Mat src, src_gray;
int kernel_size = 3;
const char* window_name = "Laplace Demo";
src = imread( argv[1] );
GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
cvtColor( src, src_gray, CV_RGB2GRAY );
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
Mat dst, abs_dst;
Laplacian( src_gray, dst, CV_16S, kernel_size);
convertScaleAbs( dst, abs_dst );
imshow( window_name, abs_dst );
waitKey(0);
return 0;
}| 1 | 1 | 1 |
| 1 | -8 | 1 |
| 1 | 1 | 1 |
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
int main( int, char** argv )
{
Mat src,gray,Kernel;
src = imread( argv[1] );
GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
cvtColor( src, gray, CV_RGB2GRAY );
namedWindow("dstImage", 1);
Kernel = (Mat_<double>(3,3) << 1, 1, 1, 1, -8, 1, 1, 1, 1);
Mat grad,abs_grad;
filter2D(gray, grad, CV_16S , Kernel, Point(-1,-1));
convertScaleAbs( grad, abs_grad );
imshow("dstImage", abs_grad);
waitKey();
return 0;
} 效果图就不发了,跟上面差点儿相同拉普拉斯锐化的基本方法能够由下式表示:
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
int main( int, char** argv )
{
Mat src,gray;
src = imread( argv[1] );
GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
cvtColor( src, gray, CV_RGB2GRAY );
namedWindow("srcImage", 1);
namedWindow("dstImage", 1);
Mat grad,abs_grad;
Laplacian( gray, grad, CV_16S, 3);
convertScaleAbs( grad, abs_grad );
Mat sharpped = gray + abs_grad;
imshow("srcImage", gray);
imshow("dstImage", sharpped);
waitKey();
return 0;
} OpenCV2马拉松第15圈——边缘检測(Laplace算子,LOG算子)
标签:alt 模糊 module intern targe sans eth ini iss
原文地址:http://www.cnblogs.com/liguangsunls/p/6784659.html