Discussion in 'C' started by TheKidd88, Jun 29, 2007.
Cause I need to figure out how to do that.
Yep. You learn what the format is, what the parts of it mean, and read the file accordingly. For instance, there is usually a small piece which describes the type of format, and its version. Then there's a header that describes the data. For instance, is it color or grayscale. How many bytes per pixel? Is there a color table or are the pixels raw color data. Stuff like that.
Personally, I study the format. Then I define some structures or classes that conform to the various pieces of the format (magic number, version, header, etc.). Then I write the code to read the file into those structures, then I refer to the information in those structures when reading the raw data.
I don't understand what you are saying. This is the header of the files:
# vtk DataFile Version 3.0
VTK File Generated by Insight Segmentation and Registration Toolkit (ITK)
DIMENSIONS 41 41 41
SPACING 1.0000000000000000e+00 1.0000000000000000e+00 1.0000000000000000e+00
ORIGIN 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00
SCALARS scalars unsigned_char 1
What I want to do is be able to read in the vtk file and then read in the value of each pixel. Starting with the pixel located at 0 0 0, all the way to the pixel located at 41 41 41.
What part of that don't you understand? Here is an example definition from a VTK spec:
Now, if you look at that, and you look at your own post, does the picture begin to clarify for you? Incidentally, do you know how to write a program using the C or C++ languages?
Separate names with a comma.