<font><font face="verdana,sans-serif">Your code looks logical. Can you test it with lower dimensionality as in this <a href="http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/ResampleImageFilter">example</a>? Use white triangle instead of square, and different x and y spacings. Maybe that way you will spot a problem.<br>

</font></font><br><div class="gmail_quote">2012/3/22 Xiaopeng Yang <span dir="ltr">&lt;<a href="mailto:yxp233@postech.ac.kr">yxp233@postech.ac.kr</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">I used linear interpolation in my code. Please have a look at my code:<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe;color:blue">       typedef</span><span style="font-size:10.0pt;font-family:DotumChe"> itk::IdentityTransform&lt; <span style="color:blue">double</span>, 3 &gt; <u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">              TransformType; <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe"><u></u> <u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       <span style="color:blue">typedef</span> itk::LinearInterpolateImageFunction&lt; OutputImageType, <span style="color:blue">double</span> &gt; <u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">              InterpolatorType; <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe"><u></u> <u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       <span style="color:blue">typedef</span> itk::ResampleImageFilter&lt; OutputImageType, OutputImageType &gt; <u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">              ResampleFilterType; <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe"><u></u> <u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       InterpolatorType::Pointer interpolator = InterpolatorType::New(); <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">

<span style="font-size:10.0pt;font-family:DotumChe"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       TransformType::Pointer transform = TransformType::New(); <u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       transform-&gt;SetIdentity(); <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe"><u></u> <u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       OutputImageType::SizeType inputSize = filter2-&gt;GetOutput()-&gt;GetLargestPossibleRegion().GetSize();<span style="color:green">//filter2 is the segmented binary image</span><u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">    <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       OutputImageType::SpacingType inputSpacing = filter2-&gt;GetOutput()-&gt;GetSpacing();<u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       OutputImageType::SpacingType outputSpacing;<u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       outputSpacing[0] = inputSpacing[0];<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       outputSpacing[1] = inputSpacing[1];<u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       outputSpacing[2] = 0.7;<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe"><u></u> <u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       OutputImageType::SizeType outputSize; <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:10.0pt;font-family:DotumChe">       <span style="color:blue">typedef</span> OutputImageType::SizeType::SizeValueType SizeValueType; <u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       outputSize[0] = <span style="color:blue">static_cast</span>&lt;SizeValueType&gt;(inputSize[0] * inputSpacing[0] / outputSpacing[0] + .5); <u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       outputSize[1] = <span style="color:blue">static_cast</span>&lt;SizeValueType&gt;(inputSize[1] * inputSpacing[1] / outputSpacing[1] + .5); <u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       outputSize[2] = <span style="color:blue">static_cast</span>&lt;SizeValueType&gt;(inputSize[2] * inputSpacing[2] / outputSpacing[2] + .5); <u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       ResampleFilterType::Pointer resampler = ResampleFilterType::New(); <u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       resampler-&gt;SetInput( filter2-&gt;GetOutput() ); <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">

<span style="font-size:10.0pt;font-family:DotumChe">       resampler-&gt;SetTransform( transform ); <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       resampler-&gt;SetInterpolator( interpolator ); <u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       resampler-&gt;SetOutputOrigin ( filter2-&gt;GetOutput()-&gt;GetOrigin()); <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">

<span style="font-size:10.0pt;font-family:DotumChe">       resampler-&gt;SetOutputSpacing ( outputSpacing ); <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       resampler-&gt;SetOutputDirection ( filter2-&gt;GetOutput()-&gt;GetDirection()); <u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       resampler-&gt;SetSize ( outputSize ); <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:10.0pt;font-family:DotumChe">       resampler-&gt;UpdateLargestPossibleRegion();<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       <span style="color:green">//resampler-&gt;Update ();<u></u><u></u></span></span></p><p class="MsoNormal" style="text-autospace:none">

<span style="font-size:10.0pt;font-family:DotumChe">   <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       ExportFilterType2::Pointer itkExporter4 = ExportFilterType2::New();  <u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       itkExporter4-&gt;SetInput( resampler-&gt;GetOutput() );<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">

<span style="font-size:10.0pt;font-family:DotumChe">       itkExporter4-&gt;Update();<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe"><u></u> <u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       vtkImageImport* vtkImporter4 = vtkImageImport::New();  <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:DotumChe">       ConnectPipelines(itkExporter4, vtkImporter4);</span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u><u></u></span></p>

<div class="im"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       vtkContourFilter *iso = vtkContourFilter::New();<u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       iso-&gt;SetInput(vtkImporter4-&gt;GetOutput());<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">

<span style="font-size:10.0pt;font-family:DotumChe">       iso-&gt;ComputeScalarsOn();<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:DotumChe">       iso-&gt;SetValue(0,128.1);<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:10.0pt;font-family:DotumChe"><u></u> <u></u></span></p></div><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       vtkPolyDataMapper *isoMapper = vtkPolyDataMapper::New();<u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       isoMapper-&gt;SetInput(iso-&gt;GetOutput());<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">

<span style="font-size:10.0pt;font-family:DotumChe">       isoMapper-&gt;ScalarVisibilityOff();<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe"><u></u> <u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       iso-&gt;Delete();<u></u><u></u></span></p><div class="im"><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe;color:green"><u></u> <u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       vtkActor *isoActor1 = vtkActor::New();<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:10.0pt;font-family:DotumChe">       isoActor1-&gt;SetMapper(isoMapper);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       isoActor1-&gt;GetProperty()-&gt;SetColor(1.0, 0.49, 0.25);<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">

<span style="font-size:10.0pt;font-family:DotumChe">       <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       isoMapper-&gt;Delete();<u></u><u></u></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:DotumChe">       ren_L-&gt;AddActor(isoActor1);<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:10.0pt;font-family:DotumChe">       </span><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u><u></u></span></p></div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">

<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> Dženan Zukić [mailto:<a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a>] <br>

<b>Sent:</b> Thursday, March 22, 2012 6:48 PM</span></p><div class="im"><br><b>To:</b> Xiaopeng Yang<br><b>Cc:</b> Kent Ogden; <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><br><b>Subject:</b> Re: [Insight-users] How to smooth the segmented surface<u></u><u></u></div>

<p></p></div><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;">For the resampling you have to make sure to use either linear, cubic, or some more advanced interpolation scheme, not the nearest neighbor which is the default I think.</span><u></u><u></u></p>

<div><div class="h5"><div><p class="MsoNormal">2012/3/22 Xiaopeng Yang &lt;<a href="mailto:yxp233@postech.ac.kr" target="_blank">yxp233@postech.ac.kr</a>&gt;<u></u><u></u></p><div><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">I resampled the segmented mask images. But when I apply vtkcontourfilter to generate a 3D surface, only iso-surfaces of the original slices of the mask images are generated, not including the resampled slices. Thus the results look the same as before. Still stairs appear.</span><u></u><u></u></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Thanks,</span><u></u><u></u></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Xiaopeng </span><u></u><u></u></p><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">

<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> Dženan Zukić [mailto:<a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a>] <br>

<b>Sent:</b> Wednesday, March 21, 2012 7:07 PM<br><b>To:</b> Xiaopeng Yang<br><b>Cc:</b> Kent Ogden; <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a></span><u></u><u></u></p><div><p class="MsoNormal">

<br><b>Subject:</b> Re: [Insight-users] How to smooth the segmented surface<u></u><u></u></p></div></div><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;">You can <a href="http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/ResampleImageFilter" target="_blank">resample</a> the image, or use linear <a href="http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/LinearInterpolateImageFunction" target="_blank">interpolator</a>.</span><u></u><u></u></p>

<div><div><p class="MsoNormal">On Tue, Mar 20, 2012 at 14:07, Xiaopeng Yang &lt;<a href="mailto:yxp233@postech.ac.kr" target="_blank">yxp233@postech.ac.kr</a>&gt; wrote:<u></u><u></u></p></div><div><div><div style="margin-left:3.0pt;margin-top:3.0pt;margin-right:3.0pt;margin-bottom:.75pt">

<div><div><p class="MsoNormal"><span style="color:#1f497d">Hi Kent,</span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">Do you know any interpolate class in ITK which can generate more slices? For volumetry, I guess I can use the original data.</span><u></u><u></u></p>

<p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">Thanks,</span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">Xiaopeng</span><u></u><u></u></p>

</div><p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> Kent Ogden [mailto:<a href="mailto:ogdenk@upstate.edu" target="_blank">ogdenk@upstate.edu</a>] <br>

<b>Sent:</b> Tuesday, March 20, 2012 9:50 PM<br><b>To:</b> <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>; Xiaopeng Yang</span><u></u><u></u></p><div><p class="MsoNormal"><br><b>Subject:</b> Re: [Insight-users] How to smooth the segmented surface<u></u><u></u></p>

</div></div></div><p class="MsoNormal"> <u></u><u></u></p><p style="margin:0in;margin-bottom:.0001pt"><span style="font-size:18.0pt">Xiaopeng,</span> <u></u><u></u></p><div><p class="MsoNormal"> <u></u><u></u></p><p style="margin:0in;margin-bottom:.0001pt">

<span style="font-size:18.0pt">This is a fundamental limitation of your data that can only truly be solved by reconstructing thinner slices at the time of the scan.  You could interpolate between images to generate more slices, which would result in a smoother looking rendering.  If you are trying to make quantitative measurements (e.g. volume) you must be careful about these kinds of manipulations though.</span> <u></u><u></u></p>

<p class="MsoNormal"> <u></u><u></u></p><p style="margin:0in;margin-bottom:.0001pt"><span style="font-size:18.0pt">Kent</span> <u></u><u></u></p><p class="MsoNormal" style="margin-bottom:12.0pt"> <u></u><u></u></p><p style="margin:0in;margin-bottom:.0001pt">

<br><br>&gt;&gt;&gt; &quot;Xiaopeng Yang&quot; &lt;<a href="mailto:yxp233@postech.ac.kr" target="_blank">yxp233@postech.ac.kr</a>&gt; 3/19/2012 10:17 PM &gt;&gt;&gt;<u></u><u></u></p></div><div><p class="MsoNormal">Dear Users, <u></u><u></u></p>

<div><div><p class="MsoNormal">  <u></u><u></u></p><p class="MsoNormal">I have tried to segment the liver from 5 mm CT slices. When I tried to visualize the segmented liver in 3D, I found that the surface of the 3D liver was discrete, just like stairs. I guess that is because of the 5 mm interval between CT slices. Do you guys have any good idea how to make the 3D surface of the liver look continuous and smooth? <u></u><u></u></p>

<p class="MsoNormal">  <u></u><u></u></p><p class="MsoNormal">Thanks, <u></u><u></u></p><p class="MsoNormal">Xiaopeng <u></u><u></u></p></div></div></div></div></div></div></div><p class="MsoNormal" style="margin-bottom:12.0pt">

<u></u> <u></u></p><div><p class="MsoNormal">_____________________________________<br>Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>Kitware offers ITK Training Courses, for more information visit:<br><a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br><br>Please keep messages on-topic and check the ITK FAQ at:<br>

<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><u></u><u></u></p>

</div></div><p class="MsoNormal"> <u></u><u></u></p></div></div></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div></blockquote></div><br>