Borrar filtros
Borrar filtros

Why double(img) / max(img(:)) ???

2 visualizaciones (últimos 30 días)
Aude Rapet
Aude Rapet el 21 de Oct. de 2016
Comentada: Aude Rapet el 21 de Oct. de 2016
Hi, I am beginner in Matlab and I have to understand a code.
I don't understand this line : im = double(imread('control_dic.tif'))/max(max(double(imread('control_dic.tif'))))
I do understand that double(imread('control_dic.tif')) converts my image to the variable double but I don't understand why max(max(double(imread('control_dic.tif')
Thank you!!!

Respuesta aceptada

Image Analyst
Image Analyst el 21 de Oct. de 2016
imread() reads in the image. It seems to be a uint8 image. They didn't have to do it twice, but they did. Anyway they then wanted to convert it to the range 0-1 like mat2gray() or im2double() would do but they decided to do it manually. The called max() twice because the first call to max() returns the maxes of the columns, not the whole image. Doing it twice gets the overall max. It appears to be the code of someone with not much more experience than you. You can do it like most people would do it like this:
grayImage = imread('control_dic.tif');
im = im2double(grayImage); % Only if you NEED it in the range 0-1 (which I virtually never do).
which reads in the image only once, and is simpler, and thus easier to understand, maintain, and share with others.
  1 comentario
Aude Rapet
Aude Rapet el 21 de Oct. de 2016
Thank you very much Image Analyst!!

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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by