首页 > 编程知识 正文

laplacian算子例题,LAC函数

时间:2023-05-04 20:03:09 阅读:270460 作者:2508

Laplacian函数:

函数功能:

对图像求二阶导数,一般用于边缘突出

Laplacian 算子 的定义:

函数调用形式:

void Laplacian(InputArray src, OutputArray dst, int ddepth, int ksize=1, double scale=1, double delta=0, int borderType=BORDER_DEFAULT )


函数参数详解:

InputArray src:输入图像

OutputArray dst:输出图像

int ddepth:表示输出图像的深度

depth 图像元素的位深度,可以是下面的其中之一:

                     位深度                                                            取值范围

      IPL_DEPTH_8U - 无符号8位整型                                     0--255

     IPL_DEPTH_8S - 有符号8位整型                                  -128--127

     IPL_DEPTH_16U - 无符号16位整型                                   0--65535

     IPL_DEPTH_16S - 有符号16位整型                           -32768--32767

     IPL_DEPTH_32S - 有符号32位整型                                    0--65535

     IPL_DEPTH_32F - 单精度浮点数                                     0.0--1.0

     IPL_DEPTH_64F - 双精度浮点数                                      0.0--1.0


int ksize=1:表示花痴的蛋挞核的大小,1表示核的大小是三:

When ksize == 1 , the Laplacian is computed by filtering the image with the following aperture:

double scale=1:表示是否对图像进行放大或者缩小

double delta=0:表示是否在输出的像素中加上一个量

int borderType=BORDER_DEFAULT:表示处理边界的方式,一般默认



opencv代码:

#include "opencv2/imgproc/imgproc.hpp"#include "opencv2/highgui/highgui.hpp"#include <stdlib.h>#include <stdio.h>using namespace cv;/** @函数 main */int main( int argc, char** argv ){ Mat src, src_gray, dst; int kernel_size = 3; int scale = 1; int delta = 0; int ddepth = CV_16S; char* window_name = "Laplace Demo"; int c; /// 装载图像 src = imread( argv[1] ); if( !src.data ) { return -1; } /// 使用高斯滤波消除噪声 GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT ); /// 转换为灰度图 cvtColor( src, src_gray, CV_RGB2GRAY ); /// 创建显示窗口 namedWindow( window_name, CV_WINDOW_AUTOSIZE ); /// 使用Laplace函数 Mat abs_dst; Laplacian( src_gray, dst, ddepth, kernel_size, scale, delta, BORDER_DEFAULT ); convertScaleAbs( dst, abs_dst ); /// 显示结果 imshow( window_name, abs_dst ); waitKey(0); return 0; }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。