[Insight-developers] Filters passing Spacing and Origin

Miller, James V (CRD) millerjv@crd.ge.com
Fri, 29 Jun 2001 17:24:19 -0400


I put in a fix that will pass an Image's spacing and origin through the pipeline.  What I have
implemented is a partial
solution to the problem.

State
--------

By default, a filter copies the meta data from its first input to all of its outputs.  This done by
ProcessObject::GenerateOutputInformation().  This method in turn calls output[i]->CopyInformation(
input[0] ).

[If a filter does not want to copy information from its first input to its output, then it would
override the method UpdateOutputInformation()]

CopyInformation is a virtual function that takes in a DataObject *.  Each subclass of DataObject
needs to provide a version of CopyInformation if it adds any ivars that need to be considered
meta-data.  In the case at hand, this meta-data would be the spacing and origin.  

Since the input to CopyInformation is a DataObject *, each implementation of CopyInformation attempts
to cast the pointer to Self.  If this cast succeeds, PhysicalImage will call GetSpacing() and
GetOrigin() of the input.  If this cast fails, PhysicalImage will attempt to cast the DataObject * to
its Superclass (in this case Image) and call GetSpacing() and GetOrigin() on that.  If that fails,
then it prints an error.

Files Modified
--------------------

itkPhysicalImage.h 
itkPhysicalImage.txx

Issues
----------

If a filter's input is of a different type than its output, then the cast operations in the current
implementation will fail and spacing and origin will not be copied.  If the input to a filter is a
PhysicalImage<float, 2> and the output is a PhysicalImage<short, 2>, (probably) qualify as different
types.  Thus a dynamic_cast from one to the other will fail and the spacing and origin will not be
copied.  

Possible solutions
--------------------------

1. Is there a way to determine if an object is an instantiation of a given template class?  i.e. can
you query whether something is a PhysicalImage (instead of a PhysicalImage<float, 2>)?

2. Use GetClassName() to detemine whether a given input is a class that we know has GetSpacing() and
GetOrigin().

3. Use a helper templated class that indicates whether a given class have GetSpacing()/GetOrigin()


The only tests of the current implementation were itkShrinkImageTest and itkThresholdImageTest.  In
the former, the spacing and origin are computed by the specified filter.  In the latter, the spacing
and origin are passed through the pipeline.





Jim Miller
_____________________________________
Visualization & Computer Vision 
GE Corporate Research & Development
Bldg. KW, Room C218B
P.O. Box 8, Schenectady NY 12301

millerjv@crd.ge.com <mailto:millerjv@crd.ge.com> 
(518) 387-4005, Dial Comm: 8*833-4005, 
Cell: (518) 505-7065, Fax: (518) 387-6981


 <<Miller, James V (CRD).vcf>> 

begin 600 Miller, James V (CRD).vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..DUI;&QE<CM*86UE<PT*1DXZ
M36EL;&5R+"!*86UE<R!6("A#4D0I#0I/4D<Z0U)$.T533`T*5$E43$4Z0V]M
M<'5T97(@4V-I96YT:7-T#0I414P[5T]22SM63TE#13HJ.#,S+30P,#4-"E1%
M3#M73U)+.U9/24-%.C$@-3$X(#,X-RTT,#`U#0I!1%([5T]22SH[2U<M0S(Q
M.$([4"Y/+B!";W@@.#M38VAE;F5C=&%D>3M.97<@66]R:SLQ,C,P,3M54T$-
M"DQ!0D5,.U=/4DL[14Y#3T1)3D<]455/5$5$+5!224Y404),13I+5RU#,C$X
M0CTP1#TP05`N3RX@0F]X(#@],$0],$%38VAE;F5C=&%D>2P@3F5W(%EO<FL@
M,3(S,#$],$0],$%54T$-"D5-04E,.U!2148[24Y415).150Z;6EL;&5R:G9`
M8W)D+F=E+F-O;0T*4D56.C(P,#$P-#(P5#$T,#,R.5H-"D5.1#I60T%21`T*
`
end