Suppose I have a quantization function that quantizes an image with a gray scale of 8 bits:
function mse = uni_quan(I, b) Q = I / 2 ^ (8 - b); Q = uint8(Q); Q = Q * 2 ^ (8 - b); mse = sum(sum((I - Q) .^ 2, 1), 2) / numel(I); end
This function performs uniform quantization on image I and converts it to bitmap b , then scales it in the range 0-255, now I want to calculate the MSE (mean square error) of this process
But the result for
mse = sum(sum((I - Q) .^ 2, 1), 2) / numel(I);
and
mse = sum(sum((Q - I) .^ 2, 1), 2) / numel(I);
is different. Can someone tell me what the problem is?
Thanks
source share