im2double:
im2double Convert image to double precision.
im2double takes an image as input, and returns an image of class double. If the input image is of class double, the output image is identical to it. If the input image is not double, im2double returns the equivalent image of class double, rescaling or offsetting the data as necessary.
I2 = im2double(I1) converts the intensity image I1 to double precision, rescaling the data if necessary.
im2double即把图像转成双精度形式。为什么要把图像转换成双精度进行运算呢?原因在于:一般情况下,图片都以uint8数据储存。当对图片进行数据运算时,数据大于256就出现溢出,结果失真。而双精度数运算时不会出现溢出,故先把uint8数据转为双精度数,就不会使计算精度失真。