LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

IMAQ Resample performance. Any better choice for 50% downsample? (average 2x2 -> 1 pixel)

My video source is a 4 Mpixel (2k x 2k resolution) USB3 camera. This is displaying a live image OK in Labview at 45 fps using only 20% CPU.  So far, so good.

 

I added a "IMAQ Resample" block to downsize this to 1024 x 1024 image. That works with almost no additional processing time if I select "Zero Order" interpolation (eg. plain subsample to value of nearest pixel). However, I want to average each 2x2 block (4 pixels) in the input image into 1 output pixel. I *think* that is the effect of selecting Bi-Linear interpolation. Doing that works, but takes about 45% of CPU.  I want to do some other processing but am worried I will quickly run out of CPU time and start dropping frames.

 

Is there any better way to do this simple 50% downsize (2x2 average), that would take less CPU overhead, or is this the best way?

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

Hi jbeale1,

 

In NI-MAX (Measurement & Automation Explorer) select your camera. Under the  'Acquistion Attributes' tab do you see an option to change the Video Mode of your camera to a different resolution? If your camera supports it, it would be more efficient to change the resolution there.

 

If not , here is a little more info regarding the IMAQ Resample VI:

http://zone.ni.com/reference/en-XX/help/370281P-01/imaqvision/imaq_resample/

 

You are correct, the Bi-Linear option uses a more intensive interpolation technique which is why it is more taxing on your CPU. I hope this is helpful.

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

Hi Robert,

 

Thank you for your reply. In NI MAX I can set a sub-window on the sensor, but I need to use the full field of view. There is no option to rescale the output, and no option to use pixel binning.

 

I was hoping that the 2x2 average -> 1 pixel downsample for exactly 50% output was a special case that might have a faster solution than the general-purpose bilinear algorithm that handles any scaling ratio.

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

Without binning, the simplest solution is IMAQ Extract, which has inputs for X and Y step size.  A step size of 2 will give you every other pixel.

 

If you really, really need binning instead, you can use a convolution filter with a 2x2 array of 1s, padded to 3x3 with zeroes.  Follow this with IMAQ Extract as before.

 

It would be helpful if NI had a binning function built in.  I have had numerous projects where it would be useful.

 

Bruce

Bruce Ammons
Ammons Engineering
Message 4 of 4
(3,113 Views)