How to transfer a matrix into an image correctly?

6 visualizaciones (últimos 30 días)
Jack Z
Jack Z el 8 de Nov. de 2017
Comentada: Jack Z el 9 de Nov. de 2017
Hi everyone,
I have a trouble converting 3-dimensional matrices into color images. I used the function imwrite(). However it just converted a lot of my entries with small values (like 7.003) into 254 or 255. This is highly undesirable for my project. Is there a way to deal with it?
Thanks, Jack

Respuesta aceptada

Walter Roberson
Walter Roberson el 8 de Nov. de 2017
You should proceed one of two ways:
  1. If your values are in the range 0 to 255 and fractions do not matter to you, then uint8() the data before imwrite()
  2. use mat2gray() to convert your data into the range 0 to 1, and then im2uint8() or im2uint16() that and imwrite what comes out.
  1 comentario
Jack Z
Jack Z el 9 de Nov. de 2017
Thank. I used method one about 4 hours ago and solved the problem.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by