[Insight-developers] Be careful with temporary images and GraftOutput()

Miller, James V (Research) millerjv@crd.ge.com
Thu, 17 Oct 2002 12:32:10 -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_01C275F9.8343631C
Content-Type: text/plain;
	charset="iso-8859-1"

I spent the last five hours or so tracking down a problem where a filter was not properly passing the
spacing and origin through.  The cause of the problem was that the filter created a temporary image,
filled it with values, ran it through a mini-pipeline and then grafted the output of the
mini-pipeline onto is output.
 
The problem was the temporary image was not provided with the filter's input's spacing and origin.
So when the mini-pipeline fired, The default spacing and origin we used.  When the output of the
mini-pipeline was grafted on the filter's output, the original negotiated spacing and origin were
replaced with the default values.
 
The result was a polygonal representation of my segmentation did not align with my original image
when both were drawn in world coordinates.
 
To make the filter work properly, I just needed to add
 
temporaryImage->CopyInformation( this->GetInput() );
 
to the code that was constructing the temporary image (before the mini-pipeline was run).
 
Just wanted to warn people to be careful when using a temporary image within a filter.  If you call
GraftOutput(), the spacing and origin for your filter's output may be replaced by the spacing and
origin in your temporary image.  So make sure your temporary image has the proper spacing and origin
set.
 
(For the case at hand, I ended up not calling CopyInformation() and instead added another filter to
the mini-pipeline so that the input could be passed down directly through the mini-pipeline).

 <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

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

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

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

 

 

------_=_NextPart_001_01C275F9.8343631C
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.2715.400" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=883172316-17102002><FONT size=2>I spent the last five hours or 
so tracking down a problem where a filter was not properly passing the spacing 
and origin through.&nbsp; The cause of the problem was that the filter created a 
temporary image, filled it with values, ran it through a mini-pipeline and then 
grafted the output of the mini-pipeline onto is output.</FONT></SPAN></DIV>
<DIV><SPAN class=883172316-17102002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=883172316-17102002><FONT size=2>The problem was the temporary 
image was not provided with the filter's input's spacing and origin.&nbsp; So 
when the mini-pipeline fired, The default spacing and origin we used.&nbsp; When 
the output of the mini-pipeline was grafted on the filter's output, the original 
negotiated spacing and origin were replaced with the default 
values.</FONT></SPAN></DIV>
<DIV><SPAN class=883172316-17102002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=883172316-17102002><FONT size=2>The result was a&nbsp;polygonal 
representation of my segmentation did not align with my original image when both 
were drawn in world coordinates.</FONT></SPAN></DIV>
<DIV><SPAN class=883172316-17102002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=883172316-17102002><FONT size=2>To make the filter work 
properly, I just needed to add</FONT></SPAN></DIV>
<DIV><SPAN class=883172316-17102002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=883172316-17102002><FONT 
size=2>temporaryImage-&gt;CopyInformation( this-&gt;GetInput() 
);</FONT></SPAN></DIV>
<DIV><SPAN class=883172316-17102002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=883172316-17102002><FONT size=2>to the code that was 
constructing the temporary image (before the mini-pipeline was 
run).</FONT></SPAN></DIV>
<DIV><SPAN class=883172316-17102002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=883172316-17102002><FONT size=2>Just wanted to warn people to 
be careful when using a temporary image within a filter.&nbsp; If you call 
GraftOutput(), the spacing and origin for your filter's output may be replaced 
by the spacing and origin in your temporary image.&nbsp; So make sure your 
temporary image has the proper spacing and origin set.</FONT></SPAN></DIV>
<DIV><SPAN class=883172316-17102002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=883172316-17102002><FONT size=2>(For the case at hand, I ended 
up not calling CopyInformation() and instead added another filter to the 
mini-pipeline so that the input could be passed down directly through the 
mini-pipeline).</FONT></SPAN></DIV>
<DIV class=Section1>
<P class=MsoNormal>&nbsp;<?xml:namespace prefix = o ns = 
"urn:schemas-microsoft-com:office:office" /><o:p></o:p></P>
<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@research.ge.com">millerjv@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@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>
<P class=MsoNormal>&nbsp;<o:p></o:p></P></DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------_=_NextPart_001_01C275F9.8343631C--