[Insight-users] 2D png to 3D gipl : ImageSeriesReader

Rao Jianguo rao . jianguo at hgu . mrc . ac . uk
Mon, 29 Sep 2003 16:55:39 +0100


Hi Luis,

Thanks a lot. I will have a try.

Cheers,

Jianguo

Luis Ibanez wrote:

> Hi Jianguo,
>
> Please find below an example of code that will read
> a set of .PNG files and save them in a single GIPL
> image file.
>
> Regards
>
>    Luis
>
> ---------------------------
>
> #include "itkNumericSeriesFileNames.h"
> #include "itkImageSeriesReader.h"
> #include "itkImageFileWriter.h"
> #include "itkImage.h"
>
> int main(int argc, char * argv[])
> {
>   typedef itk::Image<unsigned char,3> Image3DType;
>
>   //
>   // Here we generate filenames like
>   // myImage000.png, myImage001.png  .... to myImage200.png
>   //
>   itk::NumericSeriesFileNames::Pointer fileIter =
>                       itk::NumericSeriesFileNames::New();
>
>   fileIter->SetStartIndex(   0 );
>   fileIter->SetEndIndex(   200 );
>   fileIter->SetIncrementIndex( 1 );
>   fileIter->SetSeriesFormat("myImages%03d.png");
>
>   itk::ImageSeriesReader<Image3DType>::Pointer reader =
>                itk::ImageSeriesReader<Image3DType>::New();
>
>   reader->SetFileNames( fileIter->GetFileNames() );
>   reader->Update();
>
>   //
>   //  Here we save the image in GIPL format
>   //
>   itk::ImageFileWriter< Image3DType >::Pointer writer =
>                    itk::ImageFileWriter< Image3DType >::New();
>
>   writer->SetInput(   reader->GetOutput()  );
>   writer->SetFileName("myImage.gipl");
>   writer->Update();
>
>   return 0;
> }
>
> -------------------
> Rao Jianguo wrote:
> > Dear All,
> >
> > I am going to make an application.
> >
> > My intention is to make a code to read in series of 2D image files
> > in png format,  then stack them up to form a 3D image and
> > output it in gipl format.
> >
> > If someone there have already done this  could you please let me know
> > to avoid reinventing the wheel.
> >
> > Thanks for your attention.
> >
> >
> >
> > Jianguo
> >
> >
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users