difference between in2int16 and int16
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Guillaume
2017-3-15
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 个评论
Guillaume
2017-3-15
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!