2D图像滤波器基础类BaseFilter:dst(x,y) = F(src(x,y), src(x+1,y)... src(x+wdith-1,y), src(y+1,x)... src(x+width-1, y+height-1) );

相关的调用函数为getLinearFilter、getMorphologyFilter

 

单行核滤波器基础类BaseRowFilter:dst(x,y) = F(src(x,y), src(x+1,y),...src(x+width-1,y));

相关的调用函数为getLinearRowFilter、getMorphologyRowFilter

 

单列核滤波器基础类BaseColumnFilter:dst(x,y) = F(src(x,y), src(x,y+1),...src(x,y+width-1));

相关的调用函数为getColumnSumFilter、getLinearColumnFilter、getMorphologyColumnFilter

 

类FilterEngine:该类可以应用在对图像的任意滤波操作当中,在OpenCV滤波器函数中扮演着很重要的角色,相关的函数有createBoxFitler、createDerivFitlter、createGaussianFilter、createLinearFilter、createMorphologyFilter、createSeparableLinearFilter

这里介绍一下我使用Laplacian滤波的心得,这个函数的第三个参数为输出的图像的深度,注意经过拉普拉斯算子处理后得到的值是有正有负的,所以输出图像的深度最好为输入图像深度的2倍,才能有效防止数据溢出,如必须要使用8位的数据,可以再使用函数convertScaleAbs处理。而且要注意使用的拉普拉斯算子掩膜的中心系数为负。

 

 

GaussianBlur

Parameters:

  • src – input image; the image can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
  • dst – output image of the same size and type as src.
  • ksize – Gaussian kernel size. ksize.width and ksize.height can differ but they both must be positive and odd. Or, they can be zero’s and then they are computed from sigma* .
  • sigmaX – Gaussian kernel standard deviation in X direction.
  • sigmaY – Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height , respectively (see getGaussianKernel() for details); to fully control the result regardless of possible future modifications of all this semantics, it is recommended to specify all of ksize,sigmaX, and sigmaY.
  • borderType – pixel extrapolation method (see borderInterpolate() for details).

 

void convertScaleAbs(InputArray src, OutputArray dst, double alpha=1, double beta=0)

Parameters:

  • src – input array.
  • dst – output array.
  • alpha – optional scale factor.
  • beta – optional delta added to the scaled values.

 

#include "stdafx.h"

#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdlib.h>
#include <stdio.h> using namespace cv; /** @function 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; /// Load an image
src = imread( "zhou.jpg" ); // Mat --- imread if( !src.data )
{ return -1; } /// Remove noise by blurring with a Gaussian filter
GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT ); /// Convert the image to grayscale
cvtColor( src, src_gray, CV_RGB2GRAY ); /// Create window
namedWindow( window_name, CV_WINDOW_AUTOSIZE ); // cvNamedWindow /// Apply Laplace function
Mat abs_dst; Laplacian( src_gray, dst, ddepth, kernel_size, scale, delta, BORDER_DEFAULT );
convertScaleAbs( dst, abs_dst ); // Scales, calculates absolute values, and converts the result to 8-bit. /// Show what you got
imshow( window_name, abs_dst ); waitKey(0); return 0;
}

 

 

转自:http://blog.csdn.net/yang_xian521/article/category/910716/4

OPENCV(4) —— ImgProc的更多相关文章

  1. [error]OpenCV Error: Assertion failed (ssize.width > 0 && ssize.height > 0) in resize, file modules/imgproc/src/resize.cpp, line 3289

    error OpenCV Error: Assertion failed (ssize.width > && ssize.height > ) terminate call ...

  2. OpenCV 之 边缘检测

    上一篇 <OpenCV 之 图像平滑> 中,提到的图像平滑,从信号处理的角度来看,实际上是一种“低通滤波器”. 本篇中,数字图像的边缘,因为通常都是像素值变化剧烈的区域 (“高频”),故可 ...

  3. opencv 简单模糊和高斯模糊 cvSmooth

    cv::Mat 是C++版OpenCV的新结构. cvSmooth() 是老版 C API. 没有把C接口与C + + 结合. 建议你们也可以花一些时间看一下介绍. 同样,你如果查看opencv/mo ...

  4. OpenCV图像金字塔:高斯金字塔、拉普拉斯金字塔与图片尺寸缩放

    这篇已经写得很好,真心给作者点个赞.题目都是直接转过来的,直接去看吧. Reference Link : http://blog.csdn.net/poem_qianmo/article/detail ...

  5. OpenCV图像的二值化

    图像的二值化: 与边缘检测相比,轮廓检测有时能更好的反映图像的内容.而要对图像进行轮廓检测,则必须要先对图像进行二值化,图像的二值化就是将图像上的像素点的灰度值设置为0或255,这样将使整个图像呈现出 ...

  6. OpenCV中对图像进行二值化的关键函数——cvThreshold()。

    函数功能:采用Canny方法对图像进行边缘检测 函数原型: void cvThreshold( const CvArr* src, CvArr* dst, double threshold, doub ...

  7. matlab调用opencv函数的配置

    环境: VS2010 活动解决方案平台x64 WIN 8.1 Opencv 2.4.3 Matlab 2012a 1.  首先保证vs2010能正确调用opencv函数, 2.  Matlab中选择编 ...

  8. 【OpenCV新手教程之十三】OpenCV图像金字塔:高斯金字塔、拉普拉斯金字塔与图片尺寸缩放

    本系列文章由@浅墨_毛星云 出品,转载请注明出处. 文章链接:http://blog.csdn.net/poem_qianmo/article/details/26157633 作者:毛星云(浅墨) ...

  9. OpenCV 之 图像分割 (一)

    1  基于阈值 1.1  基本原理 灰度阈值化,是最简单也是速度最快的一种图像分割方法,广泛应用在硬件图像处理领域 (例如,基于 FPGA 的实时图像处理). 假设输入图像为 f,输出图像为 g,则经 ...

随机推荐

  1. React 使用link在url添加参数(url中不可见)

    1. 在要跳转页面添加<Link to={{ pathname: `/staffManagement/cardRecord`, state: {time: YYYY-MM-dd, name: s ...

  2. FarPoint自动换行

    单元格自动换行 FarPoint.Win.Spread.CellType.TextCellType mType = new FarPoint.Win.Spread.CellType.TextCellT ...

  3. C#-反射知识点

    1.反射是基于Sytem.Type的,里面的很多方法是system.reflection里面的 MethodInfo[] tt= t.GetType().GetMethods(); //t是strin ...

  4. Spring MVC 的 研发之路 (二)

    二.web.xml的简单配置介绍1 1.启动Web项目时,容器回去读web.xml配置文件里的两个节点<context-param>和<listener> 2.接着容器会创建一 ...

  5. spring揭秘 读书笔记 二 BeanFactory的对象注冊与依赖绑定

    本文是王福强所著<<spring揭秘>>一书的读书笔记 我们前面就说过,Spring的IoC容器时一个IoC Service Provider,并且IoC Service Pr ...

  6. ASMlib操作系统包安装与配置asm disk磁盘

    1.加入6块硬盘,每块100g.不管是热加还是冷加.不管是加硬盘,用san存储划lun,或者再加上多路径,都是能够这么做的. 在操作系统层,能识别这种lun.以下的sdb就是一个刚划分的300g的lu ...

  7. python 同步IO

    IO在计算机中指Input/Output 由CPU这个超快的计算核心来执行,涉及到数据交换的地方,通常是磁盘.网络等,就需要IO接口.IO编程中,Stream(流)是一个很重要的概念,可以把流想象成一 ...

  8. 如何配置MySQL?(三)

    要进行mysql配置,首先要找到mysql的配置向导文件,这个配置向导文件就在我们安装目录下的一个bin的子目录下. 刚才我们是选择典型安装MySQL,一般windows是默认存储在C:\Progra ...

  9. Oracle中根据表明获取对应表触发器名称

    Select object_name From user_objects a left join all_triggers b on a.object_Name = b.trigger_name wh ...

  10. 使用U盘安装win8(win8.1)系统

    下载镜像 下载系统镜像,可以选32位或64位.下完后放到非系统盘(如果需要重新分区的,要先保存到移动硬盘或U盘) 使用U盘制作PE 准备一个4G以上的U盘(备份好U盘里的资料,因为刻录PE需要格式化U ...