<div><br></div><div><br></div><div>Maybe change this</div><div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">resampler->SetInput(input);</span></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">to this</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><span class="Apple-style-span" style="font-size: 13px; ">resampler->SetInput( input->GetOutput() );</span></span></font></div>
<div><br></div><div><br></div><br><br><div class="gmail_quote">On Mon, Feb 15, 2010 at 10:21 PM, Richard Beare <span dir="ltr"><<a href="mailto:richard.beare@gmail.com">richard.beare@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<br>
I'm using an obviously buggy resampling procedure to upsample a small<br>
image that has been extracted from a larger one, and hence has non<br>
zero origin information. My result is blank, so I'm missing a setting<br>
somewhere, but don't have a clue as to what. Can anyone spot the<br>
problem?<br>
<br>
template <class RawIm><br>
typename RawIm::Pointer upsampleIm(typename RawIm::Pointer input,<br>
typename RawIm::SpacingType NewSpacing, int interp=1)<br>
{<br>
const int dim = RawIm::ImageDimension;<br>
typedef typename RawIm::PixelType PixelType;<br>
<br>
typedef typename itk::ResampleImageFilter<RawIm, RawIm > ResampleFilterType;<br>
typedef typename itk::IdentityTransform< double, dim > TransformType;<br>
typename ResampleFilterType::Pointer resampler = ResampleFilterType::New();<br>
<br>
input->Update();<br>
<br>
typename TransformType::Pointer transform = TransformType::New();<br>
transform->SetIdentity();<br>
resampler->SetTransform( transform );<br>
typedef typename itk::LinearInterpolateImageFunction<RawIm, double ><br>
LInterpolatorType;<br>
typedef typename itk::NearestNeighborInterpolateImageFunction<RawIm,<br>
double > NNInterpolatorType;<br>
<br>
typename ResampleFilterType::InterpolatorPointerType interpolator;<br>
switch (interp)<br>
{<br>
case 0:<br>
interpolator = NNInterpolatorType::New();<br>
break;<br>
case 1:<br>
interpolator = LInterpolatorType::New();<br>
break;<br>
default:<br>
std::cout << "Unsupported interpolator" << std::endl;<br>
}<br>
<br>
resampler->SetInterpolator( interpolator );<br>
resampler->SetDefaultPixelValue( 0 );<br>
<br>
const typename RawIm::SpacingType& inputSpacing = input->GetSpacing();<br>
typename RawIm::SpacingType spacing;<br>
typename RawIm::SizeType inputSize =<br>
input->GetLargestPossibleRegion().GetSize();<br>
typename RawIm::SizeType size;<br>
typedef typename RawIm::SizeType::SizeValueType SizeValueType;<br>
<br>
<br>
for (int i = 0; i < dim; i++)<br>
{<br>
float factor = inputSpacing[i]/NewSpacing[i];<br>
size[i] = static_cast< SizeValueType >( inputSize[i] * factor );<br>
}<br>
std::cout << inputSpacing << NewSpacing << std::endl;<br>
std::cout << inputSize << size << input->GetOrigin() << std::endl;<br>
<br>
resampler->SetSize( size );<br>
resampler->SetOutputSpacing( NewSpacing );<br>
resampler->SetOutputOrigin( input->GetOrigin() );<br>
resampler->SetOutputDirection(input->GetDirection());<br>
resampler->SetInput(input);<br>
typename RawIm::Pointer result = resampler->GetOutput();<br>
result->Update();<br>
result->DisconnectPipeline();<br>
return(result);<br>
}<br>
<br>
//////////////////////////////////////////////////<br>
_____________________________________<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.html" target="_blank">http://www.kitware.com/products/protraining.html</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><br>
</blockquote></div><br>