convert image and linear stretch

3 ビュー (過去 30 日間)
RuiQi
RuiQi 2017 年 2 月 27 日
回答済み: Walter Roberson 2017 年 2 月 27 日
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 日
doc uint8 inbuilt function which converts double to uint8.
  1 件のコメント
RuiQi
RuiQi 2017 年 2 月 27 日
thanks ! but i think it truncates the values that are above the limit. Id like to perform a scaling operation as well.

サインインしてコメントする。


Walter Roberson
Walter Roberson 2017 年 2 月 27 日
im2uint8( mat2gray(depth) )

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by