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't know what I'm doing wrong.<br>I need your help.<br><br>typedef signed short PixelType;<br>typedef itk::Image< PixelType, 3 > ImageType;<br>
typedef double FPixelType;<br>typedef itk::Image< FPixelType, 3 > FImageType;<br>typedef itk::ImageSeriesReader< ImageType > ReaderType;<br><br>ImageType::Pointer adaptarModeloImg4D(ReaderType::Pointer modReader,int xsize,int ysize,int zsize,FImageType::Pointer contActivo)<br>
{<br> typedef itk::ResampleImageFilter<ImageType,ImageType> ResampleFilter;<br> ResampleFilter::Pointer filResample = ResampleFilter::New();<br> filResample->SetInput(modReader->GetOutput());<br> <br>
typedef itk::LinearInterpolateImageFunction<ImageType, double > InterpolatorType;<br> InterpolatorType::Pointer interpolator = InterpolatorType::New();<br> filResample->SetInterpolator(interpolator);<br>
filResample->SetDefaultPixelValue(0);<br> <br> const FImageType::SpacingType& spacing = contActivo->GetSpacing();<br> const FImageType::PointType& origin = contActivo->GetOrigin();<br> FImageType::SizeType sizeCA = contActivo->GetLargestPossibleRegion().GetSize();<br>
ImageType::SizeType sizeMod = modReader->GetOutput()->GetLargestPossibleRegion().GetSize();<br> filResample->SetOutputOrigin(origin);<br> filResample->SetOutputSpacing(spacing);<br> filResample->SetSize(sizeCA);<br>
<br> // Computing scale on rows, columns and slices<br> double scaleX = (double)xsize/(double)sizeMod[1];<br> double scaleY = (double)ysize/(double)sizeMod[0];<br> double scaleZ = (double)zsize/(double)sizeMod[2];<br>
<br> // Tanking the minimum scale<br> double scale = scaleX<scaleY ? scaleX:scaleY;<br> scale = scale<scaleZ ? scale:scaleZ;<br><br> typedef itk::Similarity3DTransform< double > TransformType;<br>
TransformType::Pointer transform = TransformType::New();<br> transform->SetScale(scale);<br> <br> // Computing the beginning of the active contour <br> int posY= floor(((double)sizeCA[0]-(double)sizeMod[0]*scale)/2);<br>
int posX= floor(((double)sizeCA[1]-(double)sizeMod[1]*scale)/2);<br> int posZ= floor(((double)sizeCA[2]-(double)sizeMod[2]*scale)/2);<br> <br> // Moving model to active contour beginning<br> TransformType::OutputVectorType translation;<br>
translation[0] = posY-origin[0];<br> translation[1] = posX-origin[1];<br> translation[2] = posZ-origin[2];<br><br> // Updating resample filter<br> transform->SetTranslation(translation);<br> filResample->SetTransform(transform);<br>
filResample->Update();<br><br> return filResample->GetOutput();<br>}<br><br>Thank you.<br>