<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Paul,<div><br></div><div>Thanks for the information.</div><div><br></div><div>What sigma and alpha parameters do you use for the GaussianInterpolator? The frequently used 1*spacing for sigma, and even .8*spacing seem to give a rather soft image after sampling. Do very the parameters based on you task?</div><div><br></div><div>I will go ahead and make a patch which changes the default boundary condition for the interpolator.</div><div><br></div><div>Thanks,</div><div>Brad</div><div><br></div><div><br><div><div>On Dec 19, 2012, at 3:55 PM, Paul Yushkevich <<a href="mailto:pauly2@mail.med.upenn.edu">pauly2@mail.med.upenn.edu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><div dir="ltr">Hi Brad,<div><br></div><div style="">I think you are right, the default BC should be changed to use the zero flux. And probably the filter should be changed to integrate the kernel. I haven't actually been using it much myself, the underlying problem with the sinc filter is that it causes ringing at the edges, and these days I tend to use a Gaussian filter when linear/bspline are not sufficient.</div>
<div style=""><br></div><div style="">Paul.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Dec 19, 2012 at 10:34 AM, Nicholas Tustison <span dir="ltr"><<a href="mailto:ntustison@gmail.com" target="_blank">ntustison@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I love that you can just run testing like that with only a couple lines.<br>
That's really cool.<br>
<br>
Unfortunately, I don't know the answer to your question but Paul might.<br>
I'm cc'ing him on this and hopefully he'll see it and be able to answer.<br>
<br>
Nick<br>
<br>
<br>
On Dec 19, 2012, at 9:22 AM, Bradley Lowekamp <<a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a>> wrote:<br>
<br>
> Hello Nick,<br>
><br>
> Thanks for getting back to me on this.<br>
><br>
> I also ran the Sinc interpolators on a constant image, and I got a larger error than expected. The following Python code was run with the ZeroFlux boundary condition and the radius template parameter of 5:<br>
><br>
> # Create a image of all ones<br>
> img = sitk.Image( 10, 10 , sitk.sitkFloat64 )<br>
> img += 1<br>
<div class="im">><br>
> iterps = [sitk.sitkNearestNeighbor,<br>
> sitk.sitkLinear,<br>
> sitk.sitkBSpline,<br>
> sitk.sitkGaussian,<br>
> sitk.sitkHammingWindowedSinc,<br>
> sitk.sitkCosineWindowedSinc,<br>
> sitk.sitkWelchWindowedSinc,<br>
> sitk.sitkLanczosWindowedSinc,<br>
> sitk.sitkBlackmanWindowedSinc]<br>
><br>
</div>> for i in iterps:<br>
> eimg= sitk.Expand( img, [10,10], i )<br>
> print "RMS:",(sum( (1-eimg)**2)/len(eimg))**.5, "Abs:", max(sitk.Abs(1-eimg))<br>
><br>
> RMS: 0.0 Abs: 0.0<br>
> RMS: 0.0 Abs: 0.0<br>
> RMS: 1.90178968104e-16 Abs: 5.55111512313e-16<br>
> RMS: 0.0 Abs: 0.0<br>
> RMS: 0.00519432546396 Abs: 0.007170554427<br>
> RMS: 0.00111584107245 Abs: 0.00190357704047<br>
> RMS: 0.000697067283848 Abs: 0.00118879124085<br>
> RMS: 0.00143647177089 Abs: 0.00245097611656<br>
> RMS: 0.000491351024756 Abs: 0.000833429218405<br>
><br>
> Skimming through the code it looks like the kernel is point sampled and not integrated over the pixel. I wonder if that is the issue.<br>
><br>
> Brad<br>
<div class="HOEnZb"><div class="h5">><br>
> On Dec 18, 2012, at 3:03 PM, Nicholas Tustison <<a href="mailto:ntustison@gmail.com">ntustison@gmail.com</a>> wrote:<br>
><br>
>> Hi Brad,<br>
>><br>
>> Yeah, we just use the default. We've probably never noticed it since,<br>
>> as you say, we typically are interpolating a blob in the middle of a black<br>
>> background.<br>
>><br>
>> I think Paul Yushkevich wrote those windowed sinc interpolators. You<br>
>> might want to ask him why they're the default.<br>
>><br>
>> Nick<br>
>><br>
>><br>
>><br>
>> On Dec 18, 2012, at 1:09 PM, Bradley Lowekamp <<a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a>> wrote:<br>
>><br>
>>> Hello,<br>
>>><br>
>>> As I am finally integrating the different interpolators into SimpleITK. I am giving them a close look over.<br>
>>><br>
>>> The set of WindowSincInterpolateImageFunctions takes a Boundary condition template parameter. This defaults to ConstantBoundaryCondition. That is by default the pixels are zero outside the image, and they are not zero flux. This results in quite a bit of ringing and fading around my test images. It seems just wrong.<br>
>>><br>
>>> I can easily specify this parameter as the ZeroFluxNeumannBoundaryCondition (I don't think we have a mirror/reflective boundary, which is another possibility), and things look quite good and as I expect the output to be. I was curious as to what others were doing so I perused BRAINS and ANTS, grepping for the sinc interpolator. And to my surprise they are using the default!<br>
>>><br>
>>> Is there a reason that this default is preferred? Or is it that I am not processing a single blob in the center of a black image (aka a brain)?<br>
>>><br>
>>> Also in terms of consistency across the interpolators, this is the only one which takes a boundary condition template parameters. The other interpolators appear to behave sensibly, and exhibit a zero-flux type boundary condition. I think the default for this may need to be changed.<br>
>>><br>
>>><br>
>>> I have this little example I have been working on in SimpleITK with the famed cthead1.png data input. Here is a code snippet:<br>
>>><br>
>>><br>
>>> image = image[(size[0]//2-25):(size[0]//2+25),(size[1]//2-25):(size[1]//2+25)]<br>
>>><br>
>>><br>
>>> iterps = [sitk.sitkNearestNeighbor,<br>
>>> sitk.sitkLinear,<br>
>>> sitk.sitkBSpline,<br>
>>> sitk.sitkGaussian,<br>
>>> sitk.sitkHammingWindowedSinc,<br>
>>> sitk.sitkCosineWindowedSinc,<br>
>>> sitk.sitkWelchWindowedSinc,<br>
>>> sitk.sitkLanczosWindowedSinc,<br>
>>> sitk.sitkBlackmanWindowedSinc]<br>
>>><br>
>>> eFactor=5<br>
>>><br>
>>> image_list = []<br>
>>><br>
>>> for i in iterps:<br>
>>> image_list.append( sitk.Expand( image, [eFactor]*3, i ))<br>
>>><br>
>>> tiles = sitk.Tile( image_list, [3,0] )<br>
>>><br>
>>> And the following is the output with the different boundary conditions:<br>
>>><br>
>>> <a href="http://erie.nlm.nih.gov/~blowek1/images/expand_interp_cbc.png" target="_blank">http://erie.nlm.nih.gov/~blowek1/images/expand_interp_cbc.png</a><br>
>>> <a href="http://erie.nlm.nih.gov/~blowek1/images/expand_interp_zfbc.png" target="_blank">http://erie.nlm.nih.gov/~blowek1/images/expand_interp_zfbc.png</a><br>
>>><br>
>>> Thanks for you feedback,<br>
>>> Brad<br>
>><br>
><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Paul A. Yushkevich, Ph.D. <br>Assistant Professor<br>Penn Image Computing and Science Laboratory<br>Department of Radiology<br>University of Pennsylvania<br>
</div>
</blockquote></div><br></div></body></html>