[Insight-users] Problem when using seriesreader together with series writer
Wen Shi
wsa18 at sfu.ca
Mon Apr 13 18:40:48 EDT 2009
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??
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
More information about the Insight-users
mailing list