Matlab code..what is the meaning of Img=double(Img(:,:,1))?

Asked by Pooja on 22 Jul 2012
Latest activity Answered by Walter Roberson on 22 Jul 2012

What is the meaning of this code Img=double(Img(:,:,1))

0 Comments

Pooja

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson on 22 Jul 2012

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.)

0 Comments

Walter Roberson

Contact us