Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Average of multiple images

Hello,
 
I was wondering if there is a convenient way to determine the average of multiple (e.g. 100) images using IMAQ Vision. It is simple to find the average of two images using the Average function. To find the average of multiple images it would be ideal to add all the images together and divide by the total number. However, if I add together too many images, I exceed the maximum intensity in the image object. On the other hand, if I divide by each image by the number of images first, then I lose much of my resolution. I would greatly appreciate any suggestions that you may have for getting around this problem.
 
Naveen
0 Kudos
Message 1 of 7
(5,692 Views)

Convert your images to a different numeric base before averaging them.  Converting U8 to I16 will allow you to add together 256 images (or more) without any loss.  Converting to DBL should give you all the precision you need.

It might be faster to convert the images to arrays, combine the arrays, divide, then convert back to an image.  In this case, you could convert to U32 for the calculations.

You definitely want to add the images together before dividing so you don't lose significant digits.  The only case where it wouldn't matter is when the image is in DBL format.

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 7
(5,665 Views)
Thanks for the excellent suggestion. That solved the problem.

Naveen
0 Kudos
Message 3 of 7
(5,627 Views)

Hi Naveen,

Would it be possible to post your solution?  I'm new to LabVIEW IMAQ and unsure of how to allocate buffers for this type of situation.  Are you allocating a new buffer for each image, or looping through grabbing images and putting them in the same buffer after the previous image is already inputted into an array?  Or are you doing something completely different?  I'm generally unsure about how to use buffers, so if you know of any good examples or text, that would be helpful as well.  We're interested in doing something similar -- averaging many images -- and then we'll be analyzing them using a subvi that is already ready to go. 

Thank you!

0 Kudos
Message 4 of 7
(4,926 Views)

Due to the age of this forum post, it's not likely we'll get Naveen's exact implementation.  I have come up with a basic application that would show how to approximately do this.  Hopefully it helps point you in the right direction!

 

imaqarray2.png

0 Kudos
Message 5 of 7
(4,912 Views)

Th0r has nearly got it right, although don't try it like this with RGB (U32) images - if you do want to average color images, you'll need to extract and average the R,G and B planes separately.

 

If you want to average Greyscale images, then the easiest approach is to use SGL (or I16) images, and you don't even need to convert to arrays to do the averaging.  On the first iteration, you just need to copy the image into the Sum image.

 

ImageAverage.png

Message 6 of 7
(4,907 Views)

That's a good point!  The code I posted would best be used for images that are 8 or 16 bits.

0 Kudos
Message 7 of 7
(4,888 Views)