# AccumulateWeighted generate brighter and brighter image

Newbie, using OpenCVSharp, seems to work ok. Trying to generate an average of images but result is just brighter each iteration and ends up totally white. Some hints?

edit retag close merge delete

What weight are you using?

( 2018-05-24 18:38:01 -0500 )edit

0.5 But I tried with many numbers, trend is same whatever number,

Probably I misunderstand the function, I thought using this function creates an "average" of the images. My images are more-or-less static (except noise) and I thought I would end up with an image which looks (visually) similar to the source images.

( 2018-05-25 01:34:10 -0500 )edit

make sure, the sum of your weights is exactly 1.0

( 2018-05-26 02:44:27 -0500 )edit

As I said, I am a newbie, what do you mean by (plural) weights? and thereby sum? I can only see the alpha argument.

( 2018-05-26 02:51:12 -0500 )edit

apologies, strike that, i confused it with addWeighted()

(which, btw, might be the alternative you're looking for (since it keeps the "energy" constant) ;)

let me try to rephrase it:

accumulateWeighted() makes most sense for a finite number of accumulation steps, and alpha should be 1/N in this case, then you end up with the "correct" result.

if you do this infinitely, your image will be darker for n < 1/alpha and brighter for n > 1/alpha, this is unavoidable.

( 2018-05-26 03:14:43 -0500 )edit
1

accumulateWeighted is for a running average sort of thing. If you just use 1/N as your alpha, you don't actually get an average. For example if N is 10, then the first image would end up being 1/3rd of your output. The equation for accumulateWeighted is dst = (1-alpha)dst + (alpha)src. So the total shouldn't get any brighter than the brightest pixel in either of the images.

( 2018-05-26 10:56:44 -0500 )edit

ugg, wrong again, then ;(

thanks for the clarification !

( 2018-05-26 11:02:25 -0500 )edit

I have (at the moment) a finite set of images (jpegs), approx. 66 files, more or less static (only static background, but of course some noise). After the first accumulation the result is already almost white (plus just a few mesh-like lines, even if weight is only 0.01

( 2018-05-26 11:18:21 -0500 )edit

Try just adding them together and dividing by the number of images. And remember that since you're doing this as a CV_32F, when you do imshow it displays the range between 0 and 1, not 0 and 255.

( 2018-05-26 12:02:07 -0500 )edit

Sort by ยป oldest newest most voted

Well, it shouldn't be constantly growing in intensity, so you probably have a problem. I checked, and it's working in the current version of OpenCV. I suspect this is a problem with OpenCVSharp, which we have nothing to do with. Try asking on their forum.

more

Thanks, I will try to find OpenCVSharp forum and post there instead. As a C# developer using Visual Studio 2017 I am simply too spoiled to start using C++ or python or similar, far too much installation stuff, configuration, include etc etc. just to find that nothing works. .Net works right away and I don't really beleive there is a problem with the wrappers (OpenCVSharp), but of course, maybe...

( 2018-05-26 11:12:11 -0500 )edit

Official site

GitHub

Wiki

Documentation