difference between in2int16 and int16
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
0 Commenti
Risposte (1)
Guillaume
il 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 Commenti
Guillaume
il 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.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!