简体   繁体   中英

Image Quality Measures Calculation

I need to calculate different IQMs like MSE, PSNR, AD, NCC etc for RGB images. My query is: Can I calculate these after converting to grayscale? ie using rgb2gray ? Or it is must to input the RGB image?

For Example: I am calculating MSE using,

mse = immse(origImg,distImg)    %Method 1 (These images are RGB)

and

origImg = rgb2gray(origImg);    % Method 2

distImg = rgb2gray(distImg);

origImg = double(origImg);

distImg = double(distImg);

[M N] = size(origImg);

error = origImg - distImg;

MSE = sum(sum(error .* error)) / (M * N);

But they are giving different results. Why??

In addition to Y.AL answer, I just propose another way to reach the same result. An approach that is more intuitive in my opinion:

mse = mean((A(:)-B(:)).^2) %with A and B the two images to compare

A and B have data type double, if not those variables need to be converted.

We see that the MSE simply compute the mean of the square difference of each pixels.

We can check that the result are identical with:

%Dummy data    
A = rand(10,10,3);
B = rand(10,10,3);

%Custom vs built in MSE computation
MSE1 = mean((A(:)-B(:)).^2)
MSE2 = immse(A,B)

Because the Method 1 (immse) apply this formula: immse = err = (norm(origImg(:)-distImg(:),2).^2)/numel(origImg); , whereas Method 2 has not the same error calulcation, so it is reasonable to get different results. As well, You can apply them on both RGB and gray level.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM