zoukankan      html  css  js  c++  java
  • OPENCV(4) —— ImgProc

    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处理。而且要注意使用的拉普拉斯算子掩膜的中心系数为负。

    S~5_8NHSBU$434$2OPZ{1OR

    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.

    [0O4`STZ{CVGDHBN6YOXSPP

    #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

  • 相关阅读:
    关于C++中操作符重载的疑问 :四个运算符=, ->, [], ()不可以重载为全局函数(友员函数)...
    linux内核移植过程问题总结
    关于开发板用tftp下载失败分析
    阿里云ECS下安装的MySQL无法远程连接?
    uva729
    使用 Confluence 6 服务器移动应用
    Confluence 6 移动浏览查看任务
    Confluence 6 移动浏览查看通知
    Confluence 6 移动浏览查看页面,博客和评论
    Confluence 6 移动浏览搜索内容和人
  • 原文地址:https://www.cnblogs.com/sprint1989/p/4070443.html
Copyright © 2011-2022 走看看