Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

calculating RMSE and PSNR for color images

621 views
Skip to first unread message

jay...@yahoo.com

unread,
Jul 20, 2006, 11:21:26 AM7/20/06
to
Hi,
i am working on color images by separating the 3 color plane into RGB
or YCbCr color spaces and combine them back after Processing. I work on
Matlab 6.5 . I need to find the RMSE and PSNR of the resultant images.
I have taken RMSE for individual component planes. can anybody tell me
how to Calculate RMSE for color image using RMSE values of individual
color planes?
I also need some pointers on issues/problems in extending grayscale
algorithms for color images. Any help will be greatly appreciated.
Regards
Jaya

Nils

unread,
Jul 20, 2006, 5:14:49 PM7/20/06
to
Hi Jaya,

> I have taken RMSE for individual component planes. can anybody tell me
> how to Calculate RMSE for color image using RMSE values of individual
> color planes?

For MSE you can just take the average of the 3.

MSE=1/(N*M) * Sum_{i,j} (x_{i,j}-y_{i,j})^2 for x,y NxM images

The square also holds for vectors, in this case representing the dotproduct.
So it represents the square of the *length* from original point to sample
point.

If you've already calculated the MSE of the 3 individual channels, you can
simply calculate the resulting MSE as the sum of them.

Next, PSNR is defined as:

PSNR = 10*log_10(peak^2/MSE)

peak^2 here (for 256 level images, 3 channels), would represent 256^2 * 3,
also using the dotproduct.

PSNR is a good objective way of quantifying lossy compression losses,
however, many people have remarked that it doesn't correlate well with
visually perceived quality. Nevertheless it's a good method for comparing
efficiency of compression codecs that "behave the same".

> I also need some pointers on issues/problems in extending grayscale
> algorithms for color images. Any help will be greatly appreciated.

There are basically two types of colour images:
- Indexed (palette-based)
- separate colour maps per channel

Indexed colours can work well for lossless compression (e.g. PNG can use
them), but are usually a hindrance when doing lossy compression. I guess you
do the latter, why else would you need PSNR :)

For natural images, there's always some correlation between the R, G and B
planes. Typically, this is exploited by lossy compressors, by converting
them to something like YCbCr, the Y component taking most of the contrast,
and the Cr/Cb components having much less dense colour info. You can
visualise the Y component as an approximate diagonal in a RGB colour cube
that describes the grayscale value, and the Cr and Cb values as orthogonal
offsets in two directions adding colour information.

As an example, JPEG often scales down the Cr/Cb components by a factor 4,
and also quantises them more coarsely, so the information stored for the
Cr/Cb planes is just a fraction of info stored for the Y channel.

Basically, the colours used in an image are a cloud in the 3dimensional
colour space (for RGB/YCbCr). Usually, only a small subset of the total
colour space is used and this knowledge can be exploited when doing lossy
compression. Depending on the shape of the cloud, the YCbCr model might be
suitable or less suitable. Some image types could benefit from other models
representing colour. I'm not going to say more, since I don't want to give
away too many secrets (I'm working on image compression myself), and also
because the process of figuring it out is fun in itself :)

Nils Haeck
www.simdesign.nl


jay...@yahoo.com

unread,
Jul 21, 2006, 5:47:51 AM7/21/06
to
Hi Nils,
Thanks a lot for replying.

> If you've already calculated the MSE of the 3 individual channels, you can
> simply calculate the resulting MSE as the sum of them.

Iis it simply the sum of the 3 MSEs or the average?

> PSNR is a good objective way of quantifying lossy compression losses,
> however, many people have remarked that it doesn't correlate well with
> visually perceived quality. Nevertheless it's a good method for comparing
> efficiency of compression codecs that "behave the same".

Agreed, but the other way round is to incorporate HVS models ! I have
not yet got to it!

> Basically, the colours used in an image are a cloud in the 3dimensional
> colour space (for RGB/YCbCr). Usually, only a small subset of the total
> colour space is used and this knowledge can be exploited when doing lossy
> compression. Depending on the shape of the cloud, the YCbCr model might be
> suitable or less suitable. Some image types could benefit from other models
> representing colour.

This means that within the same codec, different types of images would
be processed in different color spaces. Is is possible /feasible?

Regards,
Jaya

Nils

unread,
Jul 21, 2006, 11:56:10 AM7/21/06
to
> Iis it simply the sum of the 3 MSEs or the average?

The sum. In the next step (PSNR) you use a factor 3 so there you in fact
average, but not in the MSE.

> Agreed, but the other way round is to incorporate HVS models ! I have
> not yet got to it!

I don't have high hopes of HSV type of colour spaces, because they skew and
morph the colour space so wickedly that it only becomes harder to compress.

> This means that within the same codec, different types of images would
> be processed in different color spaces. Is is possible /feasible?

Well if you use any colour space that can be converted to/from RGB with a
3x4 matrix you can make one codec and store the matrix. The codec can be so
smart to determine which matrix to use, the one yielding most compression.
What's feasable or not depends mostly on what time you have got to spend on
this :)

Image compression really comes down to finding all hidden correlations and
packing them together in the least possible space. For example, suppose your
cloud of colour is not really a cloud, but by approximation a plane? In that
case you can "ditch" one colour map almost completely. That can remove a
huge amount of redundant information.

However, the colour model is just one of many challenges. Other things are
even more challenging, I think. One of them is for instance how to store the
image such that detail is preserved where required and noise is removed
where detail doesn't matter. Most JPEG codecs for instance are still in
their infancy there. They quantise the complete image with the same
coefficents. Just sidetracking, sorry :)

Hope that helps,

Nils


Chong Hui Yi

unread,
Oct 26, 2020, 3:30:35 AM10/26/20
to
On Friday, July 21, 2006 at 11:56:10 PM UTC+8, Nils wrote:
> > Iis it simply the sum of the 3 MSEs or the average?
> The sum. In the next step (PSNR) you use a factor 3 so there you in fact
> average, but not in the MSE.

Hi, may I know why is it simply the sum and not the average?

Thanks.
0 new messages