[Insight-developers] Allocation question

Miller, James V (GE, Research) millerjv at crd.ge.com
Tue Oct 10 11:55:30 EDT 2006


Richard, 

If your output images are different types, then you need to override the
MakeOutput() method to create an image of the appropriate type for the
mask.

You may also need to override the AllocateOutputs() method to allocate
the pixel data.

Jim 

-----Original Message-----
From: insight-developers-bounces+millerjv=crd.ge.com at itk.org
[mailto:insight-developers-bounces+millerjv=crd.ge.com at itk.org] On
Behalf Of Richard Beare
Sent: Monday, October 09, 2006 10:05 PM
To: insight-developers at itk.org
Subject: [Insight-developers] Allocation question

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
_______________________________________________
Insight-developers mailing list
Insight-developers at itk.org
http://www.itk.org/mailman/listinfo/insight-developers


More information about the Insight-developers mailing list