Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8742597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:31:49+00:00 2026-06-13T11:31:49+00:00

How do I read RAW files with SimpleITK for C#? I use SimpleITK C#

  • 0

How do I 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:31:50+00:00Added an answer on June 13, 2026 at 11:31 am

    Thanks to Insight-Users group I got some clues to solve this issue.
    The problem is that ImageFileReader cannot read RAW files. The solution is to read binary data manualy and use ImportImageFilter to build the Image object. The code is as follows:

        [Test]
        public void ReadImageRAW()
        {
            String fileName = @"d:\Temp\MRI\t1_icbm_normal_1mm_pn3_rf20.rawb";
    
            Byte[] imageData = System.IO.File.ReadAllBytes(fileName);
    
            UInt32 width = 181;
            UInt32 height = 217;
            UInt32 depth = 181;
    
            ImportImageFilter importImageFilter = new ImportImageFilter();
    
            importImageFilter.SetSize(new VectorUInt32(new UInt32[] {width, height, depth}));
    
            importImageFilter.SetDirection(new VectorDouble(new Double[] {1, 0, 0, 
                                                                          0, 1, 0, 
                                                                          0, 0, 1}));
    
            importImageFilter.SetOrigin(new VectorDouble(new Double[] { 0, 0, 0 }));
    
            importImageFilter.SetSpacing(new VectorDouble(new Double[] {1, 1, 1}));
    
            GCHandle hObject = GCHandle.Alloc(imageData, GCHandleType.Pinned);
            IntPtr imageDataPtr = hObject.AddrOfPinnedObject();
    
            importImageFilter.SetBufferAsUInt8(imageDataPtr);
    
            Image importedImage = importImageFilter.Execute();
            SimpleITK.Show(importedImage);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to read and write the contents of large, raw volume files
On a Windows PC, is there a way to read the raw bytes from
Is there a good way to read RAW image files (especially Canon CR2 and
Im trying to use Adobe reader to read pdf files downloaded from the server
I've got raw data streams from image files, like: vector<char> rawData(fileSize); ifstream inFile(image.jpg); inFile.read(&rawData[0]);
I have dynamic array filled with bytes, which are read from .raw file with
I want to read the pdf file from raw folder if devices have any
I am trying to read a text file from raw folder, and it works
I'm trying to read from a file called quiz_questions.txt in my res/raw folder. The
I'm making a program which create a RAW socket in order to read all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.