Reading a 3d .RAW voxel file

조회 수: 9 (최근 30일)
Itzik Ben Shabat
Itzik Ben Shabat 2012년 12월 3일
Hi, I have a .RAW file that represent a 3d volume using pixels (its basically a 3d matrix containing 1 or 0 wherever there is or there isnt colume).' I am using multibandread() to read it and it works great but, multibandread requires the dimensions of the inpt (the 3 sizes of the3d matrix). how can i get these values from the file ? thanks, itzik
  댓글 수: 1
Jan
Jan 2012년 12월 3일
편집: Jan 2012년 12월 3일
It depends how this information is stored in the file. Files with the ".raw" extension could have many different formats. Therefore more information is required to identify where the wanted information is found in the file. E.g. how has this file been created?

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

답변 (4개)

Itzik Ben Shabat
Itzik Ben Shabat 2012년 12월 4일
편집: Itzik Ben Shabat 2012년 12월 4일
OK so i figured out 2 ways to do this, they both seem to work (the files are always symetric to all sides) 1.
fileID=fopen(file);
[A, count] = fread(fileID);
m_hight=nthroot(count,3);
m_width=nthroot(count,3);
m_depth=nthroot(count,3);
2.
VoxelMat= multibandread(file, m_hight,m_width,m_depth],'uint8',0,'bip','ieee-le');
  댓글 수: 2
Jan
Jan 2012년 12월 4일
편집: Jan 2012년 12월 4일
Please post a new probloem in a new thread. When you create the question for the new thread, remove this answer (which is not an answer...). Please describe "Matlab crashes" with any details: Do you get an error message, a crash dump or does Matlab quit without any notice? And finally, please do not let us guess what "I try to plot" exactly means. Without seeing the code, it is impossible to suggest an improvement. Thanks.
Itzik Ben Shabat
Itzik Ben Shabat 2012년 12월 4일
hi , i did as you ask (sorry for the mess, im relatively new here) I left the answer containing the code since it does answer the question. if you still wish for me to remove it let me know and i will

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


Walter Roberson
Walter Roberson 2012년 12월 3일
If there is no header on the file, then it is not possible to determine the dimensions just by looking at the file. If the size of the file happens to be a composite number that is the product of three primes then you can determine the dimensions but not the order of the dimensions.
  댓글 수: 1
Image Analyst
Image Analyst 2012년 12월 4일
Not without a lot of trial and error "looking" at a slice to see if it looks "correct" (without skewing), which is a tedious manual method. Then you'd have to keep going through a bunch of trial image widths until the skewing eventually went away and the image looked normal. I have done things like get the rows and columns reversed, and you can kind of make out that it is your image but it's skewed or scrambled. It's always better to ask the person or organization that created the image (if you can't find it in any header or other file).

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


Itzik Ben Shabat
Itzik Ben Shabat 2012년 12월 3일
hmmm... thats a great question. I dont really know. is there a way/test to run that i can figure out the format? do you know where i can find a source specifying these different formats ( i tried googling it but couldnt find something)
  댓글 수: 3
Jan
Jan 2012년 12월 3일
I repeat my question: Which program has created the files?
Itzik Ben Shabat
Itzik Ben Shabat 2012년 12월 4일
the files were generated from a matalb\c program that someone wrote. apperantly it stores the data in a simply long array.

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


Image Analyst
Image Analyst 2012년 12월 4일
There is no standard raw. Anybody can do whatever they want. A common one is just simply a pixel dump and nothing else. Just pixel after pixel until all of them are there. But someone could have gone down rows then over columns, or vice versa. But those are possibly the two most common ways. If you can take a look at the data in hex (unfortunately MATLAB's editor is missing this very useful capability) then you might see a difference after about 6 or 12 bytes or so in the appearance of the numbers. If that's true, then it's possible the creator wrote the rows, columns, and number of slices as the first 3 numbers in the file.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by