<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:tahoma,new york,times,serif;font-size:10pt">Hallo,<br><br>I wanted to have my MI-Registration in sagittal and coronal view. I made the registration in ITK and I presented it with VTK. But the output-direction is only in the axial-slice. How can I get the registration in sagittal and coronal view represent?<br><br>Thanks<br><br>Here is my Code:<br><br> const unsigned int Dimension = 2;<br> typedef unsigned short PixelType;<br> <br> typedef itk::Image< PixelType, Dimension > FixedImageType;<br> typedef itk::Image< PixelType, Dimension > MovingImageType;<br><br> typedef itk::TranslationTransform< double, Dimension > TransformType;<br> typedef
itk::RegularStepGradientDescentOptimizer OptimizerType;<br> typedef itk::LinearInterpolateImageFunction< MovingImageType,double > InterpolatorType;<br> typedef itk::ImageRegistrationMethod<FixedImageType,MovingImageType> RegistrationType;<br><br> typedef itk::MattesMutualInformationImageToImageMetric<FixedImageType,MovingImageType > MetricType;<br><br> TransformType::Pointer transform= TransformType::New();<br> OptimizerType::Pointer optimizer= OptimizerType::New();<br> InterpolatorType::Pointer interpolator= InterpolatorType::New();<br> RegistrationType::Pointer registration= RegistrationType::New();<br><br> registration->SetOptimizer(optimizer);<br> registration->SetTransform(transform);<br>
registration->SetInterpolator(interpolator);<br> <br> MetricType::Pointer metric = MetricType::New();<br> registration->SetMetric( metric );<br><br> unsigned int numberOfBins = 24;<br> unsigned int numberOfSamples = 10000;<br><br> numberOfBins =24;<br> numberOfSamples =10000;<br> <br> metric->SetNumberOfHistogramBins( numberOfBins );<br> metric->SetNumberOfSpatialSamples( numberOfSamples );<br> metric->SetUseExplicitPDFDerivatives(4);<br> <br> typedef itk::ImageFileReader< FixedImageType > FixedImageReaderType;<br> typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;<br><br> FixedImageReaderType::Pointer
fixedImageReader = FixedImageReaderType::New();<br> MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New();<br><br> //std::cout<<"pfad"<<filesSecondFusion.at((int)this->sliderFusion2->value()).c_str()<<endl;<br> <br> fixedImageReader->SetFileName(filesFirstFusion.at((int)this->sliderFusion1->value()).c_str());<br> movingImageReader->SetFileName(filesSecondFusion.at((int)this->sliderFusion2->value()).c_str());<br> <br> registration->SetFixedImage(fixedImageReader->GetOutput());<br> registration->SetMovingImage(movingImageReader->GetOutput());<br><br> fixedImageReader->Update();<br><br>
registration->SetFixedImageRegion(fixedImageReader->GetOutput()->GetBufferedRegion());<br><br> typedef RegistrationType::ParametersType ParametersType;<br> ParametersType initialParameters( transform->GetNumberOfParameters() );<br><br> initialParameters[0] = 0.0; // Initial offset in mm along X<br> initialParameters[1] = 0.0; // Initial offset in mm along Y<br> <br> registration->SetInitialTransformParameters( initialParameters );<br><br> optimizer->MinimizeOn();<br> optimizer->SetMaximumStepLength(2.00); <br> optimizer->SetMinimumStepLength(0.001);<br> optimizer->SetNumberOfIterations(2000);<br> optimizer->SetRelaxationFactor(0.8);<br><br> ParametersType finalParameters =
registration->GetLastTransformParameters();<br> <br> double TranslationAlongX= finalParameters[0];<br> double TranslationAlongY= finalParameters[1];<br> <br> unsigned int numberOfIterations = optimizer->GetCurrentIteration();<br> <br> double bestValue = optimizer->GetValue();<br><br> std::cout << "Result = " << std::endl;<br> std::cout << " Translation X = " << TranslationAlongX << std::endl;<br> std::cout << " Translation Y = " << TranslationAlongY << std::endl;<br> std::cout << " Iterations = " << numberOfIterations << std::endl;<br> std::cout << " Metric value = " <<
bestValue << std::endl;<br> std::cout << " Stop Condition = " << optimizer->GetStopCondition() << std::endl;<br> <br><br> typedef itk::ResampleImageFilter<MovingImageType,FixedImageType> ResampleFilterType;<br><br> TransformType::Pointer finalTransform = TransformType::New();<br><br> finalTransform->SetParameters(finalParameters);<br> finalTransform->SetFixedParameters( transform->GetFixedParameters() );<br><br> ResampleFilterType::Pointer resample = ResampleFilterType::New();<br><br> resample->SetTransform( finalTransform );<br> resample->SetInput( movingImageReader->GetOutput() );<br><br> FixedImageType::Pointer fixedImage =
fixedImageReader->GetOutput();<br><br> PixelType defaultPixelValue= 100;<br> defaultPixelValue= 100;<br> <br> resample->SetSize(fixedImage->GetLargestPossibleRegion().GetSize());<br> resample->SetOutputOrigin(fixedImage->GetOrigin());<br> resample->SetOutputSpacing(fixedImage->GetSpacing());<br> resample->SetOutputDirection(fixedImage->GetDirection());<br> resample->SetDefaultPixelValue(defaultPixelValue);<br><br><br> typedef unsigned char OutputPixelType;<br> typedef itk::Image<OutputPixelType, Dimension> OutputImageType;<br> typedef itk::CastImageFilter<FixedImageType,OutputImageType> CastFilterType;<br> typedef itk::ImageFileWriter<OutputImageType>
WriterType;<br><br> WriterType::Pointer writer= WriterType::New();<br> CastFilterType::Pointer caster= CastFilterType::New();<br><br> writer->SetFileName("registration1.jpg");<br><br> caster->SetInput(resample->GetOutput());<br> writer->SetInput(caster->GetOutput());<br> writer->Update();<br><br> typedef itk::CheckerBoardImageFilter< FixedImageType > CheckerBoardFilterType;<br> CheckerBoardFilterType::Pointer checker = CheckerBoardFilterType::New();<br><br> checker->SetInput1(fixedImage);<br> checker->SetInput2(resample->GetOutput());<br> <br> if(imageRegistrationCheckerboardChoice->value()== 0){<br> unsigned int checkerArray[3]= {2,2,2};<br>
checker->SetCheckerPattern(checkerArray); <br> }<br> if(imageRegistrationCheckerboardChoice->value()== 1){<br> unsigned int checkerArray[3]= {4,4,4}; <br> checker->SetCheckerPattern(checkerArray); <br> }<br> if(imageRegistrationCheckerboardChoice->value()== 2){<br> unsigned int checkerArray[3]= {8,8,8}; <br> checker->SetCheckerPattern(checkerArray); <br> }<br> if(imageRegistrationCheckerboardChoice->value()== 3){<br> unsigned int checkerArray[3]= {16,16,16}; <br> checker->SetCheckerPattern(checkerArray); <br> }<br> <br>
caster->SetInput(checker->GetOutput());<br> writer->SetInput(caster->GetOutput() );<br> <br> resample->SetDefaultPixelValue(100);<br> <br> // Before registration<br> TransformType::Pointer identityTransform = TransformType::New();<br> identityTransform->SetIdentity();<br> resample->SetTransform( identityTransform );<br><br> writer->SetFileName("registration2.jpg");<br> writer->Update();<br><br> <br> // After registration<br> resample->SetTransform( finalTransform );<br> writer->SetFileName("registration3.jpg");<br> writer->Update();<br> <br> typedef itk::VTKImageExport<
OutputImageType > ExportFilterType;<br> ExportFilterType::Pointer itkExporter = ExportFilterType::New();<br> itkExporter->SetInput(caster->GetOutput() );<br> <br> vtkImageImport* vtkImporter = vtkImageImport::New(); <br> ConnectPipelines(itkExporter, vtkImporter);<br> vtkImporter->Update();<br> <br> modeFusion = vtkInteractorStyleTrackballCamera::New();<br><br> rendererFusion = vtkRenderer::New();<br><br> renderWindowFusion = vtkRenderWindow::New();<br> renderWindowFusion->AddRenderer(rendererFusion);<br><br> imageFusionBox->SetRenderWindow(renderWindowFusion);<br> imageFusionBox->SetInteractorStyle(modeFusion);<br>
imageFusionBox->Initialize();<br> <br> <br> imgFirstColorMap = vtkLookupTable::New();<br> imgFirstColorMap->SetTableRange(-250, 1200);<br> imgFirstColorMap->SetSaturationRange(0,0);<br> imgFirstColorMap->SetHueRange(0, 0);<br> imgFirstColorMap->SetValueRange(0, 2);<br> imgFirstColorMap->Build();<br> <br> firstColorMapper = vtkImageMapToColors::New();<br> firstColorMapper->SetInput(vtkImporter->GetOutput());<br> firstColorMapper->SetLookupTable(imgFirstColorMap);<br> <br> imgFusionMIActor = vtkImageActor::New();<br> imgFusionMIActor->SetInput(firstColorMapper->GetOutput());<br>
imgFusionMIActor->SetOpacity(1.0);<br> <br> cameraFusion = vtkCamera::New();<br> cameraFusion->SetViewUp(0, 0, -1);<br> cameraFusion->SetPosition(0, 1, 0);<br> cameraFusion->SetFocalPoint(0, 0, 0);<br> cameraFusion->ComputeViewPlaneNormal(); <br> cameraFusion->Roll(-90);<br> cameraFusion->Azimuth(90);<br> cameraFusion->Roll(90); <br> <br> rendererFusion->AddActor(imgFusionMIActor);<br> rendererFusion->SetActiveCamera(cameraFusion);<br> rendererFusion->ResetCamera();<br> cameraFusion->Dolly(1.7);<br> rendererFusion->ResetCameraClippingRange();<br><br><div> <br><br><br><br></div>Mit freundlichen Grüßen<br>Yusuf
ÖZBEK<div><br></div>
</div><br></body></html>