how to convert a double matrix image to a unit8 matrix ?

12 visualizaciones (últimos 30 días)
Hi everybody :) I have an image ,a matrix with values between -0.0934 and 0 and i want to convert it to unit8 matrix with values between 0 ans 255.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 8 de Mzo. de 2013
Editada: Azzi Abdelmalek el 8 de Mzo. de 2013
A=imread('yourimage')
B=uint8(A)
EDIT
d=linspace(min(im(:)),max(im(:)),256)
im1=uint8(arrayfun(@(x) find(abs(d(:)-x)==min(abs(d(:)-x))),im))
  4 comentarios
Mariem Harmassi
Mariem Harmassi el 8 de Mzo. de 2013
yes i tried uint8 it was just an error
Azzi Abdelmalek
Azzi Abdelmalek el 8 de Mzo. de 2013
Editada: Azzi Abdelmalek el 8 de Mzo. de 2013
Try this
%If im is your image
d=linspace(min(im(:)),max(im(:)),256)
im1=uint8(arrayfun(@(x) find(abs(d(:)-x)==min(abs(d(:)-x))),im))

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 8 de Mzo. de 2013
You can use the mat2gray() function:
image8Bit = uint8(255 * mat2gray(floatingPointImage));
It will scale your values to the range 0-255.
  10 comentarios
Juan Manuel Miguel
Juan Manuel Miguel el 6 de Ag. de 2020
Thank you, it was perfect for me!!

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by