<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><DIV>Hi, guys: </DIV>
<DIV> </DIV>
<DIV> When I use ITK respectively in C++ and Pyhton, with similar set up, (here I mean same registration method, metric, optimizer and interpolator), C++ version allow me register more slice than python version. It is quite strange for me. I can see from the taks manager that PF usage for C++ version can reach 2.89GB, but python version usually stay below 2GB. Does anyone has similar experinces? </DIV>
<DIV> </DIV>
<DIV> In addition, I can get reasonable registration result in C++ version. BUT the program report Debug error when the application try to write the difference image into a file </DIV>
<DIV> </DIV>
<DIV> the code like this </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> <FONT size=2></DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::ResampleImageFilter<MovingImageType, </DIV>
<DIV>FixedImageType > ResampleFilterType;</DIV>
<DIV> </DIV>
<DIV>TransformType::Pointer finalTransform = TransformType::New();</DIV>
<DIV>finalTransform->SetParameters( finalParameters );</DIV>
<DIV>ResampleFilterType::Pointer resample = ResampleFilterType::New();</DIV>
<DIV>resample->SetTransform( finalTransform );</DIV>
<DIV>resample->SetInput( intensityWindowing_moving->GetOutput() );</DIV>
<DIV>FixedImageType::Pointer fixedImage = intensityWindowing_fixed->GetOutput();</DIV>
<DIV>PixelType backgroundGrayLevel = 0;</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2></FONT></FONT> </DIV>
<DIV><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2>( argc > 4 )</DIV>
<DIV>{</DIV>
<DIV>backgroundGrayLevel = atoi( argv[4] );</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>resample->SetSize( fixedImage->GetLargestPossibleRegion().GetSize() );</DIV>
<DIV>resample->SetOutputOrigin( fixedImage->GetOrigin() );</DIV>
<DIV>resample->SetOutputSpacing( fixedImage->GetSpacing() );</DIV>
<DIV>resample->SetOutputDirection( fixedImage->GetDirection() );</DIV>
<DIV>resample->SetDefaultPixelValue( backgroundGrayLevel );</DIV>
<DIV> </DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>unsigned</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>char</FONT></FONT><FONT size=2> OutputPixelType;</DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::Image< OutputPixelType, Dimension > OutputImageType;</DIV>
<DIV></DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::CastImageFilter< </DIV>
<DIV>FixedImageType,</DIV>
<DIV>OutputImageType > CastFilterType;</DIV>
<DIV></DIV>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::ImageFileWriter< OutputImageType > WriterType;</DIV>
<DIV> </DIV>
<DIV>WriterType::Pointer writer = WriterType::New();</DIV>
<DIV>CastFilterType::Pointer caster = CastFilterType::New();</DIV>
<DIV>WriterType::Pointer writer_diff = WriterType::New();</DIV></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>
<DIV> </DIV>
<DIV>writer->SetFileName( argv[3] );</DIV>
<DIV></DIV>
<DIV>writer->SetImageIO( vtkIO );</DIV>
<DIV>caster->SetInput( resample->GetOutput() );</DIV>
<DIV>writer->SetInput( caster->GetOutput() );</DIV>
<DIV>writer->Update();</DIV>
<DIV> </DIV></FONT></FONT><FONT size=2>
<DIV></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// Software Guide : BeginCodeSnippet</DIV></FONT></FONT><FONT size=2>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::SubtractImageFilter< </DIV>
<DIV>FixedImageType, </DIV>
<DIV>FixedImageType, </DIV>
<DIV>FixedImageType > DifferenceFilterType;</DIV>
<DIV>DifferenceFilterType::Pointer difference = DifferenceFilterType::New();</DIV></FONT><FONT size=2>
<DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::RescaleIntensityImageFilter< </DIV>
<DIV>FixedImageType, </DIV>
<DIV>FixedImageType > RescalerType;</DIV>
<DIV>RescalerType::Pointer intensityRescaler = RescalerType::New();</DIV></FONT><FONT size=2>
<DIV></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2></FONT></FONT> </DIV>
<DIV><FONT color=#008000 size=2><FONT color=#008000 size=2>// After registration</DIV></FONT></FONT><FONT size=2>
<DIV></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// resample->SetTransform( finalTransform ); </DIV></FONT></FONT><FONT size=2>
<DIV></DIV>
<DIV>difference->SetInput2( fixedImage );</DIV>
<DIV>difference->SetInput1( resample->GetOutput() );</DIV>
<DIV></DIV>
<DIV>intensityRescaler->SetInput( difference->GetOutput() );</DIV>
<DIV>intensityRescaler->SetOutputMinimum( 0 );</DIV>
<DIV>intensityRescaler->SetOutputMaximum( 255 );</DIV>
<DIV>caster->SetInput( intensityRescaler->GetOutput() );</DIV>
<DIV>writer_diff->SetImageIO( vtkIO );</DIV>
<DIV>writer_diff->SetInput( caster->GetOutput() );</DIV>
<DIV></DIV></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>
<DIV>// if( argc >5 )</DIV></FONT></FONT><FONT size=2>
<DIV>{</DIV>
<DIV>writer_diff->SetFileName( argv[3] );</DIV>
<DIV>writer_diff->Update(); </DIV>
<DIV>}</DIV></FONT>
<DIV> </DIV>
<DIV> The resample use the final transformation to correct the moving image and the subtractImageFilter calculate the difference after registration. . </DIV>
<DIV> </DIV>
<DIV> Thanks! </DIV>
<DIV> </DIV>
<DIV>Wen </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV></td></tr></table><br>