LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuously Averaging 2D Array

Solved!
Go to solution
I'm taking an image with a CCD camera and converting it to a 2D array.  I want to be able to continuously take data and in the end average together 50 samples.  This is my first LabVIEW project and I really have no idea what I'm doing.  Any help would be greatly appreciated!
0 Kudos
Message 1 of 8
(3,452 Views)

Do you want to take the average of each pixel over the 50 images?  Do you need any of the original images after you have done the averaging?

 

If the answers are yes and no, respectively, put the 2D array in a shift register.  Initialize it to all zeros.  After each image acquisition add the current values to the values in the shift register.  After all acquisitions divide the array by the number of acquisitions.  This will work well and is very simple, provided that the sum cannot overflow the datatype you are using for the array.  If you are using color, it may be necessary to make 3 separate arrays for the red, green, and blue components.

 

Lynn 

0 Kudos
Message 2 of 8
(3,447 Views)
The answers are yes and no, but I think that's what I've tried.  Maybe it'll help if I attach what I've got. 🙂
0 Kudos
Message 3 of 8
(3,440 Views)
The shift register needs to be in the while loop. Get rid of the FOR loop (it only sums 50 copies of the same image with each iteration of the while loop.)
0 Kudos
Message 4 of 8
(3,433 Views)
I've tried that too, and it doesn't work unfortunately.  Something about putting the add function in there messes everything up. 😕
0 Kudos
Message 5 of 8
(3,421 Views)
Solution
Accepted by topic author eccolabionda

And initialize the array to the size of your image.

 

For the summing array you need to convert to a datatype which will hold larger values than the 0..255 of a U8.  By the time you have summed 50 iterations you may have exceeded 255 on some pixels.

 

You are also not doing any averaging.  The image shows dividing by Number of Images to get the averaged pixels before you save.   I do not have the IMAQ VIs so they show up with the gray question marks.

 

Lynn 

LVISmirrorviewer3.png
Message 6 of 8
(3,411 Views)

I don't have IMAQ, so here's a quick example using a simulated random 2D array.

 

Of course you only need to update the image at N=50.

 

(Another possibility would be to place the image acq inside your N=50 inner FOR loop).

 

 

Message 7 of 8
(3,401 Views)
Works like a charm!  Thank you so much!
0 Kudos
Message 8 of 8
(3,374 Views)