<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Thanks all, you avoided me a strong
      headache!<br>
      <br>
      Somehow i thought that the order on which the data was written in
      the raw file  depended from the parameters i was giving to the
      RawImageIO. (i had a template of nhdr file that i was using with
      the .raw image for the testing).<br>
      <br>
      Now I just output the nhdr as Bradley suggested and it works
      smoothly now, sorry for the dumb approach i had!<br>
      <br>
      Best,<br>
      Emiliano<br>
      <br>
      Il 18/03/14 15:58, Luis Ibanez ha scritto:<br>
    </div>
    <blockquote
cite="mid:CABAUzPoB8-3BVkxwicD6bMynwRAnKRX6t_TvSN9cWZOaUEeuxQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi Emiliano,
        <div><br>
        </div>
        <div>Please note that the RawImageIO class will throw away all
          the Image Metadata.</div>
        <div><br>
        </div>
        <div>RawImageIO only stores the byte data corresponding to pixel
          intensity values.</div>
        <div><br>
        </div>
        <div>The rest:  direction, spacing, origin...etc..  is
          dismissed.</div>
        <div><br>
        </div>
        <div>In practice, there is no real advantage in using the
          RawImageIO.</div>
        <div><br>
        </div>
        <div>You may want to rather use the MetaImageIO format, </div>
        <div>and get two files:</div>
        <div><br>
        </div>
        <div>.mhd with a text header</div>
        <div>.raw with the raw byte data for the pixel intensities.</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Hope this helps,</div>
        <div><br>
        </div>
        <div>    Luis</div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Tue, Mar 18, 2014 at 9:49 AM,
          Emiliano Pastorelli <span dir="ltr"><<a
              moz-do-not-send="true"
              href="mailto:emiliano.pastorelli@gmail.com"
              target="_blank">emiliano.pastorelli@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000">
              <div>Hi Matt,<br>
                <br>
                is the way I use the RawImageIO together with the image
                writer correct?<br>
                I'm still trying to change directions, swapping them,
                playing around with some other values, and it just keeps
                on producing the same wrong output (i'm sure the raw
                image is newly generated though and i'm loading that one
                in paraview to visualize the results or in my software
                to analze it).<br>
                I start wondering because nothing i do seems to cause
                real changes, so i think i might be misusing the whole
                thing, but i don't get how.<br>
                <br>
                Thanks and Best,<br>
                Emiliano<br>
                <br>
                Il 18/03/14 15:24, Matt McCormick ha scritto:<br>
              </div>
              <div>
                <div class="h5">
                  <blockquote type="cite">
                    <div dir="ltr">Hi Emiliano,
                      <div><br>
                      </div>
                      <div>I am not sure I see the issue.  Is the image
                        missing the correct spacing information?</div>
                      <div><br>
                      </div>
                      <div>Matt</div>
                    </div>
                    <div class="gmail_extra"><br>
                      <br>
                      <div class="gmail_quote"> On Tue, Mar 18, 2014 at
                        8:32 AM, Emiliano Pastorelli <span dir="ltr"><<a
                            moz-do-not-send="true"
                            href="mailto:emiliano.pastorelli@gmail.com"
                            target="_blank">emiliano.pastorelli@gmail.com</a>></span>
                        wrote:<br>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          <div dir="ltr">
                            <div>
                              <div>
                                <div>
                                  <div>
                                    <div>Hi all,<br>
                                      <br>
                                    </div>
                                    I am trying to write to file a
                                    processed volume on which i'm
                                    working. Due to the fact that
                                    another software of mine that
                                    performs another analysis on the
                                    filtered dataset reads in nhdr+raw
                                    files (i write manually the nhdr,
                                    and from there i only take size and
                                    endianness of the raw data).<br>
                                    <br>
                                  </div>
                                  the look of a nhdr header that i was
                                  loading in my software is this  :<br>
                                  #################################<br>
                                  NRRD0004<br>
                                  # Complete NRRD file format
                                  specification at:<br>
                                  # <a moz-do-not-send="true"
                                    href="http://teem.sourceforge.net/nrrd/format.html"
                                    target="_blank">http://teem.sourceforge.net/nrrd/format.html</a><br>
                                  type: short<br>
                                  dimension: 3<br>
                                  space: left-posterior-superior<br>
                                  sizes: 795 788 576<br>
                                  space directions: (1,0,0) (0,1,0)
                                  (0,0,1)<br>
                                  kinds: domain domain domain<br>
                                  endian: little<br>
                                  encoding: raw<br>
                                  space origin: (-397,-393.5,-287.5)<br>
                                  data file: 4a.raw<br>
                                  #################################<br>
                                  <br>
                                </div>
                                what i am trying to do in the code to
                                write a file in a similar format that my
                                software can understand and read. it's
                                my first attempt at using the
                                RawImageIO, but doesn't matter what i
                                change, the saved volume it's always
                                wrongly reconstructed. <br>
                                <br>
                              </div>
                              A topdown view of the volume as it should
                              look like<br>
                              <a moz-do-not-send="true"
                                href="http://www.kyb3.org/images/MhdRaw.png"
                                target="_blank">http://www.kyb3.org/images/MhdRaw.png</a><br>
                            </div>
                            A topdown of how it looks like<br>
                            <a moz-do-not-send="true"
                              href="http://www.kyb3.org/images/NhdrRaw.png"
                              target="_blank">http://www.kyb3.org/images/NhdrRaw.png</a><br>
                            <div>
                              <div>
                                <div><br>
                                  #################################<br>
                                  typedef RawImageIO<short, 3>
                                  rawWriter;<br>
                                      rawWriter::Pointer newRawWriter =
                                  rawWriter::New();<br>
                                     
                                  newRawWriter->SetFileTypeToBinary();<br>
                                  <br>
                                     
                                  newRawWriter->SetDimensions(0,150);<br>
                                     
                                  newRawWriter->SetDimensions(1,150);<br>
                                     
                                  newRawWriter->SetDimensions(2,150);<br>
                                  <br>
                                      vector<double> dirX(3);<br>
                                     
                                  dirX[0]=1.0;dirX[1]=0.0;dirX[2]=0.0;<br>
                                      vector<double> dirZ(3);<br>
                                     
                                  dirZ[0]=0.0;dirZ[1]=0.0;dirZ[2]=1.0;<br>
                                      vector<double> dirY(3);<br>
                                     
                                  dirY[0]=0.0;dirY[1]=1.0;dirY[2]=0.0;<br>
                                  <br>
                                     
                                  newRawWriter->SetDirection(0,dirX);<br>
                                     
                                  newRawWriter->SetDirection(1,dirZ);<br>
                                     
                                  newRawWriter->SetDirection(2,dirY);<br>
                                      newRawWriter->SetSpacing(0,1);<br>
                                      newRawWriter->SetSpacing(1,1);<br>
                                      newRawWriter->SetSpacing(2,1);<br>
                                  <br>
                                      newRawWriter->SetHeaderSize(0);<br>
                                     
                                  newRawWriter->SetByteOrderToLittleEndian();<br>
                                     
                                  newRawWriter->SetNumberOfComponents(1);<br>
                                  <br>
                                      /*<br>
                                       * SAVE TO FILE<br>
                                       */<br>
                                      typedef itk::ImageFileWriter<
                                  OutputImageType > WriterType;<br>
                                      WriterType::Pointer writer =
                                  WriterType::New();<br>
                                      writer->SetInput(
                                  LabelToBinary->GetOutput() );<br>
                                     
                                  writer->SetImageIO(newRawWriter);<br>
                                      writer->SetFileName(
                                  "../VolumeAnalysis/Frangi.raw" );<br>
                                  <br>
                                      try{<br>
                                          writer->Update();<br>
                                      }<br>
                                      catch( itk::ExceptionObject &
                                  error ){<br>
                                          std::cerr << "Error: "
                                  << error << std::endl;<br>
                                          return EXIT_FAILURE;<br>
                                      }<br>
                                  <br>
                                      cout << "Volume Saved"
                                  << endl;<br>
                                  #################################<br>
                                  <br>
                                </div>
                                <div>Best,<br>
                                </div>
                                <div>Emiliano<br>
                                </div>
                              </div>
                            </div>
                          </div>
                          <br>
_______________________________________________<br>
                          Community mailing list<br>
                          <a moz-do-not-send="true"
                            href="mailto:Community@itk.org"
                            target="_blank">Community@itk.org</a><br>
                          <a moz-do-not-send="true"
                            href="http://public.kitware.com/cgi-bin/mailman/listinfo/community"
                            target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/community</a><br>
                          <br>
                        </blockquote>
                      </div>
                      <br>
                    </div>
                  </blockquote>
                  <br>
                </div>
              </div>
            </div>
            <br>
            _______________________________________________<br>
            Community mailing list<br>
            <a moz-do-not-send="true" href="mailto:Community@itk.org">Community@itk.org</a><br>
            <a moz-do-not-send="true"
              href="http://public.kitware.com/cgi-bin/mailman/listinfo/community"
              target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/community</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>