<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi,<br>
Could anyone give me some directions to write this code in ITK? <br>
I did check /InsightToolkit-3.12.0/Testing/Code/IO/itkAnalyzeImageIOTest.cxx<br>
Do I only modify this subrountine and put this in my readrawimages_writehdr.cxx? <br>
Thanks for your time and help.<br>
<br>
Regards,<br>
Ching-Yi<br>
<br>
static int WriteTestFiles(const std::string AugmentName)<br>
{<br>
#include "LittleEndian_hdr.h"<br>
#include "LittleEndian_img.h"<br>
#include "BigEndian_hdr.h"<br>
#include "BigEndian_img.h"<br>
std::string LittleEndianHdrName=AugmentName+"LittleEndian.hdr";<br>
std::ofstream little_hdr(LittleEndianHdrName.c_str(), std::ios::binary | std::ios::out);<br>
if(!little_hdr.is_open())<br>
{<br>
return EXIT_FAILURE;<br>
}<br>
//std::cout << LittleEndianHdrName << " written" << std::endl;<br>
little_hdr.write(reinterpret_cast<const char *>(LittleEndian_hdr),sizeof(LittleEndian_hdr));<br>
little_hdr.close();<br>
<br>
std::string LittleEndianZName(AugmentName);<br>
LittleEndianZName += "LittleEndianZ.hdr";<br>
std::ofstream littlez_hdr(LittleEndianZName.c_str(), std::ios::binary | std::ios::out);<br>
if(!littlez_hdr.is_open())<br>
{<br>
return EXIT_FAILURE;<br>
}<br>
littlez_hdr.write(reinterpret_cast<const char *>(LittleEndian_hdr),sizeof(LittleEndian_hdr));<br>
<br>
std::string LittleEndianImgName=AugmentName+"LittleEndian.img";<br>
std::ofstream little_img(LittleEndianImgName.c_str(), std::ios::binary | std::ios::out);<br>
if(!little_img.is_open())<br>
{<br>
return EXIT_FAILURE;<br>
}<br>
// write out compressed.<br>
little_img.write(reinterpret_cast<const char *>(LittleEndian_img),sizeof(LittleEndian_img));<br>
little_img.close();<br>
<br>
// write out compressed image<br>
std::string ImageZFilename(AugmentName);<br>
ImageZFilename += "LittleEndianZ.img.gz";<br>
gzFile file_p = ::gzopen( ImageZFilename.c_str(), "wb" );<br>
if( file_p==NULL )<br>
{<br>
return EXIT_FAILURE;<br>
}<br>
::gzwrite(file_p,reinterpret_cast<const char *>(LittleEndian_img),<br>
sizeof(LittleEndian_img));<br>
::gzclose(file_p);<br>
...}<br>
</td></tr></table><br>