Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Speed optimization of convolution

In my quest for optimization I have looked at convolution in matlab. There is a complete function "conv2(matrix,kernel,'same')" that does exactly what imaq convolute does. This works a lot slower than labview however - congratulations ni, you are faster at matrices than matlab!!!

There is one thing though. The convolution should be much faster if the matrix consists of many zeros - a zero basically means that a convolution "around" that specific element is not needed. This is clearly seen in the computation time in matlab where the convolution time is greatly reduced when many elements are zero (at least a factor of 2).
In Labview however the imaq convolute takes the same time no matter what image runs through - even if it is an image of only zeros!
I would therefore expect that a the convolution i labview could be greatly optimized by taking advantage of elements with value zero.

In my images of size 575*575 = 330,625 pixels, there are usually 100 particles, taking up about 10,000 pixels. The remaining 320,000 pixels usually have values below 5 (on a U8 image), a value that come from random noise. That noise I can easily remove by applying a threshold. As you can see im greatly interested in a vi that uses this advantage in a convolution.

So my question is: is there a vi that can take advantage of zeros in the input matrix, or is it possible to modify the convolute vi?

Thanks

Simon

0 Kudos
Message 1 of 4
(3,528 Views)

Its looks very basic part in any MegaSize convolution algorithm to ignore 0's.

Joining to ur question.

 

0 Kudos
Message 2 of 4
(3,514 Views)

Anyone?

 

0 Kudos
Message 3 of 4
(3,465 Views)

Hi,

There is no secret way to get the convolution function to be faster.  If you needs a faster convolution function right now, you can use the VIs provided with NI Vision that allow you to transfer the pointer to an image into external code (C, VB, etc.).  Then you can create your own algorithm to do the convolution.

You can't modify the convolute .vi, because I'm sure you know, that it's calling NIVision.dll, you can't change the functions there.

Best Regards

 

-----------------------------------------------------
Dennis Morini
District Sales Manager
National Instruments Denmark
http://www.ni.com/ask
0 Kudos
Message 4 of 4
(3,446 Views)