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 CenterFile 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