Matlab code..what is the meaning of Img=double(Img(:,:,1))?
15 次查看(过去 30 天)
显示 更早的评论
What is the meaning of this code Img=double(Img(:,:,1))
0 个评论
回答(1 个)
Walter Roberson
2012-7-22
img(:,:,1) selects the first "pane" of the array "img". If the array only has one pane (e.g., a grayscale image) then that portion is redundant but correct; if the array has multiple panes (e.g., an RGB image), it selects the first of them (probably the Red pane.)
double() indicates that the number values of the input should be examined and a new array the same size be constructed which has the same numeric values but represented as double precision data types. When applied to an image, the implication is most often (but not always!) that the original image array was stored as unsigned 8 bit integers, and now the floating point equivalent is desired. For example, converting an 8 bit integer with value "3" to its floating point equivalent, "3.0". There are various good reasons to do this kind of data type conversion; one of the several common reasons is to be able to do image subtraction and have results come out negative if appropriate (unsigned 8 bit integer subtraction cannot produce negative results and uses 0 where the results would be negative.)
2 个评论
Walter Roberson
2016-9-6
double() indicates that the number values of the input should be examined and a new array the same size be constructed which has the same numeric values but represented as double precision data types. When applied to an image, the implication is most often (but not always!) that the original image array was stored as unsigned 8 bit integers, and now the floating point equivalent is desired.
Once the floating point equivalent is constructed, 1 is added to each element of the array.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!