When to use Double data type for an image in matlab?
Mostrar comentarios más antiguos
I am trying to find out focus score of an image for which i need to get both the mean and variance. i m getting some Values for both these parameters if i convert the image into data type double. But the image, after changing its data to double, appears like a few spots on the screen, nothing else. I could be wrong in judging it as loss of information of the image. So Please guide me..... i hope this data type conversion has no effect on the information content of the image and using it wont effect my end result to find focus score of the image.
1 comentario
Vaibhav
el 30 de Ag. de 2024
When you convert an image from 8-bit to double without proper scaling, the image might appear as a few spots because the values are not in the expected range (0.0 to 1.0) for display. This does not necessarily mean information is lost, but the visual representation changes. As far we know, the pixel values are typically scaled between 0.0 and 1.0, or they can represent a much broader range of values.
Mean and Variance: These statistics should remain consistent regardless of the data type, provided you handle the conversion correctly.
- Mean: Represents the average pixel intensity.
- Variance: Measures the spread of pixel intensities.
If you calculate the mean and variance after converting to double, the results will be in line with the data type's scale (e.g., a mean close to 0.5 if scaled to 0.0-1.0).
For calculations, what matters is the underlying numerical data, not how the image appears visually.
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 24 de Jun. de 2015
2 votos
When you use img=double(imread('cell.jpg')); then the values you get will be the floating point versions of integers.
When you apply image() to a floating point array that is 3D then it assumes that the values are valid RGB values in the range 0 to 1, and will treat everything larger than 1 as if it was one.
When you apply image() to a floating point array that is 2D then it assumes that the values represent indices into the colormap, and will treat anything larger than the number of colormap entries as if it should be the last colormap entry. This does not apply to your immediately situation because .jpg files are never 2D, always 3D (the same does not appear to hold true for .jp2 files.)
If you want to convert a uint8 image (values 0 to 255) to a double image that will be recognized as representing the same colors, you should use im2double(), which will (generally) do double(TheData)./255 and so generally return values from 0 to 1 as expected by display() for a double RGB image.
double() vs uint8 and 2D vs 3D are important to display() to determine what the values represent.
1 comentario
dv
el 25 de Jun. de 2015
Categorías
Más información sobre Data Type Identification 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!