0

I have to perform Intra predicted coding on a video frame and calculate its PSNR. I am now asked to take the same original frame and encode it which consists of performing DCT, quantization, dequantization and inverse DCT. I have to calculate the PSNR of the encoded frame and compare it with the intra predicted frame.

I got the values of 53.37 db for the intra predicted frame and 32.64 db for the encoded frame. I am supposed to analyze the probability distribution of the encoded image using the histogram. Histogram for both frames look extremely similar so what am I actually supposed to look for?

EDIT

The way I am calculating the PSNR is taking the difference between the original frame and the reconstructed frame and then using the PSNR formula. Code snippet shown below:

errorFrame = orgFrame - reconstFrame;    
y = 10*log10(255*255/mean(mean((errorFrame.^2))));

Should the PSNR of the intra predicted frame and the reconstructed frame be the same value? I have uploaded the histogram of the reconstructed frame with intra prediction and reconstructed frame without intra prediction

enter image description here

The histrograms look extremely similar so why is the PSNR value so different?

David Norman
  • 301
  • 2
  • 10
  • 18
  • Please post both images here so I can calculate it on my end to compare. Also, are you sure you are calculating the PSNR right? Place how you're calculating the PSNR here as well. Also, as a reference, here's [a nice way on how to calculate it](http://stackoverflow.com/questions/25479897/deblurring-motion-blurred-images-in-matlab) – rayryeng Sep 06 '14 at 15:24
  • @rayryeng, I have edited my question and added PSNR code and a histogram – David Norman Sep 06 '14 at 20:49
  • Can you post the original frames as well, not just the histograms? I'd like to verify your PSNR. In addition, I suspect that it's that spike at around intensity 80 or so that could be driving the PSNR to be different. – rayryeng Sep 06 '14 at 23:37
  • @rayryeng, do I just add the frames I am working with? – David Norman Sep 07 '14 at 03:08
  • @rayryeng, I've added three frames, original one, non intra predicted frame and the intra predicted frame – David Norman Sep 07 '14 at 03:18
  • This is good. Thanks. Just to be clear, you are calculating two PSNR quantities: One with the original and intra, and the other one with the original and no intra, right? The one with no-intra looks like it has prediction block errors, so that's one reason why the PSNR is quite different between them. – rayryeng Sep 07 '14 at 03:32
  • @rayryeng, Yes and I have to compare. I don't understand why they have different PSNR values yet very similar histograms – David Norman Sep 07 '14 at 03:34
  • The PSNR does a point-by-point comparison between two images. The histograms capture the entire distribution of intensities as a whole. For example, if you had an image that was `A = [0 255; 255 0];` and another that was `B = [255 0; 0 255];`, and let's say original image was `C = [0 128; 128 0];`. Even though the histograms between `A` and `B` are the same, the PSNRs are `9.0650` and `2.0344` respectively. As such, I wouldn't rely on the histograms themselves as they only capture global information. Look at it locally. You can obviously see one has higher quality than the other. – rayryeng Sep 07 '14 at 03:41
  • You can see that `A` and `C` are similar in that one is simply the grayer version of the other. However, `B` is way off as it has white pixels where there are dark pixels in `C`, and dark pixels when there are gray pixels in `C`. Though the histograms between `A` and `B` are the same, the actual content between them are quite different compared to `C`. – rayryeng Sep 07 '14 at 03:43
  • @rayryeng, that is very true. If you look at the physical appearance of the images, there is a considerable quality difference. I have to analyze the probability distribution of the non intra predicted frame – David Norman Sep 07 '14 at 03:44
  • This question may have been asked on purpose. Though you can see the distribution of intensities is relatively the same, if you analyze local image patches between the two, you can definitely see that one is a lower quality than the other. To be honest, and recounting from personal experience, you should take PSNR with a grain of salt. Just because one image has a higher PSNR than the other doesn't necessarily mean that it is better quality. In fact, there have been images where they were lower PSNR, but I considered them to be better quality than one with higher PSNR. – rayryeng Sep 07 '14 at 03:45
  • @rayryeng, But what am I supposed to say in terms of probability distribution considering the histograms are nearly identical, although the quality is quite different – David Norman Sep 07 '14 at 03:47
  • Just write in exactly what I just said :) Make sure you reference what I said about histograms being a global measure. Most of the bins of the histograms look equal, but histograms are **not spatially aware**. You could have, say, 15 pixels having intensity 80 for both images, but they could be in completely different locations in each of the images. Give the example that I gave above with the different PSNRs calculated too. – rayryeng Sep 07 '14 at 03:55
  • My pleasure. Do you mind if I write an answer, and could you accept? – rayryeng Sep 07 '14 at 03:57
  • @rayryeng, i was just about to say that. Just make that as an answer so I can vote and accept it – David Norman Sep 07 '14 at 03:58
  • Beautiful. Give me one moment. – rayryeng Sep 07 '14 at 03:58

1 Answers1

1

The PSNR does a point-by-point comparison between two images. The histograms capture the entire distribution of intensities as a whole. For example, if you had an image that was:

A = [0 255;
     255 0]; 

... and another that was:

B = [255 0; 
     0 255];

... and let's say original image was

C = [0 128; 
    128 0];. 

Even though the histograms between A and B are the same, the PSNRs are 9.0650 and 2.0344 dB respectively. As such, I wouldn't rely on the histograms themselves as they only capture global information. Look at it locally. You can obviously see one has higher quality than the other. In your histograms, though most of the bins of the histograms look equal, but histograms are not spatially aware. In other words, the spatial relationships of pixels are not captured in histograms, as you have seen with my example I gave above. You could have, say, 15 pixels having intensity 80 for both images, but they could be in completely different locations in each of the images. As such, you could have a completely different looking image in comparison to another, but if you counted the amount of pixels per intensity, as long as the counts per intensity are equal, the histograms will be equal.

You can see that A and C are similar in that one is simply the grayer version of the other. However, B is way off as it has white pixels where there are dark pixels in C, and dark pixels when there are gray pixels in C. Though the histograms between A and B are the same, the actual content between them are quite different compared to C.

I do realize that you need to compare the histograms / probability distributions between both of the images, but this question may have been asked on purpose. Though you can see the distribution of intensities is relatively the same, if you analyze local image patches between the two, you can definitely see that one is a lower quality than the other. To be honest, and recounting from personal experience, you should take PSNR with a grain of salt. Just because one image has a higher PSNR than the other doesn't necessarily mean that it is better quality. In fact, there have been images where they were lower PSNR, but I considered them to be better quality than one with higher PSNR.

As such, when you answer your question, make sure you reference everything that I've said here.

tl;dr: Though the histograms look equal, histograms are not spatially aware. The spatial relationships of pixels are not captured in histograms. As such, you could have a completely different looking image in comparison to another, but if you counted the amount of pixels per intensity, as long as the counts per intensity are equal, the histograms will be equal. Even with the histograms being unequal, doing PSNR does a point-by-point difference, and this (sort of) captures the spatial relationships of pixels and thus explains why the PSNRs are quite different.

rayryeng
  • 102,964
  • 22
  • 184
  • 193