[Insight-users] A problem with JoinSeriesImageFilter
Dominique Toepfer
dominique at toepfer-web.de
Sat Oct 12 13:14:24 EDT 2013
Hi,
the problem seems to be that you are using the reader inside a loop.
JoinSeriesImageFilter will have the same pointer to the reader output
for every image and the reader, of course, holds the last image at the
end of the loop. One solution is to create a new reader for each image
by just moving
ReaderType::Pointer reader = ReaderType::New();
inside the loop.
Another solution should be calling DisconnectPipeline() on the reader
output.
HTH
Dominique
Am 12.10.2013 18:05, schrieb shiwei:
> 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< unsignedchar, 2 > InputImageType;
>
> typedef itk::Image< unsignedchar, 3 > ImageType3D;
>
> typedef itk::Image< unsignedchar, 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 = newchar [100];
>
> char* writenname=newchar[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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20131012/b1c91738/attachment.htm>
More information about the Insight-users
mailing list