MATLAB: Are the various min and max NOT zero

variables

clc
clear all
aa=imread('31c.jpg');
aq=im2double(aa);
ar=double(aa);
for n=1:3
a=aa(:,:,n);
ar=double(a);
as(:,:,n)=ar;
end
diff1=aq-as;
max1=max(max(max(diff1)))
min1=min(min(min(diff1)))
diff2=aq-ar;
max2=max(max(max(diff2)))
min2=min(min(min(diff2)))
diff3=as-ar;
max3=max(max(max(diff3)))
min3=min(min(min(diff3)))

Best Answer

They should not be the same. im2double() does not just do double() of the image -- it does not, for example, take uint8(172) and make it into 172.0 . im2double() rescales the data to fit in the range 0 to 1: im2double(A) for A integer is double(A)./double(intmax(class(A))) . For uint8 that would be double(A)/255, so 0 would still come out as 0 and 255 would come out as 1, and everything in between is linear proportion.