Is there anyway to read in vtk files and determine the value of each pixel?

Discussion in 'C' started by TheKidd88, Jun 29, 2007.

  1. TheKidd88

    TheKidd88 New Member

    Joined:
    Jun 28, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    Cause I need to figure out how to do that. :)
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    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.
     
  3. TheKidd88

    TheKidd88 New Member

    Joined:
    Jun 28, 2007
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    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)
    BINARY
    DATASET STRUCTURED_POINTS
    DIMENSIONS 41 41 41
    SPACING 1.0000000000000000e+00 1.0000000000000000e+00 1.0000000000000000e+00
    ORIGIN 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00
    POINT_DATA 68921
    SCALARS scalars unsigned_char 1
    LOOKUP_TABLE default

    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.
     
  4. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    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?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice