danielgtaylor / jpeg-archive

Utilities for archiving JPEGs for long term storage.
1.17k stars 121 forks source link

Bug in ssim calculation? #125

Closed ankuPRK closed 3 years ago

ankuPRK commented 3 years ago

The _iqa_convolve function doesn't output the same size array after convolution, it rather outputs a (w-kernelsize/2, h-kernelsize/2) image when a kernel of size (kernelsize, kernelsize) is convolved with an image of size (w,h). So:

https://github.com/danielgtaylor/jpeg-archive/blob/5b56afa11872fc4b9f68c5a3dcf2ec5afe869504/src/iqa/source/ssim.c#L197 ^this rewrites an output of (w-kernelsize/2, h-kernelsize/2) in a buffer size of (w, h)?

And then we use the full buffer to calculate average SSIM: https://github.com/danielgtaylor/jpeg-archive/blob/5b56afa11872fc4b9f68c5a3dcf2ec5afe869504/src/iqa/source/ssim.c#L214

^Woudn't this calculate wrong SSIM?

ankuPRK commented 3 years ago

Okay got it h,w get updated later here: https://github.com/danielgtaylor/jpeg-archive/blob/5b56afa11872fc4b9f68c5a3dcf2ec5afe869504/src/iqa/source/ssim.c#L199