integralFilter() vs. conv2() speed

2 views (last 30 days)
Fabio
Fabio on 14 Dec 2013
Edited: Fabio on 14 Dec 2013
Hi, I'm using the integralFilter() matlab function in an algorithm for image processing. I choose to use this function because we read that is more fast than a commonly convolution and it has the same speed for different filter size. I try to do a little test to see the speed difference between the two function conv2() and integralFilter() but the result doesn't respect what we aspect. The convolution was compute in approximately 0.3 sec and the integlarFilter in approximately 3 sec, but is not all! I try the same test with more biggest image size and/or more biggest filter size and the result shows that the conv2() doesn't change his speed significatly, instead the integralFilter() speed grown very much. Example: for a 4980x2124 image size, the convolution takes approximately 0.7 sec and the integralFilter takes something like 90 seconds! I open this question because the algorithm have to work more fast that is possible, and i need to completly understand what's the more convenient function to use. Maybe I'll be wrong something in the use of the integralFilter() function. This is the code I use for the test:
% conv2()
I=imread('moon.tif');
gx9b=[0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0;
1 1 1 -2 -2 -2 1 1 1;
1 1 1 -2 -2 -2 1 1 1;
1 1 1 -2 -2 -2 1 1 1;
1 1 1 -2 -2 -2 1 1 1;
1 1 1 -2 -2 -2 1 1 1;
0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0;];
tic
yb=conv2(I,gx9b);
toc
% IntegralFunction()
i=integralImage(I);
gx9=integralKernel([1 1 9 2; 1 3 3 5; 4 3 3 5; 7 3 3 5; 1 8 9 2], [0, 1, -2, 1, 0]);
tic
y=integralFilter(i,gx9);
toc
I hope that you can resolve me this doubt. Thanks in advance for your reply.
Sincerly, Fabio Bigi
  2 Comments
Matt J
Matt J on 14 Dec 2013
Edited: Matt J on 14 Dec 2013
I don't have the Computer Vision Toolbox, so I can't repeat your test. Does it help if you re-express your integral kernel with overlapping, and hence fewer, boxes:
gx9=integralKernel([1 1 9 9; 1 3 9 5; 4 3 3 5], [0, 1, -3])
Fabio
Fabio on 14 Dec 2013
Yes I had already try it, but doesn't improve performance.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 14 Dec 2013
I never heard of integralFilter. It's not in the Image Processing Toolbox. Did you get it off the File Exchange?
You can try imfilter(). I heard the developer say that its speed and efficiency have been vastly improved (a few years ago) and that it could be faster than conv2(), though you can certainly test that yourself.
  1 Comment
Fabio
Fabio on 14 Dec 2013
It is in Computer Vision System toolbox http://www.mathworks.it/it/help/vision/ref/integralfilter.html I will try imfilter() as soon as possible.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!