[Insight-users] Question about reading and writing HDR file
Jianxu Chen
jchen16 at nd.edu
Fri Oct 26 17:08:50 EDT 2012
Hello,
I have another question about the HDR file. The following code implements a
simple operation, reading an HDR image file and writing it exactly to a new
HDR image file.
typedef int InternalPixelType;
const unsigned int Dimension = 3;
typedef itk::Image< InternalPixelType, Dimension > InternalImageType;
typedef unsigned char OutputPixelType;
typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
typedef itk::ImageFileReader< InternalImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( "input.hdr" );
reader->Update();
typedef itk::CastImageFilter< InternalImageType, OutputImageType >
CastingFilterType;
CastingFilterType::Pointer caster = CastingFilterType::New();
caster->SetInput( reader->GetOutput() );
caster->Update();
typedef itk::ImageFileWriter<OutputImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( "output.hdr" );
writer->SetInput( caster->GetOutput() );
writer->Update();
However, the result HDR file is damaged, while the associated IMG file is
fine. When I tried to open the HDR file in MRIcro, it showed that "Unknown
image format, the file size is smaller than described in "Header
information" panel. " If the result is written in TIFF format, it would be
fine. Only the HDR file works incorrectly.
Could you give me some suggestion of how to fix this error?
Sincerely,
Jianxu Chen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20121026/36d4ff7f/attachment.htm>
More information about the Insight-users
mailing list