[Insight-users] Conversion of 2D slices to 3D datafile

Karthik Krishnan Karthik.Krishnan at kitware.com
Wed Dec 8 23:45:28 EST 2004


Hi Dhaval,

You might want to take a look at the classes itk::NumericSeriesFileNames and
itk::ImageSeriesReader.

The following code should do your job

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkNumericSeriesFileNames.h"
#include "itkImageSeriesReader.h"
#include "itkSiemensVisionImageIO.h"
#include <iostream>

int main()
{
 itk::NumericSeriesFileNames::Pointer NumSeriesFNs =
itk::NumericSeriesFileNames::New();
 NumSeriesFNs->SetStartIndex(1);
 NumSeriesFNs->SetEndIndex(10);
 NumSeriesFNs->SetSeriesFormat ("Sen1009_%d.ima");

 typedef itk::Image<unsigned short, 3> ImageType;

 typedef itk::ImageSeriesReader<ImageType> ImageSeriesReaderType;
 ImageSeriesReaderType::Pointer ImSeriesReader =
ImageSeriesReaderType::New();
 ImSeriesReader->SetFileNames(NumSeriesFNs->GetFileNames());
 ImSeriesReader->Update();
 std::cout << ImSeriesReader << std::endl;

 typedef itk::ImageFileWriter<ImageType> ImageFileWriterType;
 ImageFileWriterType::Pointer ImFileWriter = ImageFileWriterType::New();
 ImFileWriter->SetInput(ImSeriesReader->GetOutput());
 ImFileWriter->SetFileName("Output.mhd");
 std::cout << ImFileWriter << std::endl;
 ImFileWriter->Write();
 return 0;
}

Thanks
karthik


----- Original Message ----- 
From: "Dalal, Dhaval" <dalal at bnl.gov>
To: <insight-users at itk.org>
Cc: <insight-users-bounces at itk.org>
Sent: Wednesday, December 08, 2004 11:16 AM
Subject: [Insight-users] Conversion of 2D slices to 3D datafile


> HI
> I have 2D slices of MRI images in all 3domains.
> I had first used ImageReadExtractWrite to extract 2D slices from my raw
data
> file and then I had performed non-rigid registration using
> DeformableRegistration8 on the 2D slices.
> Now after registration, i want to reconstruct my 3D datafile again.
> I have 256*256*512 slices
> Any suggections are welcome
> Thanx
> DHaval
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users



More information about the Insight-users mailing list