Why do we transfer the image into double?
Mostrar comentarios más antiguos
I saw a lot of image processing examples and before conducting any analysis the image is transfered into double. Is it essential? and what is the benefit from doing so?
Respuesta aceptada
Más respuestas (1)
Paul Hoffrichter
el 4 de Dic. de 2020
MATLAB when using mixed mode arithmetic, will try to save memory.
250 + 10 = 260, right?
>> x =double(250) + uint8(10);
>> x
x =
uint8
255
In other languages, like C/C++, the rule is to maximize precision. Avoid mixed mode arithmetic unless you need it. There is no error or warning provided, by default, in the above code.
4 comentarios
Muhamed Sewidan
el 4 de Dic. de 2020
Paul Hoffrichter
el 4 de Dic. de 2020
Normally, data in MATLAB defaults to double unless specified by a function to be otherwise.
When using imread, it is usual to get a integer type, but not necessarily, uint8. Here you also see uint16, and others.
In fact, I see that TIFF can be returned as single floating point number:
"imread reads and converts TIFF images as follows:
- YCbCr images are converted into the RGB colorspace.
- All grayscale images are read as if black = 0, white = largest value.
- 1-bit images are returned as class logical.
- 16-bit floating-point images are returned as class single."
Muhamed Sewidan
el 4 de Dic. de 2020
Paul Hoffrichter
el 4 de Dic. de 2020
Glad to help.
Categorías
Más información sobre Image Arithmetic en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!