[Insight-developers] Allocation question
Richard Beare
richard.beare at gmail.com
Tue Oct 10 23:17:25 EDT 2006
Hi,
I've had some more success. It turned out that the problem with null
masks related to an incorrect dynamic cast in the function that
returned the mask pointer.
However I still have some other problems that I'm confused about. At
present the mini pipeline runs, but seg faults on exit in the
unregister method.
This makes me wonder whether I've done the allocation correctly.
I started using a MakeOutput method, but the only examples I found
called this from class constructors.
I then used SignedDanielssonDistanceMapImageFilter as a template and
did setting and ::New calls in my constructor. Is this a reasonable
way to go?
However I suspect that my problem may be related to correctly
"sinking" my last mask output.
My meta filter has two inputs - image and mask, and one output. The
filters in the mini pipeline each have two inputs (image and mask) and
two outputs (filtered image and updated mask). The mask output from
the last filter in the mini pipeline isn't connected to anything, and
I wonder if that matters. Is there a special way of terminating an
unwanted half of a pipeline, or do I need to write a special filter to
that doesn't produce two outputs to terminate the mini pipeline?
On 10/11/06, Richard Beare <richard.beare at gmail.com> wrote:
> Hi,
> The output images are different types. I have overriden MakeOutput and
> attempted to override AllocateOutputs, but didn't have any success.
> Can you think of any filters that I might use as examples? I haven't
> found anything yet.
>
> On 10/11/06, Miller, James V (GE, Research) <millerjv at crd.ge.com> wrote:
> > 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