Why do we transfer the image into double?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Muhamed Sewidan
el 5 de Abr. de 2020
Comentada: Paul Hoffrichter
el 4 de Dic. de 2020
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?
0 comentarios
Respuesta aceptada
Image Analyst
el 5 de Abr. de 2020
No, it's usually not. But sometimes it is, like if you want to use conv2(). It has to do with how MATLAB likes to multiply variables of different classes.
2 comentarios
Image Analyst
el 5 de Abr. de 2020
Other than conv2(), I can't think of any off the top of my head. But you obviously must have had some cases in mind because you're the one who brought up the question. Care to share those cases?
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
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!