06-15-2015 05:57 PM
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?
06-16-2015 05:05 PM
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.
06-16-2015 05:12 PM
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.
06-17-2015 11:51 AM
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