[Insight-users] Save a Matlab 3D image to work with it in ITK
Dirk Boye
body at nabla.org
Mon May 10 02:20:55 EDT 2010
Hi Daniela,
within Matlab save the image as a raw image.
Matlab commands:
----------------
rawFilename=['test.raw'];
fid=fopen(rawFilename,'w+');
fwrite(fid,test,'uint8');
fclose(fid);
In ITK you can read in raw files the following way:
Set the pixeltype according to your US data!
typedef unsigned char PixelType;
typedef itk::Image<PixelType, 3> ImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;
typedef itk::RawImageIO< PixelType, 3 > RawIOType;
ReaderType::Pointer reader = ReaderType::New();
RawIOType::Pointer rawio = RawIOType::New();
rawio->SetByteOrderToBigEndian(); //Could be LittleEndian as well,
depending on your machine
rawio->SetFileDimensionality(3);
rawio->SetHeaderSize(0);
int dimension[3]={{1,1,1}}; // Set your image dimensions here
double spacing[3]={{0.5,0.5,0.5}}; // Set your spacing here
for (int i=0;i<3;++i){
rawio->SetDimensions(i,dimension[i]);
rawio->SetSpacing(i,spacing[i]);
}
reader->SetImageIO(rawio);
reader->SetFileName('test.raw');
reader->Update();
>
> Hi everyone,
>
> I'm trying to work in ITK with a multislice US image pre-processed in
> Matlab: I'm not able to save that in a useful format to process it with
> ITK.
>
> I know that I can use Matlab routine dicomwrite to save an image as .dcm
> (and then process it in ITK); unluckily I think that dicomwrite is good
> only for 2D image and so I don't know how to save my 3D image....
>
> Could someone help me?
>
>
>
> Thanks all
>
> Daniela
>
> _________________________________________________________________
> MSN ti offre esattamente quello che cerchi: il tuo browser personale
> http://www.pimpit.it/ie8msn/_____________________________________
> 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.html
>
> 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