[vtkusers] [Insight-users] Problem when using seriesreader together with series writer
John Drescher
drescherjm at gmail.com
Mon Apr 13 21:23:24 EDT 2009
On Mon, Apr 13, 2009 at 6:40 PM, Wen Shi <wsa18 at sfu.ca> wrote:
> Hi Guys,
>
> I was using VED(vesselness enhancement filter) and using imageseriesreader and serieswriter(Since VED only deals with 3D image data)
>
> The problem occured when the writer try to read the output of the rescalefilter.
> I got errors like this:
>
> error C2440: 'initializing' : cannot convert from 'itk::Image<TPixel,VImageDimension> *' to 'itk::SmartPointer<TObjectType>'
>
> The rescalefilter code along with the responsive codes are as follows:
>
>
> typedef itk::Image<unsigned char, 3> OutputImageType;
> const unsigned int Dimension = 3;
> typedef double OutputVesselnessPixelType;
> typedef itk::Image<unsigned char, 3> OutputImageType;
> typedef itk::Image< OutputVesselnessPixelType, Dimension> VesselnessOutputImageType;
>
> typedef itk::RescaleIntensityImageFilter< VesselnessOutputImageType,
> OutputImageType>
> RescaleFilterType;
>
> RescaleFilterType::Pointer rescale = RescaleFilterType::New();
> rescale->SetInput( MultiScaleVesselnessFilter->GetOutput() );
> rescale->SetOutputMinimum( 0 );
> rescale->SetOutputMaximum( 255 );
>
> try
> {
> rescale->Update();
> }
> catch( itk::ExceptionObject & err )
> {
> std::cerr << "Exception caught: " << err << std::endl;
> return EXIT_FAILURE;
> }
>
>
>
>
> typedef itk::ImageSeriesWriter< OutputImageType, OutputImageType > ImageWriterType;
> ImageWriterType::Pointer writer = ImageWriterType::New();
>
>
> typedef itk::NumericSeriesFileNames NameGeneratorType;
> NameGeneratorType::Pointer nameGenerator1 = NameGeneratorType::New();
>
> std::string format = "output";
> format += "%03d.";
> format += "png"; // filename extension
> nameGenerator1->SetSeriesFormat( format.c_str() );
> InputImageType::ConstPointer inputImage = rescale->GetOutput();// The error is pointing here!!!!!!!!!!!!!!!!!!!!!!! I guess here is buggy??
This statement does not make sense. I mean a vtk smart pointer can not
= something from a GetOutput()
You may be able to
InputImageType::Pointer inputImage = InputImageType::New();
inputImage->GetInput(rescale->GetOutput());
but I am not 100% sure and to me this is not optimal. I did not answer
this question yesterday because I am not a vtk expert and your code
fragment was not enough for me do figure out what you really were
trying to do with this.
> InputImageType::RegionType region = inputImage->GetLargestPossibleRegion();
> InputImageType::IndexType start = region.GetIndex();
> InputImageType::SizeType size = region.GetSize();
>
> const unsigned int firstSlice = start[2];
> const unsigned int lastSlice = start[2] + size[2] - 1;
>
> nameGenerator1->SetStartIndex( firstSlice );
> nameGenerator1->SetEndIndex( lastSlice );
> nameGenerator1->SetIncrementIndex( 1 );
>
> writer->SetFileNames( nameGenerator1->GetFileNames() );
>
> Thanks a lot
> Wen Shi
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.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
>
--
John M. Drescher
More information about the vtkusers
mailing list