<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Re: [Insight-users] erosion performance for binary images</TITLE>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18702"></HEAD>
<BODY>
<DIV dir=ltr align=left>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial>Hi Dan and Gaetan,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial>First of all: thanks for your feedback.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial>I&nbsp;forgot about&nbsp;the importance of the specific choice 
of the kernel. That makes sense of course. In my test code I used the 
line</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial>&nbsp;&nbsp;&nbsp; erosionFilter-&gt;SetRadius( radii[ i ] 
);</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial>and&nbsp;assumed it would be give a ball. Now I 
use:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial>&nbsp;&nbsp;&nbsp; erosionFilter-&gt;SetKernel( 
itk::FlatStructuringElement&lt;Dimension&gt;::Box( radius ) 
);</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial>or</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial>&nbsp;&nbsp;&nbsp; erosionFilter-&gt;SetKernel( 
itk::FlatStructuringElement&lt;Dimension&gt;::Ball( radius ) 
);</FONT></DIV></SPAN><SPAN class=031202716-05062009></SPAN>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial>Then&nbsp;the&nbsp;VHGW filter&nbsp;indeed did not run for the 
Ball, because it is not decomposable.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial>The new performance results for ball and box are in the 
attachments. For the box the binary erode still seems to be faster up till a 
radius of 8, after which the VHGW takes over. The latter is not constant for 
increasing radius though.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=031202716-05062009><FONT color=#0000ff 
size=2 face=Arial>I added the source code in the zip, so you can reproduce the 
results. You can also find the binary image on which I did the test in the 
zip.</FONT></SPAN></DIV></DIV><BR>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px" 
dir=ltr>
  <DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>
  <HR tabIndex=-1>
  <FONT size=2 face=Tahoma><B>From:</B> Gaëtan Lehmann 
  [mailto:gaetan.lehmann@jouy.inra.fr] <BR></FONT></DIV></BLOCKQUOTE><PRE dir=ltr>The algorithm used in BinaryErodeImageFilter can't be easily&nbsp;<BR>constrained to a zone, and so it is difficult to multithread it.<BR>If you want to perform an erosion with a radius of 1 (on all the&nbsp;<BR>dimension), BinaryContourImageFilter followed by a SubtractImageFilter&nbsp;<BR>would be a lot faster (really) especially on a multicore system, as&nbsp;<BR>they are both multithreaded. Some timings are available in section 3&nbsp;<BR>of <A href="http://insight-journal.com/download/viewpdf/217/2">http://insight-journal.com/download/viewpdf/217/2</A><BR><SPAN class=171344316-05062009>&nbsp;</SPAN><SPAN class=171344316-05062009>&nbsp;</SPAN></PRE><PRE dir=ltr><SPAN class=171344316-05062009><FONT color=#0000ff size=2 face=Arial>I just assumed it would be, since there were multi-threaded versions for grayscale images. But it's an entirely different algorithm I guess.</FONT></SPAN></PRE><PRE dir=ltr><SPAN class=171344316-05062009><FONT color=#0000ff size=2 face=Arial>Regards,</FONT></SPAN></PRE><PRE dir=ltr><SPAN class=171344316-05062009><FONT color=#0000ff size=2 face=Arial>Marius</FONT></SPAN></PRE></BODY></HTML>