[vtkusers] Problem with

Isaac Gerg isaacgerg at psu.edu
Fri Aug 6 16:06:07 EDT 2004


I solved my own problem. The BMP files are 8-bit grayscale. Thus,
Allow8bitBMPOn() must be invoked so that the data set is not as the
default BMP type, 24bit.

Thanks,
Isaac Gerg


-----Original Message-----
From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On
Behalf Of Isaac Gerg
Sent: Friday, August 06, 2004 11:04 AM
To: vtkusers at vtk.org
Subject: [vtkusers] Problem with 






--
Information Fusion Division
  Image Processing / GIS
Penn State Applied Research Laboratory
http://www.personal.psu.edu/idg101/

Hi all,
  I am attempting to render a volume created from grayscale bitmap
images. I have created 5 images of the attached file number 1.bmp
through 5.bmp. I use the code below to attempt to display them but get
wacky results.

The image is not centered correctly, and none of the coloring or opacity
seems to work Correctly.

Any help deeply appreciated.

Best Regards,
Isaac Gerg



	// Create the standard renderer, render window and interactor
	vtkRenderer* ren = vtkRenderer::New();
	vtkRenderWindow* renWin = vtkRenderWindow::New();
	renWin->AddRenderer(ren);
	vtkRenderWindowInteractor *iren =
vtkRenderWindowInteractor::New();
	iren->SetRenderWindow(renWin);

	vtkBMPReader* reader = vtkBMPReader::New();
	reader->SetFilePrefix ("C:\\USData\\3d\\rgb\\");
	reader->SetFilePattern("%s\\%d.bmp");
	reader->SetDataExtent(0, 0, 0, 0, 1, 5);


	vtkPiecewiseFunction* opacityTransferFunction =
vtkPiecewiseFunction::New();
	opacityTransferFunction->AddPoint(60, 0.0);
	opacityTransferFunction->AddPoint(61, 1.0);
	opacityTransferFunction->AddPoint(70, 1.0);
	opacityTransferFunction->AddPoint(71, 0.0);
	opacityTransferFunction->AddPoint(250, 0.0);
	opacityTransferFunction->AddPoint(251, 0.2);


	vtkColorTransferFunction* colorTransferFunction =
vtkColorTransferFunction::New();
	colorTransferFunction->AddRGBPoint(0.0, 0.0, 0.0, 0.0);
	colorTransferFunction->AddRGBPoint(60.0, 0.0, 0.0, 0.0);
	colorTransferFunction->AddRGBPoint(61.0, 1.0, 0.0, 0.0);
	colorTransferFunction->AddRGBPoint(70.0, 1.0, 0.0, 0.0);
	colorTransferFunction->AddRGBPoint(71.0, 0.0, 0.0, 0.0);

	// The property describes how the data will look
	vtkVolumeProperty* volumeProperty = vtkVolumeProperty::New();
	volumeProperty->SetColor(colorTransferFunction);
	volumeProperty->SetScalarOpacity(opacityTransferFunction);

	
	vtkOutlineFilter *outlineData = vtkOutlineFilter::New();
		outlineData->SetInput
		(
			(vtkDataSet *) reader->GetOutput()
		);
	vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();
		mapOutline->SetInput(outlineData->GetOutput());

	// Draws bounding box.
	vtkActor *outline = vtkActor::New();
		outline->SetMapper(mapOutline);
		outline->GetProperty()->SetColor(0,0,0);

	vtkVolumeRayCastCompositeFunction* compositeFunction =
vtkVolumeRayCastCompositeFunction::New();
	vtkVolumeRayCastMapper* volumeMapper =
vtkVolumeRayCastMapper::New();
	volumeMapper->SetVolumeRayCastFunction(compositeFunction);
	volumeMapper->SetInput(reader->GetOutput());


	
	// The volume holds the mapper and the property and
	// can be used to position/orient the volume
	vtkVolume* volume = vtkVolume::New();
	volume->SetMapper(volumeMapper);
	volume->SetProperty(volumeProperty);
	
	//ren->AddProp(volume);
	
	ren->AddVolume(volume);
	ren->AddActor(outline);
	ren->SetBackground(1, 1, 1);
	renWin->SetSize(640, 480);
	renWin->Render();
	
		
	iren->Initialize();
	renWin->Render();
	iren->Start();




More information about the vtkusers mailing list