Matlab code..what is the meaning of Img=double(Img(:,:,1))?
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
What is the meaning of this code Img=double(Img(:,:,1))
0 commentaires
Réponses (1)
Walter Roberson
le 22 Juil 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.)
2 commentaires
aravind S
le 6 Sep 2016
Modifié(e) : Walter Roberson
le 6 Sep 2016
what is
>>double(x)+1;
means?
x is a matrix
Walter Roberson
le 6 Sep 2016
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.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!