[Insight-users] Write hdr/img format from a series of raw images (float format)
Ching-Yi Hsieh
cymed2 at yahoo.com
Thu Mar 19 22:44:50 EDT 2009
Hi,
Could anyone give me some directions to write this code in ITK?
I did check /InsightToolkit-3.12.0/Testing/Code/IO/itkAnalyzeImageIOTest.cxx
Do I only modify this subrountine and put this in my readrawimages_writehdr.cxx?
Thanks for your time and help.
Regards,
Ching-Yi
static int WriteTestFiles(const std::string AugmentName)
{
#include "LittleEndian_hdr.h"
#include "LittleEndian_img.h"
#include "BigEndian_hdr.h"
#include "BigEndian_img.h"
std::string LittleEndianHdrName=AugmentName+"LittleEndian.hdr";
std::ofstream little_hdr(LittleEndianHdrName.c_str(), std::ios::binary | std::ios::out);
if(!little_hdr.is_open())
{
return EXIT_FAILURE;
}
//std::cout << LittleEndianHdrName << " written" << std::endl;
little_hdr.write(reinterpret_cast<const char *>(LittleEndian_hdr),sizeof(LittleEndian_hdr));
little_hdr.close();
std::string LittleEndianZName(AugmentName);
LittleEndianZName += "LittleEndianZ.hdr";
std::ofstream littlez_hdr(LittleEndianZName.c_str(), std::ios::binary | std::ios::out);
if(!littlez_hdr.is_open())
{
return EXIT_FAILURE;
}
littlez_hdr.write(reinterpret_cast<const char *>(LittleEndian_hdr),sizeof(LittleEndian_hdr));
std::string LittleEndianImgName=AugmentName+"LittleEndian.img";
std::ofstream little_img(LittleEndianImgName.c_str(), std::ios::binary | std::ios::out);
if(!little_img.is_open())
{
return EXIT_FAILURE;
}
// write out compressed.
little_img.write(reinterpret_cast<const char *>(LittleEndian_img),sizeof(LittleEndian_img));
little_img.close();
// write out compressed image
std::string ImageZFilename(AugmentName);
ImageZFilename += "LittleEndianZ.img.gz";
gzFile file_p = ::gzopen( ImageZFilename.c_str(), "wb" );
if( file_p==NULL )
{
return EXIT_FAILURE;
}
::gzwrite(file_p,reinterpret_cast<const char *>(LittleEndian_img),
sizeof(LittleEndian_img));
::gzclose(file_p);
...}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090319/60fc79d7/attachment.htm>
More information about the Insight-users
mailing list