[Insight-users] Hint: Tapping into ITK pipelines to visualize intermediate result s with VTK

Miller, James V (Research) millerjv@crd.ge.com
Thu, 17 Oct 2002 12:50:18 -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_01C275FD.466CCB1C
Content-Type: text/plain;
	charset="iso-8859-1"

Several of ITK's filters are designed so at the end of each iteration in the algorithm, the output of
the filter contains the "results so far".  For example, the finite difference filters (level sets,
etc.) trigger an IterationEvent as well as a ProgressEvent() so that you can tap into the output of
the current iteration as the filter is executing.
 
I put together a little application that shows a levelset expanded over an image.  To do this, I
originally tied the output of the levelset filter to a VTK pipeline to run MarchingSquares to extract
the zero level set and display the original image. This used the standard Exporter/Importer
facilities of VTK and ITK and wired the pipeline methods together so Update() would propagate between
VTK and ITK filters.
 
I tied a callback to the IterationEvent that told my VTK viewer to render.  
 
Unfortunately, telling a VTK viewer to render causes an Update() to propagate up the pipeline.  But
since the pipeline is already updating (since the level set code was running), the update mechanism
aborted and not data was drawn.
 
To address this, I separated the two pipelines.  The ITK pipeline read the data, preprocessed the
data, and ran the level set algorithm.  A separate pipeline was used to export data from ITK to VTK
and to visualize the data.  To separate the pipelines, I created an itk::Image and essentially
"grafted" the output of the levelset filter into this image.  (This copied the regions, spacing,
origin, and passed a reference to the pixel container from the output of the level to this separate
image).  I then passed this extra image through the standard ITK exporters and VTK importers. This
extra image did not have to copy the bulk pixel data (since I just passed a reference to the pixel
container) but it also did not have a "source" so the VTK pipeline could run asynchronously with the
ITK pipeline.
 
Now in my iteration callback, I reconfigured this extra image (copying regions, spacing, origin, and
reference to the pixel container), and told VTK to render.

When the examples/applications reconfiguration is complete, I'll put this application in as an
example.    

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 

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

 

------_=_NextPart_001_01C275FD.466CCB1C
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=323133216-17102002><FONT size=2>Several of ITK's filters are 
designed so at the end of each iteration in the algorithm, the output of the 
filter contains the "results so far".&nbsp; For example, the finite difference 
filters (level sets, etc.) trigger an IterationEvent as well as a 
ProgressEvent() so that you can tap into the output of the current iteration as 
the filter is executing.</FONT></SPAN></DIV>
<DIV><SPAN class=323133216-17102002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=323133216-17102002><FONT size=2>I put together a little 
application that shows a levelset expanded over an image.&nbsp; To do this, I 
originally tied the output of the levelset filter to a VTK pipeline to run 
MarchingSquares to extract the zero level set and display the original image. 
This used the standard Exporter/Importer facilities of VTK and ITK and wired the 
pipeline methods together so Update() would propagate between VTK and ITK 
filters.</FONT></SPAN></DIV>
<DIV><SPAN class=323133216-17102002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=323133216-17102002><FONT size=2>I tied a callback to the 
IterationEvent that told my VTK viewer to render.&nbsp; </FONT></SPAN></DIV>
<DIV><SPAN class=323133216-17102002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=323133216-17102002><FONT size=2>Unfortunately, telling a VTK 
viewer to render causes an Update() to propagate up the pipeline.&nbsp; But 
since the pipeline is already updating (since the level set code was running), 
the update mechanism aborted and not data was drawn.</FONT></SPAN></DIV>
<DIV><SPAN class=323133216-17102002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=323133216-17102002><FONT size=2>To address this, I separated 
the two pipelines.&nbsp; The ITK pipeline read the data, preprocessed the data, 
and ran the level set algorithm.&nbsp; A separate pipeline was used to export 
data from ITK to VTK and to visualize the data.&nbsp; To separate the pipelines, 
I created an itk::Image and essentially "grafted" the output of the levelset 
filter into this image.&nbsp; (This copied the regions, spacing, origin, and 
passed a reference to the pixel container from the output of the level to this 
separate image).&nbsp; I then passed this extra image through the standard ITK 
exporters and VTK importers. T</FONT></SPAN><SPAN class=323133216-17102002><FONT 
size=2>his extra image did not have to copy the bulk pixel data (since I just 
passed a reference to the pixel container) but it also did not have a "source" 
so the VTK pipeline could run asynchronously with the ITK 
pipeline.</FONT></SPAN></DIV>
<DIV><SPAN class=323133216-17102002><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=323133216-17102002><FONT size=2>Now in my iteration callback, I 
reconfigured this extra image (copying regions, spacing, origin, and reference 
to the pixel container), and told VTK to render.</FONT></SPAN></DIV>
<DIV class=Section1>
<P class=MsoNormal><SPAN class=323133216-17102002><FONT size=2>When the 
examples/applications&nbsp;reconfiguration is complete, 
I'll</FONT></SPAN>&nbsp;<SPAN class=323133216-17102002><FONT size=2>put this 
application in as an example.&nbsp;&nbsp;&nbsp; </FONT></SPAN></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;<?xml:namespace prefix = o ns = 
"urn:schemas-microsoft-com:office:office" /><o:p></o:p></P></DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------_=_NextPart_001_01C275FD.466CCB1C--