Hi, 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. 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:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.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(3,3));
morphologyEx(src,dst,MORPH_TOPHAT,element,Point(-1,-1));
double elapsed=((double)getTickCount()-t0)/getTickFrequency();
cout<<elapsed<<"second"<<"\n";
imshow("src",src);
imshow("dst",dst);
waitKey(0);
return -1;
}
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?