im2double和double函数的区别

      针对数字图像处理,多数情况下,源图像的像素格式为unsigned char类型,当涉及到频域等处理时候,需要将字节型数据转换为double类型,matlab提供了2两个函数,im2double和double函数,均可使用,但是两者的区别则极其重要。

    在matlab的官方论坛上有这样几句话:But a simple test will show you that  when you use im2double, it will convert your uint8 image from the range of 0-255 into a double array in the range 0-1. In general, all Image Processing Toolbox functions that take floating point arrays want them in the range of 0 to 1. I find it kind of annoying but that's the way it is. That's basically what "rescaling" means. So this imdouble() function is there to help you get to what you might need for later calls to Image Processing Toolbox functions. If you use double() you would have to divide by 255 yourself if you needed to. If you're doing your own custom functions then you can leave it in the original range if you want。

    意思就是im2double 函数将所有像素数据转化为【0 1】区间之内,这也是数字图像处理工具箱的要求;但是double函数则仅仅提高数据精度,但是并未将数据量化到【0 1】区间之内。

   适应场合:当你需要做频域滤波处理,需要注意不要使用im2double函数,否则滤波之后,图像在傅里叶反变换之后,所有像素数据都是0,也就是说图像纯黑色。与此对应,当你使用数字图像处理工具箱的时候,建议使用im2double函数。

你可能感兴趣的:(im2double和double函数的区别)