[Insight-users] any filter to calculate the norm of a vector image?

Hua-Mei Chen huameichen0523 at gmail.com
Thu Oct 9 12:02:17 EDT 2008


Dear ITK users/developers,

        I used itkImage with vector pixel type to store both the deformation 
field resulting from a deformable registration method and the ground truth. 
To evaluate the registration accuracy, I need to subtract these two 
deformation fields and find the maximum or average of the norm of the 
difference image. I found that there is an itkSubtractImageFilter that works 
well with vector images. But, I can not find any filter to calculate the 
norm. For my purpose, I modified the itkSubtractImageFilter so that it 
returns the square of the norm of the difference image rather than the 
difference image.  What I did was to change the inline operator( ) function 
of the Sub2 class from

inline TOutput operator()( const TInput1 & A, const TInput2 & B)
{ return (TOutput)(A - B); }

to

inline TOutput operator()( const TInput1 & A, const TInput2 & B)

{ return (TOutput)(A[0] - B[0])*(A[0] - B[0])+(A[1] - B[1])*(A[1] - B[1]); }



Probably you have spotted my problem. The implementation I wrote required 
the knowledge of the dimension of the pixel type. In the above case, it is 
two.

For 3D registration applications, I will need another function like the one 
shown below:

 inline TOutput operator()( const TInput1 & A, const TInput2 & B)

{ return (TOutput)(A[0] - B[0])*(A[0] - B[0])+(A[1] - B[1])*(A[1] - 
B[1])])+(A[2] - B[2])*(A[2] - B[2]); }



My question is, how should I do so that I do not need to have two seperate 
filters, one for 2D and another one for 3D cases?

Also, in itkSubtractImageFilter, there is an "AdditiveOperators" concept 
used by the concept checking. Is there a "multiplicativeOperators" concept? 
Where can I find all the conpects used by ITK?

Given 2 vectors A and B, can we define A*B? How to find the dimension of a 
given vector? How and where should the implementation be placed?

Any response is appreciated. Thank you.



Chen











More information about the Insight-users mailing list