convert image and linear stretch

3 visualizaciones (últimos 30 días)
RuiQi
RuiQi el 27 de Feb. de 2017
Respondida: Walter Roberson el 27 de Feb. de 2017
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;

Respuestas (2)

KSSV
KSSV el 27 de Feb. de 2017
doc uint8 inbuilt function which converts double to uint8.
  1 comentario
RuiQi
RuiQi el 27 de Feb. de 2017
thanks ! but i think it truncates the values that are above the limit. Id like to perform a scaling operation as well.

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 27 de Feb. de 2017
im2uint8( mat2gray(depth) )

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by