[Insight-users] Save a Matlab 3D image to work with it in ITK

Sergio Vera sergio.vera at alma3d.com
Mon May 10 03:46:30 EDT 2010


Hello.
As an alternative to mhd files, Matlab can read .nii files (NIFTI/ANALYZE),
although I'm not 100% sure if it can actually write them and I don't have a
matlab right here to test it now.
And ITK can load nii files. 3D wise, of course.

Regards


On Mon, May 10, 2010 at 8:23 AM, Dirk Boye <body at nabla.org> wrote:

> Oh i forgot:
> In Matlab fwrite(fid,test,'uint8')
> will write the image test to the file fid with PixelType uint8 = unsigned
> char
>
> Cheers,
> Dirk
>
> > 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
> >>
> >
> > _____________________________________
> > 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
> >
> >
>
> _____________________________________
> 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
>



-- 
Sergio Vera

Alma IT Systems
C/ Vilana, 4B, 4º 1ª
08022 Barcelona
T. (+34) 932 380 592
www.alma3d.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100510/0b30092d/attachment.htm>


More information about the Insight-users mailing list