<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 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 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 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 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 href="mailto:Community@itk.org">Community@itk.org</a><br>
<a 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>