Vision Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
BruceAmmons

Binning Function

Status: New

Binned images are very useful for reducing processing time when you are looking at the entire image.  It would be very useful to have a function that would perform binning on an image to generate a new image.  The binning factor could be anywhere from 2x2 to 32x32 or even larger.  I would be happy with powers of two, but any integer value would be even more useful.  Different values for the X and Y binning would also be useful.  The values could be simply added together and divided by a user specified divisor, much like the filter options.  It would be similar to the existing IMAQ Block Statistics, but the output would be a new image ready for processing.

 

Right now, binning can be accomplished by multiple steps - filtering with the appropriate size filter, then using IMAQ Extract to reduce the size of the image.  This is much slower and less efficient than a single binning function would be, since the filter must be applied to every pixel, instead of just the pixels you are keeping.  It could be done in place on the original image if desired.

 

Bruce

Bruce Ammons
Ammons Engineering
7 Comments
varga.sm
Member

Bruce,

This sounds like IMAQ Resample.  Is there something different?

 

Steve

 

BruceAmmons
Trusted Enthusiast

Resample is used for interpolating the image.  It is fairly slow when you want to reduce the size of an image by integer factors.  For each pixel, it uses interpolation to determine the value of the new pixel from the surrounding pixels.  If you use the lower interpolation functions, you only get the value of a single pixel, instead of combining all the pixels in the block.

 

Binning, on the other hand, simply adds the pixel values in a 2x2 (or NxN) block.  That is a fairly fast operation, if you have direct access to the pixel data.

 

Bruce

Bruce Ammons
Ammons Engineering
GregSands
Active Participant

Yes, kudos from me.  I'm guessing that the output would be the average of the NxN pixels (avoiding overflow in the computation) but perhaps other options would also be useful - median, max/min etc?

X.
Trusted Enthusiast
Trusted Enthusiast

Binning usually returns the sum. The dynamic range of the destination image needs to sufficient to handle the largest sum value.

BB_King
Member

Yes, very much needed to reduce number of data necessary to retain (and at the moment process off line). It would need to be N-dimensional array binning (triplets at least) calculating means. Number of bins in powers of 2^i, where max (i) should be at least 10.

logatto
Member

 

Hi Bruce,


I have the same needs. I need to do a bin 2x2 on an Int16 image. I convert it in Single and then I do the sum 2x2pixels. I do it scanning and indexing the matrix, but it takes sometime. How did you fix it?

Thank you.

BruceAmmons
Trusted Enthusiast

I would use a 2x2 convolution filter with the divisor set to 1, then use IMAQ Extract to remove every other line and row from the image.  It is fairly fast.

 

Bruce

Bruce Ammons
Ammons Engineering