image format question
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I am dealing with satellite imagery have a binary file of image data. I can read the file correctly using fread, so have it in a 2d array called a. How do I display the image. I tried
imshow(a)
but I got the following:
Warning: Image is too big to fit on screen; displaying at
33%
> In imuitools/private/initSize at 72
In imshow at 259
A new window came up, but no image was displayed. I then tried:
imshow(a(1:100,1:100))
and a smaller window popped up, but still nothing in it. No warning that time though.
I think my fundamental question as a newbie to image processing in matlab is: do I have to convert my array to some sort of "image" format for matlab to understand how to display it and perform other image processing functions on it?
Thanks!
0 comentarios
Respuesta aceptada
Alex Taylor
el 19 de Dic. de 2011
When you say that "a new window came up, but no image was displayed", the most likely cause of this is that the 'DisplayRange' property of imshow needs to be adjusted because the input data is not well scaled.
Try the following to get autoscaling behavior:
imshow(a,[]);
This will set the 'DisplayRange' to the range of the histogram of your data.
For more help, please take a look at the reference page for imshow
doc imshow
Más respuestas (4)
Sean de Wolski
el 19 de Dic. de 2011
No. You can display any 2d nmatrix or mxnx3 rgb matrix with imshow, you just might need to adjust a few parameters (such as initialmagnification displayrange colormap etc.)
doc imshow
explains a little. The warning you were seeing was just because the image was large. Adjust the initialmagnification or turn off the warning. (During grad school I permanently turned off that warning because it was thrown on every call)
0 comentarios
Walter Roberson
el 19 de Dic. de 2011
I'm sure I already answered this question, but I see that question has disappeared :(
You do not need to convert your array to any kind of "image" format. However, if the values in your array are close together then imshow() and image() would only have a very small range of colors to work with. If you pass [] as the second parameter of imshow(), or if you use imagesc() instead of imshow(), then the data will automatically be scaled to use the entire color map.
What data type is your "a" array? Is it possibly uint8 ? And are all the values exactly 0 or 1 ? If that is the case then imshow(double(a)) would turn out to have the same effect but would take more memory.
Image Analyst
el 19 de Dic. de 2011
Like they said, try the bracket bracket [] to have it scale. If it's still not there, set a breakpoint and look at the size and type of "a." Maybe it's only one signel number for some reason. You should also choose a meaningful variable name, such as originalImage, rather than single letters. Just before you call imshow, insert this statement:
[rows columns numberOfColorChannels] = size(originalImage)
(no semicolon) and see what it spits out to the command window, then tell us.
0 comentarios
Etamar
el 19 de Dic. de 2011
try imread instead of fread.
or cast ur data to uint8 uint8(data)
3 comentarios
Image Analyst
el 20 de Dic. de 2011
It may not, unless it is some standard format like TIFF, PNG, BMP, etc. That's probably why you had to write your own custom reading program using fread().
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!