[vtkusers] Trouble blending two 3d images
Andaharoo
Andx_roo at live.com
Mon Aug 14 21:20:49 EDT 2017
Thanks, I wasn't aware there was a DebugOn function. It seems you can't blend
a greyscale and rgb image. It's strange this error message isn't thrown to
the vtkOutputWindow without DebugOn though. Instead just blankly doing
nothing. Color mapping the rgb image to r=g=b and then blending worked. This
works:
// Creates a blank image to edit and overlay over the 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. Initially make the mask red for
> testing.
> *ptr++ = 255;
> *ptr++ = 0;
> *ptr++ = 0;
> }
blendFilter = vtkSmartPointer<vtkImageBlend>::New();
// Convert greyscale input to rgb
rgbConverter = vtkSmartPointer<vtkImageMapToColors>::New();
rgbConverter->SetInputData(input);
rgbMap = vtkSmartPointer<vtkScalarsToColors>::New();
rgbConverter->SetLookupTable(rgbMap);
rgbConverter->Update();
blendFilter->AddInputData(rgbConverter->GetOutput());
blendFilter->AddInputData(maskImage);
blendFilter->SetOpacity(0, 1.0);
blendFilter->SetOpacity(1, 0.5);
blendFilter->Update();
--
View this message in context: http://vtk.1045678.n5.nabble.com/Trouble-blending-two-3d-images-tp5744385p5744403.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list