I have 2 3d images ,which have different dimension, origin and spacing ,they both are Grayscale image . When i use volume rendering or put them in 3dSclicer , Their spatial positions match well.
but when i use vtkimageblend to blend them , Their spatial positions dismatch ,i’m not sure the reason.Dose it matter with the image’s dimension,origin or spacing?
this image shows the spatial positions match well
this image shows the result of blend , you can see the dismatch from the image
The vtkImageBlend filter only considers the Extent. It assumes that the voxels of the two images are already in the same positions. It ignores the spatial position and scale that are defined by the spacing and origin.
Before applying vtkImageBlend, the voxels in the overlay image can be resampled with vtkImageReslice to match the voxels in the base image. Something like this:
reslice->SetInputData(overlayImage);
reslice->SetInformationInput(baseImage); // reslice like base image
reslice->SetInterpolationModeToLinear();
reslice->Update();
...
blend->SetInputData(0, baseImage);
blend->SetInputData(1, reslice->GetOutput());