[Insight-users] A problem with JoinSeriesImageFilter
Bill Lorensen
bill.lorensen at gmail.com
Sat Oct 12 13:20:28 EDT 2013
Move:
ReaderType::Pointer reader = ReaderType::New();
inside your for loop.
On Sat, Oct 12, 2013 at 12:05 PM, shiwei <swingsw89 at 163.com> wrote:
> Hi,All~
> Here I got a problem with the itk::JoinSeriesImageFilter,I read four
> different 2d images and want to join them to one 3D Image by using
> JoinSeriesImageFilter.However, in the Test example,I finally got one 3D
> Image which has four same slices(not four different one),and it shows that
> the same slice are the last 2D image which read in to the memory. Now I'm
> confused about this ,and can anyone help me with that? The code is below,
> Thank you very much for that!
>
> #include "itkImage.h"
>
> #include "itkImageFileReader.h"
>
> #include "itkImageFileWriter.h"
>
> #include "itkJoinSeriesImageFilter.h"
>
> typedef itk::Image< unsigned char, 2 > InputImageType;
>
> typedef itk::Image< unsigned char, 3 > ImageType3D;
>
> typedef itk::Image< unsigned char, 2 > ImageType2D;
>
> typedef itk::ImageFileReader< InputImageType > ReaderType;
>
> typedef itk::ImageFileWriter< ImageType3D > WriterType;
>
> typedef itk::JoinSeriesImageFilter<ImageType2D, ImageType3D>
> JoinSeriesImageFilterType;
>
> int main()
>
> {
>
> ReaderType::Pointer reader = ReaderType::New();
>
> JoinSeriesImageFilterType::Pointer joinFilter =
> JoinSeriesImageFilterType::New();
>
> int slice;
>
> char* Src="D:\\ITK_test\\joinseriestest\\bin\\liimage1";
>
> char * Ipo="_cor.tif";
>
> char* Ipr="GFP_";
>
> char* filename = new char [100];
>
> char* writenname=new char[100];
>
> for(slice=2600;slice<=2605;++slice)
>
> {
>
>
>
> filename[0] = '\0';
>
> sprintf_s(filename,100,"%s\\ %s%05d%s",Src,Ipr,slice,Ipo);
>
> reader->SetFileName(filename);
>
> reader->Update();
>
> joinFilter->SetInput(slice-2600,reader->GetOutput());
>
> }
>
> joinFilter->Update();
>
> WriterType::Pointer writer = WriterType::New();
>
> writer->SetFileName( "D:\\ITK_test\\joinseriestest\\bin\\26001.tif" );
>
> writer->SetInput(joinFilter->GetOutput());
>
> writer->Update();
>
> return 0;
>
> }
>
>
>
>
>
>
> _____________________________________
> 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.php
>
> 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
>
--
Unpaid intern in BillsBasement at noware dot com
More information about the Insight-users
mailing list