zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    Chrome 控制台console的用法[转]
    Page Visibility(页面可见性) API介绍、微拓展[转]
    移动端rem单位用法[转]
    JavaScript继承方式详解[转]
    说说React
    Flex 布局教程:语法篇[转]
    git 常用命令总结
    Supervisor 在ubuntu系统下添加自启动
    Django 通过APNS推送消息
    通过 python-xmp-toolkit 读取图片xmlp信息
  • 原文地址:https://www.cnblogs.com/herd/p/15423231.html
Copyright © 2011-2022 走看看