필터 지우기
필터 지우기

image format question

조회 수: 3 (최근 30일)
Betty
Betty 2011년 12월 19일
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!

채택된 답변

Alex Taylor
Alex Taylor 2011년 12월 19일
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
  댓글 수: 1
Betty
Betty 2011년 12월 19일
Thank you! This worked well.

댓글을 달려면 로그인하십시오.

추가 답변 (4개)

Sean de Wolski
Sean de Wolski 2011년 12월 19일
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)

Walter Roberson
Walter Roberson 2011년 12월 19일
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.
  댓글 수: 1
Betty
Betty 2011년 12월 19일
It's int16 (that's how the binary file was created). The values vary from 100 to 810.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2011년 12월 19일
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.

Etamar
Etamar 2011년 12월 19일
try imread instead of fread.
or cast ur data to uint8 uint8(data)
  댓글 수: 3
Betty
Betty 2011년 12월 19일
It was just raw data - 16-bit signed integer, 2000x2000 values. I didn't know how to get imread to read it.
Image Analyst
Image Analyst 2011년 12월 20일
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().

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by