[vtkusers] Creating Transparant volumes

Mark E Roberts mroberts at andrew.cmu.edu
Tue Apr 17 10:39:47 EDT 2007


Hey Mark,

I apologize for not getting back to you sooner. I've included a snippet of my code to help (hopefully). Again, I'm trying to combine a two-D image with a volume to 'recolor' the volume. But if I combine a number of images with the same volume, I'm going to want to set the opacity of the volume's voxels so I can see all of these pictures. This is my first problem; I am not sure how to set the opacity of the voxels.

Thank you for your help,
Mark Roberts

vtkImageData *vol = vtkImageData::New();
	vol->SetDimensions(b, b, b);
	vol->SetOrigin(0., 0., 0.);
	vol->SetScalarTypeToDouble();
	vol->SetSpacing(1., 1., 1.);

	
	/************************************************
	Bring in the picture
	Change it to Structured Points
	Change the Origin to the Center of the Picture
	Transform the picture
	Combine the picture to the volume we've created
	Display the new object we've just created
	*************************************************/

	vtkJPEGReader *pic1 = vtkJPEGReader::New();
	pic1->SetFileName("C:\\Documents and Settings\\Mark\\My Documents\\CMU\\Research\\brst_usbiop_cyst.jpg");
	
	vtkImageToStructuredPoints *PP1 = vtkImageToStructuredPoints::New();
	PP1->SetInputConnection(pic1->GetOutputPort());	
	
	vtkImageChangeInformation *change1 = vtkImageChangeInformation::New();
	change1->SetInput(PP1->GetOutput());
	change1->SetCenterImage(1);
		
	vtkTransform *trans1 = vtkTransform::New();
	trans1->RotateX(0.);
	trans1->Translate(0., 0., 0.);
	
	
	vtkImageReslice *newpl1 = vtkImageReslice::New();	
	newpl1->SetInput(change1->GetOutput());
	newpl1->SetOutputDimensionality(3);
	newpl1->SetInformationInput(vol);	
	newpl1->SetResliceTransform(trans1);
	newpl1->SetInterpolationModeToNearestNeighbor();
	newpl1->SetBackgroundColor(1., 1., 1., 0.5);
	newpl1->Update();	



> Hi Mark,
> 
> If you can post some sample code of what your pipeline looks like I can
> probably give a suggestion. Hope CMU is doing well,
> 
> Mark
> 
> On 4/9/07, Mark E Roberts <mroberts at andrew.cmu.edu> wrote:
>> Hello,
>> 
>> For a project I am working on, I am merging an image (as an imagedata
>> object) with a volume. The image is an ultrasound image and when I
>> combine the two with vtkImageReslice, the voxels that are not colored
>> in by the scalars from the image are black.
>> 
>> My question is, how am I able to make all of the voxels in this new
>> volume transparant so that I can see through the volume? And if
>> possible, is there a way to pick and choose which voxels get a certain
>> transparency value?
>> 
>> Thanks in advance,
>> 
>> Mark Roberts
>> 
>> 
>> -- Mark Roberts Computer Integrated Engineering Lab Carnegie Mellon
>> University
>> 
>> 301-806-6529
>> 
>> MRoberts at andrew.cmu.edu MeerkyJ at gmail.com
>> 
>> _______________________________________________ This is the private VTK
>> discussion list. Please keep messages on-topic. Check the FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ Follow this link to
>> subscribe/unsubscribe: http://www.vtk.org/mailman/listinfo/vtkusers
>> 
> 
> 


-- 
Mark Roberts
Computer Integrated Engineering Lab
Carnegie Mellon University

301-806-6529

MRoberts at andrew.cmu.edu
MeerkyJ at gmail.com




More information about the vtkusers mailing list