[Insight-developers] ImageToImageFilter, ExtractOrthogonalSwath2D

Miller, James V (Research) millerjv at crd . ge . com
Thu, 21 Aug 2003 17:11:13 -0400


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C36828.C07DAE9E
Content-Type: text/plain;
	charset="iso-8859-1"

The ExtractOrthogonalSwath2D test is crashing on all optimized builds of MS
VC++.  This filter
is an (eventual) subclass of ImageToImageFilter but one of its inputs is a
Path and not an Image.
There is code in ImageToImageFilter::GetInput() that static_cast's a pointer
to an input to a 
pointer to an Image.  So a Path gets munged into being an Image and
GenerateInputRequestedRegion()
crashes.  Strangely enough, this bug only reveals itself on optimize builds
of VC++.  All other platforms
and debug builds of VC++ seem to be fine.
 
There are a number of ways that this can be fixed.  One it not make the
ExtractOrthogonalSwath2D
filter derive (eventually) from an ImageToImageFilter.  But then its
superclass (ImageAndPathToImageFilter)
need to duplicate code from ImageToImageFilter which I am not in favor of.
 
My solution is to change the implementation of
ImageToImageFilter::GenerateInputRequestedRegion()
such that if an input is not a subclass of ImageBase (with the same
dimension as the TInputImage), then
it rest of the method is skipped for that input (the rest of the method
copies the RequestedRegion).
 
Therefore, it a filter is a subclass of ImageToImageFilter, has multiple
inputs,  and the inputs are not all a 
subclass of ImageBase with the same image dimension; then that filter will
need to implement GenerateInputRequestedRegion() and specify what to do with
the inputs that are not handled by
ImageToImageFilter::GenerateInputRequestedRegion().  It should be safe for
these filters to call the implementation in ImageToImageFilter first and
then set the RequestedRegion for the inputs not handled by
ImageToImageFilter.
 
I ran the tests and the only filter that may be failing due to this change
is the CannySegmentationLevelSetImageFilterTest.  I'll take a look at that
one.  
 
If you have any strange behaviors in your multiple input filters, please let
me know.
 
 

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

millerjv at research . ge . com <mailto:millerjv at research . ge . com> 

james . miller at research . ge . com
(518) 387-4005, Dial Comm: 8*833-4005, 
Cell: (518) 505-7065, Fax: (518) 387-6981 

 

------_=_NextPart_001_01C36828.C07DAE9E
Content-Type: text/html;
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 6.00.2800.1141" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=826135620-21082003><FONT size=2>The ExtractOrthogonalSwath2D 
test is crashing on all optimized builds of MS VC++.&nbsp; This 
filter</FONT></SPAN></DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2>is an (eventual) subclass of 
ImageToImageFilter but one of its inputs is a Path and not an 
Image.</FONT></SPAN></DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2>There is code in 
ImageToImageFilter::GetInput() that static_cast's a pointer to an input to a 
</FONT></SPAN></DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2>pointer to an Image.&nbsp; So a 
Path gets munged into being an Image and 
GenerateInputRequestedRegion()</FONT></SPAN></DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2>crashes.&nbsp; Strangely 
enough, this bug only reveals itself on optimize builds of VC++.&nbsp; All other 
platforms</FONT></SPAN></DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2>and debug builds of VC++ seem 
to be fine.</FONT></SPAN></DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2>There are a number of ways that 
this can be fixed.&nbsp; One it not make the 
ExtractOrthogonalSwath2D</FONT></SPAN></DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2>filter derive (eventually) from 
an ImageToImageFilter.&nbsp; But then its superclass 
(ImageAndPathToImageFilter)</FONT></SPAN></DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2>need to duplicate code from 
ImageToImageFilter which I am not in favor of.</FONT></SPAN></DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2>My solution is to change the 
implementation of 
ImageToImageFilter::GenerateInputRequestedRegion()</FONT></SPAN></DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2>such that if an input is not a 
subclass of ImageBase (with the same dimension as the TInputImage), 
then</FONT></SPAN></DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2>it rest of the method is 
skipped for that input (the rest of the method copies the 
RequestedRegion).</FONT></SPAN></DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2>Therefore, it a filter is a 
subclass of ImageToImageFilter, has multiple inputs,&nbsp; and the inputs are 
not all a </FONT></SPAN></DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2>subclass of ImageBase with the 
same </FONT></SPAN><SPAN class=826135620-21082003><FONT size=2>image dimension; 
then that filter will need to implement GenerateInputRequestedRegion() and 
specify what to do with the inputs that are not handled by 
ImageToImageFilter::GenerateInputRequestedRegion().&nbsp; It should be safe for 
these filters to call the implementation in ImageToImageFilter first and then 
set the RequestedRegion for the inputs not handled by 
ImageToImageFilter.</FONT></SPAN></DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2>I ran the tests and the only 
filter that may be failing due to this change is the 
CannySegmentationLevelSetImageFilterTest.&nbsp; I'll take a look at that 
one.&nbsp; </FONT></SPAN></DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=826135620-21082003><FONT size=2>If you have any strange 
behaviors in your multiple input filters, please let me 
know.</FONT></SPAN></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV>
<P style="MARGIN: 0in 0in 0pt"><B><SPAN 
style="COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">Jim Miller</SPAN></B> 
<BR><B><I><SPAN 
style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Arial">_____________________________________</SPAN></I></B><BR><EM><SPAN 
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial">Visualization &amp; 
Computer Vision</SPAN></EM><I><SPAN 
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial"><BR><EM>GE 
Research</EM><BR><EM>Bldg. KW, Room C218B</EM><BR><EM>P.O. Box 8, Schenectady NY 
12301</EM><BR><BR></SPAN></I><EM><U><SPAN 
style="FONT-SIZE: 7.5pt; COLOR: blue"><A 
href="mailto:millerjv at research . ge . com">millerjv at research . ge . com</A></SPAN></U></EM></P>
<P style="MARGIN: 0in 0in 0pt"><EM><U><SPAN 
style="FONT-SIZE: 7.5pt; COLOR: blue">james . miller at research . ge . com</SPAN></U></EM><BR><I><SPAN 
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial">(518) 387-4005, Dial 
Comm: 8*833-4005, </SPAN></I><BR><I><SPAN 
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial">Cell: (518) 505-7065, 
Fax: (518) 387-6981</SPAN></I> </P></DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------_=_NextPart_001_01C36828.C07DAE9E--