Reputation: 989
a=imread('pic1.jpg');
b=0.25*a;
c=4.0*b;
figure;
imshow(c);
MSE = reshape(mean(mean(((a) - (c)).^2,2),1),[1,3])
Code works fine without any errors. Size of a is 256*256*3 RGB type. However, There are 2 issues :
1.1361 1.2780 1.2902
The same is observed when testing with b=0.27.*a
; then c=3.703703704.*b
; 0.5346 0.6132 0.6275
Can anyone explain it lucidly why this is happening and what is the remedy?
Upvotes: 0
Views: 679
Reputation: 5024
Have a look at the data type of your variable a. It is probably a uint8, which means b also becomes uint8 containing rounded values - in other words you loose two bits of information per pixel.
You mention "double data type", but I don't see where you use it in your code.
If you started with a=double(imread('pix1.jpg')); then your MSE should nearly zero (I'd expect it to be on the order of 256*256*3*eps (i.e. rounding error)).
Upvotes: 3