Is it always necessary to convert image to double type before further execution?
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
Hi,
I want to threshold an image. I can read the image and it is a byte type (UINT 8). I want to pass this image to another function as it is but it asks me to convert to double before I can pass to another function where threshold is performed via MEX MATLAB. How can I pass the image as the same data type? Thanks in advance.
Respuestas (2)
Walter Roberson
el 2 de Oct. de 2013
0 votos
We don't know. You will need to tell us which function you are trying to pass it to.
1 comentario
Krishna
el 4 de Oct. de 2013
Image Analyst
el 2 de Oct. de 2013
0 votos
Well apparently you can't. It said so. It said it wanted double and rejected your call when you tried to pass in uint8(). I don't know why, but that's the way it is. It seems like it could just cast it to double internally, but, for whatever reason, it doesn't. So I guess you have to live with it. Either use double() if it can take whatever range you have, or use im2double() if it wants it in the 0-1 range.
6 comentarios
Krishna
el 4 de Oct. de 2013
Image Analyst
el 4 de Oct. de 2013
Well you don't necessarily need to go back to uint8 for analysis - it just depends on what you're doing. I can't help anymore unless you provide more details. For example I have no idea if you're using imcrop() or doing the cropping some other way. I have a copy and paste demo (attached) in case that helps.
Walter Roberson
el 5 de Oct. de 2013
There is a routine to convert double precision images into uint8(). Or you can just use
uint8(floor(255 * DoublePrecisionImage))
@Krishna: This is not Matlab. We do not know: getData_Image function, type and size of "image", value or "rows" and "cols", size and type of "matlab_image" and why you use 1-based indexing here. So currently there is no chance to guess, what you are doing.
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!