X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FvvImage.txx;h=06f44af400ef2d75dc0bb12936ed80289672d84f;hb=a30d8dd30db9b6f4b67101e712f28c0b2a0227bf;hp=e73cd27fc4d22153365031d6654c897011b1296e;hpb=97e94d6d86e558d1d377486bf2db1549c06f4fd1;p=clitk.git diff --git a/common/vvImage.txx b/common/vvImage.txx index e73cd27..06f44af 100755 --- a/common/vvImage.txx +++ b/common/vvImage.txx @@ -4,23 +4,30 @@ template void vvImage::AddItkImage(TItkImageType *input) { + // Convert from ITK object to VTK object mImageDimension = TItkImageType::ImageDimension; typedef itk::ImageToVTKImageFilter ConverterType; typename ConverterType::Pointer converter = ConverterType::New(); + mItkToVtkConverters.push_back(dynamic_cast< itk::ProcessObject *>(converter.GetPointer())); converter->SetInput(input); converter->Update(); + mVtkImages.push_back( converter->GetOutput() ); + + // Account for direction in transform. The offset is already accounted for + // in the VTK image coordinates, no need to put it in the transform. + for(unsigned int j=0; jGetImageDimension(); j++) + for(unsigned int i=0; iGetImageDimension(); i++) + mTransform->GetMatrix()->SetElement(i,j, input->GetDirection()[i][j]); - mItkToVtkConverters.push_back(dynamic_cast< itk::ProcessObject *>(converter.GetPointer())); - mVtkImages.push_back(converter->GetOutput()); - - //mVtkImageReslice.push_back(vtkSmartPointer::New()); - //mVtkImageReslice.back()->SetInterpolationModeToLinear(); - //mVtkImageReslice.back()->AutoCropOutputOn(); - //mVtkImageReslice.back()->SetBackgroundColor(-1000,-1000,-1000,1); - //mVtkImageReslice.back()->SetResliceTransform(mTransform); - //mVtkImageReslice.back()->SetInput(0, image); - //mVtkImageReslice.back()->Update(); - //mVtkImages.push_back( mVtkImageReslice.back()->GetOutput(0) ); + // Create the corresponding transformed image + mVtkImageReslice.push_back(vtkSmartPointer::New()); + mVtkImageReslice.back()->SetInterpolationModeToLinear(); + mVtkImageReslice.back()->AutoCropOutputOn(); + mVtkImageReslice.back()->SetBackgroundColor(-1000,-1000,-1000,1); + mVtkImageReslice.back()->SetResliceTransform(mTransform); + mVtkImageReslice.back()->SetInput(0, converter->GetOutput()); + mVtkImageReslice.back()->UpdateInformation(); + mTransformedVtkImages.push_back( mVtkImageReslice.back()->GetOutput(0) ); } //--------------------------------------------------------------------