how to make running average of 5 frames of video?
I’d like to calculate a running average of the last 5 frames of video from a live stream, in order to control noise.
I’ve looked at jit.slide (and it’s shader cousin), it seems to mostly do what I need, but I really don’t understand the two parameters and what they do.
maybe [jit.op @op +]
send the first frame through the jit.op, then the output wraps back around to the right inlet. next frame comes through, gets added, wraps back around again, repeat. After 5, bang out the stored matrix into [jit.op @op * @val 0.2] to take the average. However, you’ll go over the maximum matrix values in a lot of places, so I’m not sure about the method…
maybe jit.matrixset could also be used, but it would be more clunky probably. jit.3m? Possibly you’ll need to calculate the average using every frame instead of sets of 5.
Depending on what you want, jit.slide might "shmorph" something close enough to an "average", and will work fine.
Jit.slide could probably produce accurate enough results, as you can only deal with very small amounts of noise this way anyway. Slide_up and slide_down specify the amount of frames it would take to fully get to an input image if you were to input it that many times (which will normally never happen). That sounds tricky, but if you have a slide of 30 that means when you input a frame, only 1/30 of the difference between the current image and the input is added to the current frame.
But you could also make a buffer of 5 frames (5 matrices), each multiplied by .2 and add together. Use a counter to rotate through them with a gate (or [jit.cycle]). There may be an easier way, I can’t think of it now.
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 840.3oc0XtsbaCBDF9Z6mBFcYqaF.A5PuJ84nSlLxVTGxnCNR3DmlIu6U.Ro NsVRDIaJcxXoX.K92O1kcQurbg25xCrZOvWAeGrXwKKWrP0jrgEseegWdxgM YI0pg4Uvdpb88dqzcIXGDplumKtZyyaxX.ZWe+nrPTjjyT8+sJdRVWO6RDat iWr81J1FgdxwAAWAWAvnH4snfqnq.x+GbS6ugmpdNMy8WvwcOnh847hLlPIM zQyaM+mp4EAadbuM1x8htAGz1ptIwy6XZc34s5De.2HG8qKWJurxPRIQxtm3 EokOMfgihTVLITa+vP4MD0uGSObPS+81HdPabR1z.q9k6.W274ySZ4uiB9X4 s.hBB8s7GbRFf+HK+8hlFK417DQE+PKj5zbEqlUHRD7xhi0cbrTpTHUdC1dw oPKFpXJQ6YMBZotCZw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