[Insight-developers] RE: GradientToMagnitudeImageFilter (was: Life without traits)

Miller, James V (CRD) millerjv@crd.ge.com
Tue, 17 Jul 2001 09:04:43 -0400


Lydia and Damion,

There was a powerpoint document that described the pipeline process.  I do not recall whether the
last version of that document was to this level of detail or not.  Clearly, we need an official LaTeX
document on the subject.  I do like the documentation of the pipeline in the source code.  The
related files are ProcessObject and ImageToImageFilter.  ProcessObject defines the overall
methodology and what each of the 4 methods you mentioned do.  ImageToImageFilter redefines a base
assumption of ProcessObject.  In ProcessObject, the default implementation for a filter is to request
the LargestPossibleRegion for its input, regardless of the requested output.  In ImageToImageFilter,
the default implementation for a filter is to request an input the same size as its output.

Lydia, your discussion of the pipeline is correct.  It sounds like the sections of the
GradientToMagnitudeImageFilter::GenerateData() method you identified for elimination should be
removed.

It also sounds likes using the UnaryImageFilter would be a good implementation. Though looking at the
UnaryImageFilter implementation, it has similar problems with redefining regions. I'll fix the
UnaryImageFilter.  Damion, if you want any help with the GradientToMagnitudeImageFilter, please let
me know.

Jim



-----Original Message-----
From: Lydia Ng [mailto:lydia_l_ng@hotmail.com]
Sent: Tuesday, July 17, 2001 2:47 AM
To: dmsst59@pitt.edu; Miller, James V (CRD)
Subject: GradientToMagnitudeImageFilter (was: Life without traits)


Jim, Damion:

> Since I removed ScalarTraits and Scalar, could you verify that the filters
you were trying to connect
> together but couldn't can now be connected together.

Not quite yet!

The filters I am trying to connect together is Luis's
GradientRecursiveGaussianImageFilter
and Damion's GradientToMagnitudeImageFilter. The image type I want to use is
Image<CovariantVector<float,3>,3> for the derivative and
Image<float,3> for the magnitude image.

Damion:  Following are the list of issues/problems I have come across with
GradientToMagnitudeImageFilter - they are mainly pipeline
related.

Jim: Please double-check what I have said about the pipeline is correct. Is
there a document
where all the pipeline stuff is specified?

---------------------
The main problem is that GradientToMagnitudeImageFilter::GenerateData() has
GetSpacing/GetOrigin and
SetSpacing/SetOrigion in it. Hence, preventing the use of  itk::Image as
input or output.
The pipeline mechanism has now been changed to pass Spacing/Origin
information along.
Since you are only copying the Spacing/Origin for the input to output, lines
62-71
is not neccessary. Removing these lines also have the advantage of allowing
the use of
itk::Image as input or output.

------------------
Pipeline-related issues:

I think all input and output region "requests" are suppose to be done
before we even get to GenerateData().

If you want to make the input requested region larger or smaller than the
output
requested region you need to override
ProcessObject::GenerateInputRequestRegion()

If you want to make your output to have different spacing/origin
to the input you need to override ProcessObject::UpdateOutputInformation()

If you want your output be a different size to the input you need to
override
ProcessObject::GenerateOutputInformation()

If your algorithm can only generate output for the whole image,
you need to override ProcessObject::EnlargeOutputRequestedRegion()

It seems to me that you don't really have to do any of the above for the
GradientToMagnitudeImageFilter.

Once you are inside GenerateData(), I think all you are allow to do is
    outputPtr->SetBufferedRegion( outputPtr->GetRequestedRegion() );
    outputPtr->Allocate();

All the stuff between lines 33-50 can be replace by the above two lines.

----------------
Line 73:
    double acc = 0;

Did you mean for that to be *outside* the for loop?

---------------
As per discussion on BinomialBlurImageFilter:

- GetIndex, GetPixel, SetPixel are expensive -
since you don't really need to know about the index
you will get much faster performance if you just use the Get/Set methods
of iterators.

- this filter too can easily be multi-threaded

-----------------
Having said all that - I think this filter can easily be implementated
as one of Luis's UnaryImageFilter.
Then all you need is to define a magnitude function the *.h file
(see example in attached file)

Cheers,
Lydia