[Insight-developers] Allocation question

Richard Beare richard.beare at gmail.com
Mon Oct 9 22:04:58 EDT 2006


Hi everyone,

I'm experimenting with a filter that takes two input images and
produces two output images (class A). I'm adapting a threaded filter
that uses two inputs and produces one output. I'm attempting to
connect several of these together in a mini pipeline (class B).

I'm having a problem causing the allocation of the second mask image
to happen at an appropriate time.

I have the following methods defined in class A:

ThreadedGenerateData
GenerateInputRequestedRegion

I do the following in the constructor:

  this->SetNumberOfRequiredInputs( 2 );
  this->SetNumberOfRequiredOutputs( 2 );
  this->SetNthOutput( 0, this->MakeOutput( 0 ) );
  this->SetNthOutput( 1, this->MakeOutput( 1 ) );

and have the following for setting/getting input and output images

  void SetMaskImage(MaskImageType *input)
     {
     // Process object is not const-correct so the const casting is required.
     this->SetNthInput( 1, const_cast<TMaskImage *>(input) );
     }

  /** Get the marker image */
  MaskImageType * GetMaskImage()
    {
    return static_cast<MaskImageType*>(const_cast<DataObject
*>(this->ProcessObject::GetInput(1)));
    }


  /** Get the modified mask image */
  MaskImageType * GetOutputMask()
{
   return dynamic_cast<MaskImageType *>(
    this->GetOutput( 1 ) );
}
  /** Get the result image */
  OutputImageType * GetOutputImage()
{
   return dynamic_cast<OutputImageType *>(
    this->GetOutput( 0 ) );
}

In my mini pipeline filter I have one instance per dimension, connect
the two inputs of each filter to the outputs of the previous filter,
with the first one in the chain being connected to the inputs of the
meta filter.

My problem is that the GenerateInputRequestedRegion for my class A
filter is reporting that the mask image is null.

So the question is where to perform the allocation? I've experimented
with AllocateOutputs, and BeforeThreadedGenerateData, but without
success. I've no luck tracking down a sample filter either.

What is the correct place for this sort of thing to happen?

Thanks


More information about the Insight-developers mailing list