I have a .rec file which is supposed to be a reconstructed SPECT image of a point source. I am trying to open it up in matlab.
I have usually used the following generic way of opening image data files in matlab:
fid = fopen('filename.ext','r');
A = fread(fid,sizeA,precision);
imagesc(A)
colormap('gray')
axis image off
but this block of code does not open my .rec file in this case. It simply returns a blank gray screen with no image. I was told something about specifying the file format, but I'm not sure how to do this.

댓글 수: 5

Iain
Iain 2014년 8월 27일
Do you know the precision? - What precision have you specified?
Have you tried plotting A with plot(A,'x')?
richard
richard 2014년 8월 27일
I believe the precision is 45x45, these are the pixel dimensions for the gamma camera. I have not used the plot command. What is the 'x' string you have put down for it stand for?
Iain
Iain 2014년 8월 28일
plot(A,'x') should pop up a figure with the values of "A" plotted as crosses (thats what 'x' was for) - I was trying to get you to find out if there was data in the file. - Which Image Analyst is trying to help you do as well.
richard
richard 2014년 8월 28일
The A matrix is zero so as a result there are x's only at zero...
Image Analyst
Image Analyst 2014년 8월 28일
Attach your image and code to read it so we can (perhaps) try to fix it.

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

답변 (1개)

Image Analyst
Image Analyst 2014년 8월 27일

0 개 추천

Richard,
No, precision would be something like '*uint8'. What you called precision is actually "sizeA" and would be sizeA = [45, 45]. So try
sizeA = [45, 45];
precision = '*uint8';
A = fread(fid,sizeA,precision);
imshow(A, [])
colormap('gray');
axis on;

댓글 수: 5

richard
richard 2014년 8월 27일
Oh yea, the precision I believe is float32, I'll try this
richard
richard 2014년 8월 27일
The block of code you sent still doesn't pull up the .rec file, it pulls up a blank black figure. What you sent works for most of the data images I have worked with, but the .rec file is still giving me trouble
Image Analyst
Image Analyst 2014년 8월 27일
Try changing the endian (machinefmt) and see if that helps. What is the range of the values you get back? Are you sure you're using [] in the imshow() call?
richard
richard 2014년 8월 27일
Yea I tried changing the machine format to all those listed, the matrix I get for A is still all zeroes... do you think that this attachment would get me where I need to be? I got the M-file from this url: http://www.mathworks.com/matlabcentral/fileexchange/29344-read-medical-data-3d/content/ReadData3D.m
Image Analyst
Image Analyst 2014년 8월 27일
It may. Looks like you need the fig file also since it's a GUIDE file. Try reading in A as bytes, or just opening it in notepad. Is it all zeros if you use either of those? If so, then the file actually is all zeros for some reason.

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

카테고리

도움말 센터File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

질문:

2014년 8월 27일

댓글:

2014년 8월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by