Hi All.<br><br>I have the following function to register models (modReader) to the size of an active contour (contActivo). Xsize, ysize and zsize are the number of rows, columns and slices of active contour bounding box.<br>
<br>When I execute it, the output of the Resample filter is all zero. I don&#39;t know what I&#39;m doing wrong.<br>I need your help.<br><br>typedef signed short PixelType;<br>typedef itk::Image&lt; PixelType, 3 &gt; ImageType;<br>
typedef double FPixelType;<br>typedef itk::Image&lt; FPixelType, 3 &gt; FImageType;<br>typedef itk::ImageSeriesReader&lt; ImageType &gt; ReaderType;<br><br>ImageType::Pointer adaptarModeloImg4D(ReaderType::Pointer modReader,int xsize,int ysize,int zsize,FImageType::Pointer contActivo)<br>
{<br>&nbsp;&nbsp;&nbsp; typedef itk::ResampleImageFilter&lt;ImageType,ImageType&gt; ResampleFilter;<br>&nbsp;&nbsp;&nbsp; ResampleFilter::Pointer filResample = ResampleFilter::New();<br>&nbsp;&nbsp;&nbsp; filResample-&gt;SetInput(modReader-&gt;GetOutput());<br>&nbsp;&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp;&nbsp; typedef itk::LinearInterpolateImageFunction&lt;ImageType, double &gt; InterpolatorType;<br>&nbsp;&nbsp;&nbsp; InterpolatorType::Pointer interpolator = InterpolatorType::New();<br>&nbsp;&nbsp;&nbsp; filResample-&gt;SetInterpolator(interpolator);<br>
&nbsp;&nbsp;&nbsp; filResample-&gt;SetDefaultPixelValue(0);<br>&nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp; const FImageType::SpacingType&amp; spacing = contActivo-&gt;GetSpacing();<br>&nbsp;&nbsp;&nbsp; const FImageType::PointType&amp; origin = contActivo-&gt;GetOrigin();<br>&nbsp;&nbsp;&nbsp; FImageType::SizeType sizeCA = contActivo-&gt;GetLargestPossibleRegion().GetSize();<br>
&nbsp;&nbsp;&nbsp; ImageType::SizeType sizeMod = modReader-&gt;GetOutput()-&gt;GetLargestPossibleRegion().GetSize();<br>&nbsp;&nbsp;&nbsp; filResample-&gt;SetOutputOrigin(origin);<br>&nbsp;&nbsp;&nbsp; filResample-&gt;SetOutputSpacing(spacing);<br>&nbsp;&nbsp;&nbsp; filResample-&gt;SetSize(sizeCA);<br>
<br>&nbsp;&nbsp;&nbsp; // Computing scale on rows, columns and slices<br>&nbsp;&nbsp;&nbsp; double scaleX = (double)xsize/(double)sizeMod[1];<br>&nbsp;&nbsp;&nbsp; double scaleY = (double)ysize/(double)sizeMod[0];<br>&nbsp;&nbsp;&nbsp; double scaleZ = (double)zsize/(double)sizeMod[2];<br>
&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; // Tanking the minimum scale<br>&nbsp;&nbsp;&nbsp; double scale = scaleX&lt;scaleY ? scaleX:scaleY;<br>&nbsp;&nbsp;&nbsp; scale = scale&lt;scaleZ ? scale:scaleZ;<br><br>&nbsp;&nbsp;&nbsp; typedef itk::Similarity3DTransform&lt; double &gt; TransformType;<br>
&nbsp;&nbsp;&nbsp; TransformType::Pointer transform = TransformType::New();<br>&nbsp;&nbsp;&nbsp; transform-&gt;SetScale(scale);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp; &nbsp; // Computing the beginning of the active contour <br>&nbsp;&nbsp;&nbsp; int posY= floor(((double)sizeCA[0]-(double)sizeMod[0]*scale)/2);<br>
&nbsp;&nbsp;&nbsp; int posX= floor(((double)sizeCA[1]-(double)sizeMod[1]*scale)/2);<br>&nbsp;&nbsp;&nbsp; int posZ= floor(((double)sizeCA[2]-(double)sizeMod[2]*scale)/2);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; // Moving model to active contour beginning<br>&nbsp;&nbsp;&nbsp; TransformType::OutputVectorType translation;<br>
&nbsp;&nbsp;&nbsp; translation[0] = posY-origin[0];<br>&nbsp;&nbsp;&nbsp; translation[1] = posX-origin[1];<br>&nbsp;&nbsp;&nbsp; translation[2] = posZ-origin[2];<br><br>&nbsp;&nbsp;&nbsp; // Updating resample filter<br>&nbsp;&nbsp;&nbsp; transform-&gt;SetTranslation(translation);<br>&nbsp;&nbsp;&nbsp; filResample-&gt;SetTransform(transform);<br>
&nbsp;&nbsp;&nbsp; filResample-&gt;Update();<br><br>&nbsp;&nbsp;&nbsp; return filResample-&gt;GetOutput();<br>}<br><br>Thank you.<br>