Effacer les filtres
Effacer les filtres

difference between in2int16 and int16

3 vues (au cours des 30 derniers jours)
Deep P
Deep P le 15 Mar 2017
Commenté : Guillaume le 15 Mar 2017
Hello,
I am trying to read in a 16 bit unsigned image and convert it into 16 bit signed image. I used the function im2int16 and my R,G and B planes have negative values, where as if I use just int16, these planes have positive values. What is the difference between the two?
Also to plot histogram, should I use histogram function or imhist function ? Please explain me the difference.
Thank you.

Réponses (1)

Guillaume
Guillaume le 15 Mar 2017
As per the documentation of im2int16, it rescales the data as necessary, meaning that if the orginal values are not already int16, it will rescale to the int16 range (-32768 to +32767). So a double array in the range [0 1] will result in an int16 array in the range [-32768 32767].
int16 just change the type of the array without changing the values (except for rounding to integers obviously). So a double array in the range [0 1] will result in an int16 array whose values are only 0 or 1.
For your histogram, use whichever function you prefer. imhist will give you more information but both generate an histogram.
  2 commentaires
Deep P
Deep P le 15 Mar 2017
Thank you Guillaume. But what if my original values are int 16? How is the rescaling performed? IS it advisable to use int16 or im2int16?
Guillaume
Guillaume le 15 Mar 2017
If the image class is already int16, then it left untouched by either function.
Which function to use depends on the use case. If the values are already in the int16 range but just the wrong type, then use int16 to cast the image to the correct type. If the image is of another type and in the range of that type (e.g. double in the [0-1] range, or uint8 in the [0-255] range) then use im2int16.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by