[Insight-users] Question about reading and writing HDR file

Xiaoxiao Liu xiaoxiao.liu at kitware.com
Mon Oct 29 11:50:05 EDT 2012


I don't think  HDR (high dynamic range) image  format is directly supported
in ITK yet.
You might need to some image format conversions in your code.
Or if you find a good way to import the HDR IO into ITK, that will be great.

-Xiaoxiao

On Fri, Oct 26, 2012 at 5:08 PM, Jianxu Chen <jchen16 at nd.edu> wrote:

> 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
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>


-- 


---------------------------------------------
*Xiaoxiao Liu*, Ph.D.
R & D Engineer
Kitware Inc <http://www.kitware.com/>.
Clifton Park, NY
Phone: (518) 881-4924  or  (518) 371-3971 x124
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20121029/fc4917e2/attachment.htm>


More information about the Insight-users mailing list