convert image and linear stretch

If i have an array of type double, how can i convert it to uint8 and linearly stretch all the values such that min = 0 and max = 255 ? do I have too write my own code for this ? Would this be the correct code ?
K = (depth - min(depth(:)))/(max(depth(:)) - min(depth(:)))*255;

回答(2 个)

KSSV
KSSV 2017-2-27

1 个投票

doc uint8 inbuilt function which converts double to uint8.

1 个评论

thanks ! but i think it truncates the values that are above the limit. Id like to perform a scaling operation as well.

请先登录,再进行评论。

类别

在 帮助中心 和 File Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by