Running average of images

Anyone know how to do a running average of images? I could convert images to 2-D arrays and stack in a 3-D array. I can't think of a way to add the images once in the 3-D array without a loop that would slow execution speed to a crawl.

This example demonstrates how to use a running average to remove transients from captured images.
1. Set up an acquisition and create a storage buffer, a working buffer for the current image, and a repository for the running average. The running average is a 16-bit buffer to allow for up to 256 8-bit images to be averaged together.
2. Create an array of buffers to hold each of the images being averaged. This array works as a shift register to subtact the oldest image (step 4) and add the newest image (step 6)
3. The calculation determines which index of the array to access. This index is then indexed for use in this iteration of the loop.
4. For each iteration, first subtract the oldest image from the repository. You cannot subtract images that have not been stored, so subtracting occurs on the second iteration of the loop.
5. The newly acquired image is converted to a 16-bit image and stored in the current index of the array.
6. Add the current index to the repository and display the image. 16-bit images are dynamically ranged when displayed so that the image displayed is the average of all images added to the repository. Steps 4, 5, and 6 repeat, subtracting the oldest image and adding the newest image to create a running average.
7. 16-bit images are signed. This step subtracts 2^15 from the repository the first time through the loop and allows access to the entire 16-bits of resolution.
8. This step scales the histograms so that the histogram for 16-bit (average) and 8-bit (current) images cover the same range.
9. Dispose of the buffers and WindDraw windows.
10. This loop calculates the frames per second being handled. Notice the use of notifiers to end this while loop when the main loop ends.
NOTE: You must have IMAQ Vision installed to run this example. The maximum number of buffers used should be no greater than 255 for 8 bit images.
Attachments:
IMAQ_Running_Averaging.vi ‏161 KB

Similar Messages

  • Help with Running Averages and Graphs on Ipad3

    I am new to Mac, slowly learning but quickly falling in love with it.
    I need to keep track of our basketball teams free throw percentages for 5 team and for each kid. The coaches are asking for, made shots, missed shots, total attempts and their percentages and then an running average of their percentages.
    I created a spreadsheet for each team and seperate tabs for each kid (attached image) in Numbers on the ipad which will allow me to add their made and missed shots (=sumB2+C2). It then gives me the total of attempts and then gives me that percentage (=B2/D2) all good here.
    This is now what I am trying to see if I can do, I want to be able to just fill in the blank fields day to day or as they shoot and then have it just update the running average on the bottom without me having to adjust the cells to re-calculate.
    If I select cells E2 to E25 the error comes up Cell "E4" contains an error. I know it is cause no figures are entered in the row yet. Is there away around doing the percentage formula so it just shows blank in the row without the error show it will do the running total or a way to have it calculate the running total even with the error?
    Can I take the overall averages from each kids sheet and creat a graph on a seperate sheet just showing the overall averages?
    If so, will the graph automatically update as I update my numbers or will it have to be created again each time?
    Thanks for all the help.

    1) Welcome
    2) Empty cells return 0 (zero)
    3) anything divided by zero is infinite (and not legal, mathematically speaking)
    so you should wrap your formula in an iferror() function to screen errors out.  For the "Percentage" column you should do something like:
    E2=iferror(B2/D2, "")
    As long as B2/D2 is a valid result the iferror() passes the answer.  If, however, D2 = 0, then iferror() will "catch" the error and return "" this is an empty string.
    Charts do automatically update in Numbers.  I don't actuall have Numbers for an iOS device (you posted to the forum dedicated to Numbers on Mac OS X).
    The iWork for iOS forum is located here:
    https://discussions.apple.com/community/app_store/iwork_for_ios

  • Running average of a 2d array

    Hi,
    I am trying to get a running average but my data is a 2D array. How do you get arunning average of a 2D array. Any suggestions?
    cheers
    lp19

    Convert it to a 1D Array, and then use the existing running average tools. You can convert a 2D array to a 1D array using the "Reshape Array" function. You will need to provide this function a "length" argument, which is calculated a the product of the row-length and column-length of your 2D array. The way that I calculate this is to use the "Muliply Array Elements" function on the "size(s)" output of the "Array Size" function (see the attached image file).
    Good luck,
    -Jim
    Attachments:
    2Dto1D.JPG ‏5 KB

  • How do I create an n-point running average VI?

    I've been programming in sequential written languages like C for many years now. I've been using LabVIEW for the last 4 months and am having problems writing an n-point running average VI. It is really bothering me, because this would be really trivial in C or anything else. But for some reason I can't conceive how I would do this in LabVIEW. I used LabVIEW 5 for the bulk of that time, and we just upgraded to LabVIEW 8 last week so I've been learning it. Wow, some pretty big differences between the two but the gist is the same.
    I have a 5-point running average subVI written that uses a run-once while loop with shift-registers that keep their value between subsequent VI calls. This works for what I need, but have 2 problems I would like to overcome.
    1. I can't have multiple instances of the same subVI in my top-level VI program because the way the shift-registers are keeping their value between subsequent VI calls. I have to make duplicates of the .vi file (i.e., 5_point_running_average.vi, 5_point_running_average_2.vi) in order to keep all the shift registers seperate.
    2. I want it to be an n-point running average. Currently I have to jump into the VI and add another shift register to add another point. I often change my sample rate, and thus being able to have a different averaging window is really handy.
    So the VI takes 2 inputs:
    n - (integer) the number of points to computer the average over.
    in - (real) the current data point.
    output:
    out[i] = (in[i] + in[i-1] + ... + in[i-n-1])/n
    I've also thought about the possibility of needing a 3rd input that is "instance" which might help keep variables within the subVI separated and thus not needing separate duplicate files.
    In case you are wondering, I'm using a running average to make digital HUDs easy to read. The actual data that I'm recording to file will not be going through the running average function, because as you can see by the output function, there will be a phase shift in the output. At high sample rates, the digital displays can be moving very rapidly and that makes them hard to read.
    Other recommendations as to how to make digital displays easy to read to help operators while performing tests? As for instantaneous data smoothing, so to speak. I already make the displays very large if they are critical.
    I'm very interested in this n-point running average solution. I've been scratching my head over it for awhile now and am quite stumped on how to approach this in LabVIEW.
    Help is very much appreciates,
    -nickerbocker

    The atomic operations (delete/insert) MUST do the following:
    When you insert into array, all higher elements need to be moved up one slot, then the element is inserted.
    When you delete from array, the lement needs to be deleted and all higher elements moved down one slot
    Both operations involve an array resizing operation and data shuffling in memory.
    How can LabVIEW be sure that the memory can be re-used? What if your code would delete one, but insert two at each iteration? It might well be that the LabVIEW compiler properly re-uses the memory in your particular case, but there are no guarantees. A five element array is peanuts. so it would probably be difficult to notice a difference.
    You might want to run a benchmark of the different algoritms using a huge buffer.
    "First call?" is defined as followes in the online help:
    First Call? returns TRUE the first time the VI runs after the first top-level caller starts running, such as when the Run button is clicked or the Run VI method executes. If a second top-level caller calls the VI while the first top-level caller is still running, First Call? does not return TRUE a second time.
    It will only be true exactly once during the entire execution of the toplevel VI, only the first time it is called from anywhere.
    LabVIEW Champion . Do more with less code and in less time .

  • Running Average 2D(or more) Array Graphed

    I am really confused on how to plot the running average for my data. I allow the user to say how many data points they want averaged. The user can also collect up to 32 channels of data @ 1000hz.
    I understand averaging a 1D array, but how do I simultaneously plot averages when its a 2D,3D,etc array? By that I mean plot the average value for channel 0 at the same time as channel 1 at the same time as channel 2...
    Any help is appreciated, thanks!
    Lauren

    Lauren,
    It sounds like you would like to extract each channel from the 2D data array so that you can average them simultaniuosly. The best way to do this is by wiring the 2D array to the input of index array function. The funtion will morph to have an input for index(row) and index(col). You can extract one channel of the 2D array by wiring a constant to the column input. The output of this function is then a 1D array that you are used to averaging. Becasue using 32 of these may become cumbersome the function could be placed inside of a loop and the loop iteration could control the row to extract each iteration of the loop. I hope this resource helps!
    Regards,
    Shea C
    Applications Engineering
    NI

  • Running average

    Hi,
    regarding running average I'd like to ask for advice. I have an application where I read analog voltages from a DSO6104a oscilloscope. 1000 samples are taken in a 20 ms Iong window in every two seconds. I want to create a running average in a way that the 1000 data points are taken, averaged and the averaged value is displayed in a chart. I tried to do the following:
    1, read the 1000 data points with the appropriate VI for that oscilloscope
    2. I get the voltage value components and store them into the array
    3. I summarise the content of the array
    4. divide it by 1000.
    This is how I thought it should be but the results are some weird numbers. Can you please advise where it's gone wrong/how to make it better.
    Thanks,
    Krivan
    Attachments:
    runavg.PNG ‏5 KB

    krivan wrote:
    Thanks both of you for the advices! 
    Ermm...I thought that a running average is basically an instantaneous average...what is the real difference?
    There is a difference: http://en.wikipedia.org/wiki/Moving_average.
    What I try to achieve and confused about is that there is an input data stream which is read by the ag6000a single channel VI. It reads 1000 samples in every 2 seconds [wait time in the while loop]. The output of the read VI connects to a waveform chart displaying the actual voltage values but at the same time I would like to average these 1000 data points and put the averaged value into another waveform chart. I think how I've done it - the getComponents+array - is not correct...
    How is it possible to average these 1000 data points and display them in every loop sequence?
    You don't show the rest of the code, but (as has been pointed several times) the Mean VI will give you the average of the array you get from the read . You can wire this value directly to a chart. You mentioned charts, so I assume you know the difference between a chart and a graph? If not, please review the help on graphs and charts and look at the examples that ship with LabVIEW.

  • Running average of histogram

    I am generating a new 1000 point histogram with each iteration of a loop.  I need to figure out the running average at each point in the histogram over 200 iterations without a 200 shift registers.  There are a few posts in this direction, but I can't seem to get the indexing right.  Can someone help me out?  thanks.  Jonathan

    altenbach wrote:
    Note that with a bit more coding there are much smarter ways to do all that ...
    Well, here it does not really matter, because both complete in well under 1ms, but here's a quick implementation of the above idea. Could be useful with larger datasets. We keep the sum of all rows in a second shift register and at each iteration we read the current histogram at that location (the oldest in the history!) before we overwrite it with the newest. Now we add the newest and subtract the oldest from the sum of all histograms and divide by the total number of histograms currently in it.
    I am sure many improvements are possible.
    I have not done any benchmarks.
    Message Edited by altenbach on 03-11-2008 12:39 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    RunningHistogramAverageBetter.png ‏21 KB
    RunningHistogramAverageFaster.vi ‏28 KB

  • Need an object or function to compute a Running Average

    Each minute, I must compute the average of the 180 most recent values for a parameter, each of which was computed at one-minute intervals from current measurements. Referred to as a 3-hour Running Average, this is commonly used with environmental measurements. Other (shorter) time periods are also used. Some of the one-minute values are themselves averages of the values sampled during the minute, some are the maximum or minimum value found during the minute.
    Any suggestions of how to do it within Lookout?

    Greetings,
    From what you have described, it sounds as if you need more of a rolling average instead of a running average. Unfortunately we don't have an object to direct accomplish this for you, and it is a little more difficult when you key in the fact that you need to average 180 elements. In order to implement this though, it will take a little time and effort to utilize a combination of objects and expressions. Two methods come to mind:
    1. Use a Sequencer object to multiplex through 6 different Sample objects. You know that the averages occur once a minute so you can set up your Sequencer to write a average to a Sample object, then transition to the next state and write the next average to the next Sample object and so forth. Then create an express
    ion that adds up the first 30 elements of the 6 sample objects and divide by 180.
    2. Daisy-chain 6 Sample objects together. You could use 5 expressions to write the 35th element of 1 Sample object to the 1st element of the next Sample object. Then create an expression that adds up the 35 elements of the first 5 Sample objects and the first 5 elements of the 6th, then divide by 180.
    Hope this helps.
    Patrick R.

  • Running Average of a 2D array element-wi​se

    Hello all,
    I am having trouble approaching this problem. I have a sub-VI which outputs a 2D-array for each iteration of a while-loop. This is spectroscopic data set where the first column is the time value and the next 32 columns are intensities from the array detector. RIght now I am fine with just figuring out how to solve my problem with only two columns. 
    Anyways, I want to be able to save the array between iterations ( which I am implementing a shift register for) and then average the next array with the previous saved array. Since all my time points will be equivalent in between iterations (the sub-VI creates a special time axis), I want to do a straight running average where each element is averaged with the previous corresponding element in the array. 
    What would be the best way to approach this part? Should I just do a build array and at the end somehow iteratively average together all of the appended arrays? I figure that would take way too long compared to a running average though. 
    Thank you for your help. I can clarify further if anything seems unclear. 

    Try using index array for elemenet by element averaging for both the arrays. You dont need buid array anyways.
    One more question, if some points are same then do averaging of those elements which are not equal or expected to be different.
    Do you have any sample data. It will be great if i have some data on which operation needs to be performed.
    Kudos are always welcome if you got solution to some extent.
    I need my difficulties because they are necessary to enjoy my success.
    --Ranjeet

  • Resetable, Adjustable, Running Average

    I have a loop that is spitting out a single number each time.  I need to be able to take a running average of the value.  That is easy with a while loop and shift registers but what I need is to be able to reset it and also change the number of averages.  So when the operator says he wants some unknown amount of averaging the loop starts and with each iteration it gives me an output of the average so far and then when the full number of averages is reached it resets and starts again.

    mikeporter wrote:
    Isn't there a pt-by-pt VI that does exactly this?
    Mike...
    Like Mean PtByPt?
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Run Oracle VM images on Citrix Xen

    Maybe here someone know how to answer for my question:
    Re: Run Oracle VM images on Citrix Xen

    Could you send me a link, how to do such things? I tried yesterday, but nothing happened. Is there any checkbox to set compatibility or something like that?

  • Multichannel running average

    Dea all,
    I am looking for a multi channel running average function (or VI) that i can adjust to an arbitrary but fixed number of channels.
    I attached an example of a 5 channel running average which technically does the job. however, scaling it to bigger numbers of channels (lets say, 50) is surely not good practice. do you have any suggestions?
    Thank you!
    and by the way, what change does this VI need so I could adjust the sample length while running the VI?
    Solved!
    Go to Solution.
    Attachments:
    running avg multichannel.vi ‏16 KB

    I made my own multi channel running average, based on what i found in the PtByPt mean VI as suggested by GerdW, but with the matrix multiplication. It has not all the functionality as the original PtByPt, but it works like a charmfor an arbitrary number of parallel channels and sample length. I attached also the runAxB.vi that feeds a random input and provides a graph of original and averaged data.
    still, could i change the sample length while running the VI?
    Attachments:
    AxB.vi ‏24 KB
    runAxB.vi ‏21 KB

  • Running average or median of images from Gige vision camera

    Hi all,
    I have a Gige Vision camera(baselar's) I want to continously grab the images (video) and output the Average or median of the frames(10 frames atelast). My camera setting and pixels hieght widht are mono 8 and width and height are 1000. I tried to get the average in simple adding and division but was unsuccesfull in getting the final images can any one check where I can be wrong , attached is my vi.
    thanks
    Attachments:
    average image.vi ‏53 KB

    MoviJOHN wrote:
    That's easy.  I don't even need to see your code to tell you what you're doing wrong.  You are probably storing your data as 8-Bit unsigned, taking ten images and adding them together.  The problem is that the largest value U8 can hold is 255, so you run out of space for the numbers to increase.
    Grab the U8 image, cast it to a SGL, and convert image to array.  Then add the previous array to the current array in a for loop, and divide by the total images.  You can either display the image as a SGL, or cast it to some other type for saving to disk, since SGL is not supported in any common image file format.
    Hi MoviJohn,
    I tried putting imaq cast after imaqdx get image and giving the output of cast image to image to array, but it didnt work, i dont se the images at all.
    Attachments:
    average image.vi ‏54 KB

  • Leopard, can it run without core image?

    well i got an ibook g4 from my friend and i bought leopard disk new from ebay it was boxed and all well anyways i want to install leopard on my ibook which is running 10.4.11
    the specs are
    1.7 ghz
    786 ram
    60 gb hard drive
    my question is that i think that the ibook doesnt support Core image, can i install it on the ibook cuz im thinking of doing a clean install since its neww any thoughts??

    Requirements for OS X 10.5
    http://support.apple.com/kb/HT3759?viewlocale=en_US

  • IDVD6 Buffer under-run through View Image

    Higtherto a fair run with iDVD6 but suddenly, no matter what I've tried, when I eventually have run through the creation in iDVD then saved to Image View the complete disc build carries right through to the end then closes with the box message tellingme it has failed through buffer under-run. A waste of approximately 11 hours.
    I'm employing OSX.3.9 for the job with my undermentioned spec. The film is a holiiday one of 58 mins 30 secs, and I'm working in PAL with a Pioneer 109 and -R disc.
    Maybe I should know what is buffer under-run and maybe it's something I'm doing along the line but I haven't a clue.....
    Help required here, people - with thanks.

    Apologies - read it as 'when burning from' and confirm that I get as far as having already saved as Disk Image.
    I've a number of times gone over the lengthy process of saving from FCP through FCP Movie then iDVD to Disk Image followed by spasmodic print results to disks during this present difficulty. Last night I had one result from Toast 6 and another result from Disk Utility followed by a string of complete failures in the way I have already reported - that fatal "The drive drained its buffer without underrun protection."
    I've used Disk Warrior's Optimiser to optimise both my HDs which showed a noticeable difference to the storage graphs. Turned the computer off and on again. Resaved the film in the way described. Gone through the process with Toast and Disk Utillity, and produced one good disk from each. All followiing attempts have ended in failures as described and those attempts have included switching off and on again, not just restarting. My startup disk has 42gb free space and the storage disk containing the edited material has 47gb free space.
    So yes - the problem shows from the Disk Image starting point. When I got a result from Toast 6 followed by another one from Disk Utility I thought I'd cracked it. Maybe there's a clue in noting that the failures occurred again after once more using Disk Utility.
    Thanks again for your interest.

Maybe you are looking for

  • Regarding mid year go-live

    Dear Gurus, i am new to midyear glive. i have gone through the threads on it n i got some idea.. but i have the following doubts: 1. when should i upload the data n run inlk schema? before golive or after go live?? 2. if after golive, whether it shou

  • JNI Multithreading/Callback Function Design Issues

    Ok, I have been working on this for quite some time now and I simply can not figure it out. So any ideas are more than welcome. :) I have Java code that uses a DLL that I created in C++. My C++ code links with a library made by a 3rd party (don't hav

  • Which adapter do I buy?

    I need to buy a new adapter for my MacBook Air 13,3". Information about my laptop: has serial number C0******JWT (mid 2011), processor 1,7 GHz Intel Core i5. I need to buy a new MagSafe Power adapter. The one I used until now was 45w. Please help me.

  • Premiere CC - cloud says it's installed but it's not

    Hi! My windows 8.1 pc had a hardware issue so had to go back in time via recovery. Have to reinstall premiere pro cc because it was not installed at that time. When logging in to the cloud it says it's installed but in fact it's not.  Also nothing in

  • Problemas al grabar en adobe audición cs6

    @Mi problema es el siguiente coloco la instrumental en el primer track grabo la voz en el segundo y al querer hacer a pollos o marcaciones de frases que quiero que se destaquen en el tercer track estas se desfazan no tengo problemas de latencia en el