• opencv ocl_morphologyEx


    opencv   ocl_morphologyEx

    static bool ocl_morphologyEx(InputArray _src, OutputArray _dst, int op,
                                 InputArray kernel, Point anchor, int iterations,
                                 int borderType, const Scalar& borderValue)
    {
        _dst.createSameSize(_src, _src.type());
        bool submat = _dst.isSubmatrix();
        UMat temp;
        _OutputArray _temp = submat ? _dst : _OutputArray(temp);
    
        switch( op )
        {
        case MORPH_ERODE:
            if (!ocl_morphOp( _src, _dst, kernel, anchor, iterations, MORPH_ERODE, borderType, borderValue ))
                return false;
            break;
        case MORPH_DILATE:
            if (!ocl_morphOp( _src, _dst, kernel, anchor, iterations, MORPH_DILATE, borderType, borderValue ))
                return false;
            break;
        case MORPH_OPEN:
            if (!ocl_morphOp( _src, _temp, kernel, anchor, iterations, MORPH_ERODE, borderType, borderValue ))
                return false;
            if (!ocl_morphOp( _temp, _dst, kernel, anchor, iterations, MORPH_DILATE, borderType, borderValue ))
                return false;
            break;
        case MORPH_CLOSE:
            if (!ocl_morphOp( _src, _temp, kernel, anchor, iterations, MORPH_DILATE, borderType, borderValue ))
                return false;
            if (!ocl_morphOp( _temp, _dst, kernel, anchor, iterations, MORPH_ERODE, borderType, borderValue ))
                return false;
            break;
        case MORPH_GRADIENT:
            if (!ocl_morphOp( _src, temp, kernel, anchor, iterations, MORPH_ERODE, borderType, borderValue ))
                return false;
            if (!ocl_morphOp( _src, _dst, kernel, anchor, iterations, MORPH_DILATE, borderType, borderValue, MORPH_GRADIENT, temp ))
                return false;
            break;
        case MORPH_TOPHAT:
            if (!ocl_morphOp( _src, _temp, kernel, anchor, iterations, MORPH_ERODE, borderType, borderValue ))
                return false;
            if (!ocl_morphOp( _temp, _dst, kernel, anchor, iterations, MORPH_DILATE, borderType, borderValue, MORPH_TOPHAT, _src ))
                return false;
            break;
        case MORPH_BLACKHAT:
            if (!ocl_morphOp( _src, _temp, kernel, anchor, iterations, MORPH_DILATE, borderType, borderValue ))
                return false;
            if (!ocl_morphOp( _temp, _dst, kernel, anchor, iterations, MORPH_ERODE, borderType, borderValue, MORPH_BLACKHAT, _src ))
                return false;
            break;
        default:
            CV_Error( CV_StsBadArg, "unknown morphological operation" );
        }
    
        return true;
    }

    代码参考:opencv3_4_1opencv-3.4.1modulesimgprocsrcmorph.cpp

    ##############################################

    QQ 3087438119
  • 相关阅读:
    linux给用户添加sudo权限
    VirtualBox下安装ubuntu图文教程以及软件安装
    线程池代码(通用版)
    linux下配置jdk+tomcat
    线程池代码(加强版)
    线程池的理解与简单实现(学习版)
    条件变量pthread_cond_wait()和pthread_cond_signal()详解
    五种编程模型
    Linux线程退出、资源回收、资源清理的方法
    数据结构
  • 原文地址:https://www.cnblogs.com/herd/p/15423231.html
Copyright © 2020-2023  润新知