[vtkusers] Trouble blending two 3d images

Andaharoo Andx_roo at live.com
Sun Aug 13 04:28:03 EDT 2017


I have two 3d images that I'd like to blend and then display in imageViewer2.
Here's the code:
// Create the mask image based off input
maskImage = vtkSmartPointer<vtkImageData>::New();
maskImage->SetDimensions(inputImage->GetDimensions());
maskImage->SetSpacing(inputImage->GetSpacing());
maskImage->SetOrigin(inputImage->GetOrigin());
maskImage->AllocateScalars(VTK_UNSIGNED_CHAR, 3);
int* dim = maskImage->GetDimensions();
// Get pointer to beginning of image
unsigned char* ptr = static_cast<unsigned
char*>(maskImage->GetScalarPointer(0, 0, 0));
for (int i = 0; i < dim[0] * dim[1] * dim[2]; i++)
{
	// Set and advance the pixel
	*ptr++ = 255;
	*ptr++ = 0;
	*ptr++ = 0;	
}
blendFilter = vtkSmartPointer<vtkImageBlend>::New();
blendFilter->AddInputData(inputImage);
blendFilter->AddInputData(maskImage);
blendFilter->SetOpacity(0, 1.0);
blendFilter->SetOpacity(1, 0.5);
blendFilter->Update();

Unfortunately my program just freezes and pulls up the vtkOutputWindow with
nothing in it. 

Also does type matter when using these? I'm trying to blend a grayscale
(single float image) with an rgb image (uchar). 



--
View this message in context: http://vtk.1045678.n5.nabble.com/Trouble-blending-two-3d-images-tp5744385.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list