大礼帽过滤器运行时间 [英] top hat filter running time

查看:134
本文介绍了大礼帽过滤器运行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大礼帽过滤器的速度问题。在IEEE交易论文中,使用MATLAB软件在具有8-GB存储器和4-GHz Intel i7处理器的PC上估计应用于分辨率为320×256的图像的顶帽的运行时间为0.0062秒。 table_time我使用openCV在带有6 GB内存和2.6 GHz Intel i5处理器的笔记本电脑上运行以下代码,该图像具有相同的分辨率:

I have a problem with speed of a top hat filter. In an IEEE transaction paper, the running time of top hat applied to an image with resolution 320× 256 is estimated 0.0062 second with MATLAB software on a PC with 8-GB memory and 4-GHz Intel i7 processor. table_time I run the following code with openCV on a laptop with 6-GB memory and 2.6-GHz Intel i5 processor for this image with the same resolution: enter image description here

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(){
    double t0 = (double)getTickCount();
    Mat src,dst;
    src=imread("E:/tree.jpg",0);
    Mat element = getStructuringElement(MORPH_ELLIPSE,Size(15,15));
    morphologyEx(src,dst,MORPH_TOPHAT,element,Point(-1,-1));
    double elapsed=((double)getTickCount()-t0)/getTickFrequency();
    cout<<elapsed<<"second"<<"\n";
    return -1;}

尽管事实上C ++和openCV是快速的,但为什么顶帽的运行时间在Matlab中为6 ms,在opencv中为54 ms。

It takes .05375 second. In spite of the the fact that C++ and openCV are fast, but why the running time of top hat is 6 ms in matlab and 54 ms in opencv. how I could accelerate it?

推荐答案

这是我的笔记本电脑上的测试结果(Intel(R)_Core(TM)_i5- 3230M_CPU _ @ _ 2.60GHz)

here is my test result on my laptop ( Intel(R)_Core(TM)_i5-3230M_CPU_@_2.60GHz)

0.00129578秒!!

0.00129578 seconds!!

我认为最重要的是编译OpenCV。有很多选择。我附上我的输出 getBuildInformation()

i think the most important thing is how did you compile OpenCV. there is many options. i attached my output of getBuildInformation()

测试代码(改进的代码版本)

test code (improved version of your code)

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main() {

    Mat src, dst;
    src = imread("tree.jpg", 0);
    Mat element = getStructuringElement(MORPH_ELLIPSE, Size(15, 15));
    double elapsed = 0;
    for (int i = 0; i < 100; i++)
    {
        double t0 = (double)getTickCount();
        morphologyEx(src, dst, MORPH_TOPHAT, element, Point(-1, -1));
        elapsed += ((double)getTickCount() - t0) / getTickFrequency();
    }

    cout << elapsed / 100 << " seconds" << "\n";
    cout << getBuildInformation();
    imshow("result", dst);
    waitKey();
    return -1;
}

输出测试代码

0.00129578 seconds

General configuration for OpenCV 3.1.0-dev =====================================
  Version control:               unknown

  Extra modules:
    Location (extra):            D:/git/opencv_contrib/modules
    Version control (extra):     unknown

  Platform:
    Timestamp:                   2016-05-27T19:59:05Z
    Host:                        Windows 10.0.10586 AMD64
    CMake:                       3.5.0-rc3
    CMake generator:             Visual Studio 14 2015 Win64
    CMake build tool:            C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe
    MSVC:                        1900

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe  (ver 19.0.23506.0)
    C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:AVX /Oi  /wd4251 /wd4324 /wd4275 /wd4589 /MP4  /MD /O2 /Ob2 /D NDEBUG
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR /EHa  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:AVX /Oi  /wd4251 /wd4324 /wd4275 /wd4589 /MP4  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
    C Compiler:                  C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
    C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:AVX /Oi    /MP4  /MD /O2 /Ob2 /D NDEBUG
    C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /arch:AVX /Oi    /MP4  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
    Linker flags (Release):      /machine:x64  /INCREMENTAL:NO
    Linker flags (Debug):        /machine:x64  /debug /INCREMENTAL
    Precompiled headers:         NO
    Extra dependencies:          comctl32 gdi32 ole32 setupapi ws2_32 D:/git/pthreadVC2.lib
    3rdparty dependencies:       zlib libjpeg libpng libtiff libjasper IlmImf libprotobuf

  OpenCV modules:
    To be built:                 core flann imgproc ml photo reg surface_matching video dnn fuzzy imgcodecs shape videoio highgui objdetect plot superres ts xobjdetect xphoto bgsegm bioinspired cvblobslib dpm face features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo structured_light videostab xfeatures2d ximgproc aruco optflow stitching tracking ayvos java
    Disabled:                    world contrib_world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev python2 python3 viz cvv hdf matlab sfm

  Windows RT support:            NO

  GUI:
    QT:                          NO
    Win32 UI:                    YES
    OpenGL support:              NO
    VTK support:                 NO

  Media I/O:
    ZLib:                        build (ver 1.2.8)
    JPEG:                        build (ver 90)
    WEBP:                        NO
    PNG:                         build (ver 1.6.19)
    TIFF:                        build (ver 42 - 4.0.2)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)
    GDAL:                        NO

  Video I/O:
    Video for Windows:           NO
    DC1394 1.x:                  NO
    DC1394 2.x:                  NO
    FFMPEG:                      YES (prebuilt binaries)
      codec:                     YES (ver 56.41.100)
      format:                    YES (ver 56.36.101)
      util:                      YES (ver 54.27.100)
      swscale:                   YES (ver 3.1.101)
      resample:                  NO
      gentoo-style:              YES
    GStreamer:                   NO
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    OpenNI2:                     NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    DirectShow:                  YES
    Media Foundation:            NO
    XIMEA:                       NO
    Intel PerC:                  NO

  Parallel framework:            Concurrency

  Other third-party libraries:
    Use IPP:                     NO
    Use IPP Async:               NO
    Use Eigen:                   NO
    Use Cuda:                    NO
    Use OpenCL:                  YES
    Use custom HAL:              NO

  OpenCL:                        <Dynamic loading of OpenCL library>
    Include path:                D:/git/opencv/3rdparty/include/opencl/1.2
    Use AMDFFT:                  NO
    Use AMDBLAS:                 NO

  Python 2:
    Interpreter:                 C:/Python27/python.exe (ver 2.7.11)

  Python 3:
    Interpreter:                 NO

  Python (for build):            C:/Python27/python.exe

  Java:
    ant:                         C:/Program Files/apache-ant/bin/ant.bat (ver 1.9.6)
    JNI:                         C:/Program Files/Java/jdk1.8.0_74/include C:/Program Files/Java/jdk1.8.0_74/include/win32 C:/Program Files/Java/jdk1.8.0_74/include
    Java wrappers:               YES
    Java tests:                  NO

  Matlab:                        NO

  Tests and samples:
    Tests:                       NO
    Performance tests:           YES
    C/C++ Examples:              YES

  Install path:                  D:/opencv-build/install

  cvconfig.h is in:              D:/opencv-build
-----------------------------------------------------------------

这篇关于大礼帽过滤器运行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆