[Insight-users] problems with imageserieswriter when using VED

Wen Shi wsa18 at sfu.ca
Sun Apr 12 20:49:14 EDT 2009


Thanks a lot for your reply John,

Now the first problem is fixed :).

As you mentioned the second problem occured when the writer try to read the output of the rescalefilter.
Now 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

----- Original Message -----
From: "John Drescher" <drescherjm at gmail.com>
To: "Wen Shi" <wsa18 at sfu.ca>, insight-users at itk.org
Sent: Sunday, April 12, 2009 5:25:19 PM GMT -08:00 US/Canada Pacific
Subject: Re: [Insight-users] problems with imageserieswriter when using VED

On Sun, Apr 12, 2009 at 7:50 PM, Wen Shi <wsa18 at sfu.ca> wrote:
> Hi Guys,
>
> As I heard from Luis that VED just deal with 3D images, I tried again using imageseriesreader to read in 5 slices image data and imageserieswriter to write the output slices.
> But I got these errors when using series writer:
>
> error C2015: too many characters in constant
> error C2664: 'itk::ImageSeriesWriter<TInputImage,TOutputImage>::SetInput' : cannot convert parameter 1 from 'itk::Image<TPixel,VImageDimension> *' to 'const itk::Image<TPixel,VImageDimension> *'1>
>
> (The responsive code is:
>  typedef itk::ImageSeriesWriter< InputImageType, OutputImageType  >      ImageWriterType;
>  ImageWriterType::Pointer writer = ImageWriterType::New();
>
>
>  typedef itk::NumericSeriesFileNames    NameGeneratorType;
>  NameGeneratorType::Pointer nameGenerator1 = NameGeneratorType::New();
>
>  std::string format = 'output'; //  The errorC2015 occured here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


In C or C++ single quotes surround a single character, not a string.
Use double quotes

" instead.


>  format += "%03d.";
>  format += 'bmp';   // filename extension
>  nameGenerator1->SetSeriesFormat( format.c_str() );
>
>  //writer->SetFileName( "vessel(enhanced).png"  );
>  writer->SetInput ( rescale->GetOutput() );
>
Looks like the error is here and not where  you said. The error talks
about SetInput(). I am not sure of the reason for the error because
you did not post what rescale was.

>
>  InputImageType::ConstPointer inputImage = rescale->GetOutput();
>  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() );// The errorC2664 occured here. !!!!!!!!!!!!
>
> I think maybe I misused the imageserieswriter.
>
> Could someone help me with this?
> Which parameter I should assign to the std::string format?
>
> Thanks a lot
>

John


More information about the Insight-users mailing list