"I2 = im2double(I) convertsthe intensity image I to double precision, rescalingthe data if necessary". I am not getting this description.
Why an image is converted to double using I=im2double(I); in matlab?
38 次查看(过去 30 天)
显示 更早的评论
I=im2double(I); what is the need for it
采纳的回答
Walter Roberson
2015-8-13
MATLAB has two ways of representing RGB and grayscale images.
- Images can be represented as double precision numbers (or single precision) in the range 0 to 1.
- Images can also be represented as integer data classes, especially uint8 (unsigned 8 bit integers), in which case the values are the integers 0, 1, 2, ... up to the maximum representatable in the integer class, such as 255. The conversion from integer class to double precision is to switch the numbers to floating point and then divide by the maximum allowed for the class, such as double(ImageData)/255 so 0 still corresponds to 0.0 and 255 corresponds to 1.0
Most of the image file formats store only integers, or "prefer" to store integers.
Sometimes operations on images are easier when the images are represented in floating point. For example if you want to subtract one image from another, if the images are in unsigned integer format, everywhere the second image was greater than the first you would get 0 as the result because unsigned integers cannot represent negative numbers.
There are also some parts of the graphics system, such as AlphaData, that must be in floating point format.
It is therefore not uncommon to want to switch from integer representation to floating point representation. im2double() does that. im2double() knows about all the various integer storage classes and what the proper conversion formula is -- it is not necessarily a "difficult" conversion, but you can count on im2double() to get it right. This is especially valueable when you are allowing the user to select the images to be read in: if you want to be able to support a variety of image file formats that might use different ranges of values, it is better to call a routine that is sure to get the conversion right than to do the conversion yourself and risk an incompatibility.
11 个评论
Simon Silge
2020-7-15
编辑:Simon Silge
2020-7-15
I might add to it that double can help to preserve higher precision during image manipulation or grayscale conversion as you are not limited to integer values. For example, for grayscale conversion from a 24-bit RGB ( three channels with 8 bit, datatype uint 8) rgb2gray returns a uint8 grayscale by calculating one grayscale intensity value from the three 8-bit color channels. Here you can loose a small part of information (apart from the colors) during this calculation as the unit8 cannot represent numbers like 100.3 or 100.6 but rounds them to 100 and 101.
gunturu gunturu
2021-3-8
function out = TTFIO(image, tao, zeta)
[row col]=size(image);
img = (image - min(image(:)))./(max(image(:)) - min(image(:)));
for j = 1:row
for k = 1:col
if img(j,k) <= tao
enhanced(j,k) = 2*img(j,k)^2;
else
enhanced(j,k) = 1-2*(1-img(j,k))^2;
end
end
end
out=((enhanced).^(tao+zeta));
can someone please explain this? or please kindly tell me any source from where i can learn this?
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!