[Insight-developers] Operators with explicitly specified coef ficients

Miller, James V (Research) millerjv at crd.ge.com
Tue Jul 6 09:30:49 EDT 2004


Gunnar,

You certainly are not the only person needed such a capability. When I 
have needed a special kernel, I have bypassed the use of an operator
and just constructed/filled a neighborhood with the kernel values I needed.

But I think it makes to have an operator that does this.  Perhaps one
that is not limited to directional kernels as well.

As for ITK style issues, here are a few minor points:

1. The ITK style limits abbreviations to just a few abbreviations in 
widespread acceptance.  So the methods Set/GetCoeffs() should be written
out as SetCoefficients()/GetCoefficients().

2. You probably need a default constructor that will initialize the 
direction ivar and fill the coefficient vector with good default values
(maybe 1 at the center pixel and zeros elsewhere).

3. DirectionalOperator(int direction) and DirectionalOperator(int direction,
const std::vector<double> coeffs) - I am not sure about having these two 
additional constructors.  I don't think the other operators have
constructors
that take "direction" as an argument.  So to be consistent, this operator
should probably only have the default constructor and the copy constructor.
Users can use the SetDirection() and SetCoefficients() methods to populate
the operator.

4. ITK style is to preface calls to member functions with "this->", so
instead
of 
	SetDirection(direction);

we use

	this->SetDirection(direction);

5. You have a duplication of "data".  The coefficient vector is stored in 
an ivar and then again in the neighborhood.  You might want to look at 
trying to eliminate your ivar to hold the coefficient vector and just have
the coefficients stored in the neighborhood.





-----Original Message-----
From: Gunnar Farneback [mailto:gunnar at bwh.harvard.edu]
Sent: Friday, July 02, 2004 2:58 PM
To: insight-developers at public.kitware.com
Subject: [Insight-developers] Operators with explicitly specified
coefficients


I'm trying to implement yet another variation of the demons
registration algorithm in ITK. As part of the implementation I needed
a set of directional filters with specific coefficients
(algorithmically computed). I didn't find a simple way to create my
filters, however. The most straightforward way I could see would be to
subclass NeighborhoodOperator and implement a GenerateCoefficients()
method which computes the coefficients, but this would be rather
inconvenient since it's in my case natural to compute the coefficients
of all the filters at the same time, rather than one at a time.

Instead I wrote a subclass of NeighborhoodOperator called
DirectionalOperator, which is constructed with an explicit vector of
coefficients and a direction. I imagine I'm not the only one who may
want this functionality, so I submit it for inclusion into ITK.

However, I'm not sure I've managed to pick up all of the ITK design
ideas, so it's possible that this class doesn't really fit. If so,
please tell me if there's some better way to solve my problem (or ask
me to clarify if it's unclear what I want). In any case I expect that
there are various shortcomings in the code, so feel free to point
those out to me.

New file Insight/Code/Common/itkDirectionalOperator.h attached.

/Gunnar Farneback

Harvard Medical School            Brigham and Women's Hospital
Tel : (+1) 617-732-5931           Department of Radiology
Fax : (+1) 617-264-6887           Boston, MA 02115
Email: gunnar at bwh.harvard.edu     USA


More information about the Insight-developers mailing list