fsphil / fswebcam

A neat and simple webcam app
http://www.sanslogic.co.uk/fswebcam/
GNU General Public License v2.0
416 stars 87 forks source link

Floating point vs Integer Math #49

Open rtlprmft opened 4 years ago

rtlprmft commented 4 years ago

You are using integer math in summing frames to increase processing speed. Integer math has the advantage that it can keep the high precision of floating point values even though you use integers. But then (e.g. when adding YUYV images), you artificially reduce the precision of your result to 8bit before you sum (average) your frames. You would get a much better result if you first summed them and later clip them. I have produced a version of the code which uses 16bit integer precision combined with 32bit buffers to achieve a better image quality when adding images that internally are anyways available in 16bit precision.