[Insight-users] Reaing RAW Images with SimpleITK for C# Windows

Dan Mueller dan.muel at gmail.com
Sat Oct 27 05:38:29 EDT 2012


Hi Sebastian,

Because the file format you are trying to read is not supported by
ITK, you will need to manually import the image using
sitkImportImageFilter:
    http://www.itk.org/SimpleITKDoxygen/html/sitkImportImageFilter_8h.html

I don't have time to write an example at the moment, but it would
involve reading the raw file using System.IO.File.ReadAllBytes, then
choosing the desired import method (i.e. ImportAsUInt8, ImportAsFloat,
etc) and specifying the image size/spacing/origin/direction/num
components, and finally calling update on the import filter. This will
give you an ITK image wrapped around the raw byte array.

Please let us know how you get on. If you get stuck, I may have time
later this week to whip up a quick example.

HTH

Cheers, Dan

On 27 October 2012 17:50, Sebastian Widz <widz at infovision.pl> wrote:
> Hi,
>
>
>
> how to read RAW files with SimpleITK for C#.
>
>
>
> I use SimpleITK C# version 0.5.1 on Windows (64 bit)
>
>
>
> My code is:
>
>
>
> String fileName = @"d:\Temp\MRI\t1_icbm_normal_1mm_pn3_rf20.rawb";
>
> ImageFileReader reader = new ImageFileReader();
>
> reader.SetFileName(fileName);
>
> Image image = reader.Execute();
>
> It works fine for .png or analyze images for example but not for RAW images.
>
>
>
> I get the following error:
>
>
>
> System.ApplicationException : Exception thrown in SimpleITK
> ImageFileReader_Execute:
> ..\\..\\..\\..\\..\SimpleITK\Code\IO\src\sitkImageReaderBase.cxx:44:
>
> sitk::ERROR: Unable to determine ImageIO reader for
> "d:\Temp\MRI\t1_icbm_normal_1mm_pn3_rf20.rawb"
>
>
>
> I understand that the ImageFileReader cannot recognize the file type. Is
> there a way of passing the image type and image parameters in SimpleITK
> since the standard ITK templates are hidden?
>
>
>
> Regards, Sebastian
>
>
> _____________________________________
> 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
>


More information about the Insight-users mailing list