[vtkusers] "coloured volume" volume rendering

Dr. Daniel James White PhD dan at chalkie.org.uk
Thu Jul 1 10:26:33 EDT 2004


Hi Brian,

I saw your VTK post.

I am trying to do pretty much the same thing, with little success so 
far.

A few points:

Lisa Avila from kitware says volview2 will volume render a volume 
dataset where each voxel has some colour (as R, G and B values each 
read as independent data for each voxel). I tried it and did not get 
convincing results.... she is currently testing my data (actually 2 
channel data from confocal microscopy, where we try to see where there 
is red and green in the same place, by looking for yellow.)

As far as I am aware I don't think your code works, because you have 
not extracted a scalar value (or 3 scalar values , 1 for R G and B) for 
each voxel. You can use vtkImageLuminance to do this. I might be wrong 
but I had to do this. The ray cast volume mapper doesn't read "colour" 
but some scalar value, which is extracted for each voxel by calculating 
its total luminance (R+B+G i suppose) by  vtkImageLuminance

As far as I am aware the VTK volume rendering mappers can not render 
this "coloured volume" as we want.
They take a SINGLE scalar value for each voxel, look it up in the 
colour and opacity transfer functiosn you define, then render them 
accordingly.

What we need is a volume ray cast mapper, or 2D/3D texture mapper class 
which reads the 3 colour channels in vtkImageData, and renders the 
voxel as the colour they really are, using some opacity function 
determined by the user, perhaps from the total luminance of each 
voxel... or somethiong like that. VolView2 is supposed to have 
something like this, but I cant see it. my Volumepro1000 (terarecon 
inc) hardware accelerated volume rendering board is also supposed to be 
able to do something like this, but VTK doesn't support it.

So as far as I know, thats about where we are.

If you manage to get your code to do what you want, then I would be 
very interested to turn it into a rendering module to MayaVi (GUI front 
end for VTK, which does volume rendering). That would be exactly what 
we need.

cheers


Dan


Message: 7
Date: Thu, 1 Jul 2004 09:32:46 -0400
From: Brian Rowe <briprowe at yahoo.com>
Subject: [vtkusers] 3 Component RGB Data Volume Visualization
To: vtkusers at vtk.org
Message-ID: <23AAC11A-CB63-11D8-A7A4-000A959DA684 at yahoo.com>
Content-Type: text/plain; charset="us-ascii"

Hello,
I have a set of data that is composed of 24bit RGB images.  I am trying
to load them in as a volume and process them with ITK, then visualize
them in VTK.

I can load them in ITK and pass them to vtk fine,  I verified this by
loading a single image and passing it to vtkImageMapper (etc.).

The problem comes when I try to pass the volume to the vtkVolume
classes (Mapper, Property, etc.)  When I visualize this, I see nothing.
   I am not sure what the problem is.  It could be as simple as having
inappropriate ColorTransferFunctions, but at this point I'd like to ask
one of the experts if they see something.

I thank you for your time.

the relevant source code follows:
	append = vtkImageAppendComponents::New();
	
	//////////////////////////////////
	/// This code ties ITK to VTK
	//////////////////////////////////
	append->AddInput(RedConnector->GetOutput());
	append->AddInput(GreenConnector->GetOutput());
	append->AddInput(BlueConnector->GetOutput());
	//append->AddInput(AlphaConnector->GetOutput());
	
	/////////////////////////////////
	/// 2D Image Stuff
//	vtkImageMapper *imapper = vtkImageMapper::New();
//	
//	imapper->SetInput(append->GetOutput());
//	
//	vtkActor2D *actor = vtkActor2D::New();
//	actor->SetMapper(imapper);
//	ren->AddActor(actor);
      ///////////////////////////////////
	
	
	func = vtkVolumeRayCastCompositeFunction::New();
	
	mapper = vtkVolumeRayCastMapper::New();
	mapper->SetInput(append->GetOutput());
	mapper->IndependentComponentsOn();
	mapper->SetComponentBlendModeToAdd();
	mapper->SetVolumeRayCastFunction(func);
	
	opacity = vtkPiecewiseFunction::New();
//	opacity->AddPoint(0.0, 0);
//	opacity->AddPoint(5.0, 1);
	
	red = vtkColorTransferFunction::New();
	red->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
	red->AddRGBPoint(255.0, 1.0, 0.0, 0.0);
	green = vtkColorTransferFunction::New();
	green->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
	green->AddRGBPoint(255.0, 0.0, 1.0, 0.0);
	blue = vtkColorTransferFunction::New();
	blue->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
	blue->AddRGBPoint(255.0, 0.0, 0.0, 1.0);
	
	prop = vtkVolumeProperty::New();
	prop->SetInterpolationTypeToLinear();
//	prop->SetScalarOpacity(0, opacity);
	prop->SetColor(0, red);
	prop->SetColor(1, green);
	prop->SetColor(2, blue);
	prop->ShadeOn();
	
	vol = vtkVolume::New();
	vol->SetProperty(prop);
	vol->SetMapper(mapper);

	ren->AddVolume(vol);
	ren->ResetCamera();


Dr. Daniel James White BSc. (Hons.) PhD
Cell Biology
Department of biological and environmental science
PO Box  35
University of Jyväskylä
Jyväskylä FIN 40014
Finland
+358 14 260 4183 (work)
+358 468102840 (new mobile)
NEW PHONE NUMBER!!!

http://www.chalkie.org.uk
dan at chalkie.org.uk
white at cc.jyu.fi



More information about the vtkusers mailing list