[vtkusers] displaying 3d image

varshini varshini vvarshini at hotmail.com
Fri Mar 19 12:20:03 EST 2004


I am able to read and display a 2d image, but when I try to read a 3d image 
and display it in vtk,I get a 2d output of the 3d image compressed in Z.I 
need to view the image as  a 3d image. I have copied the code below, that I 
use.

	vtkImageData *image1=vtkImageData::New();
		image1->SetDimensions(imageX,imageY,imageZ);
		image1->SetOrigin(0,0,0);
		image1->SetSpacing(1,1,1);
		image1->SetScalarTypeToFloat();
		image1->AllocateScalars();
		float *ptr = static_cast<float*>(image1->GetScalarPointer());
		for (i=0;i<(imageX*imageY*imageZ);i++)
		{
			*ptr++=*image++;
		}

	vtkImageFlip *imageFlip=vtkImageFlip::New();
		imageFlip->SetInput(image1);
		imageFlip->SetFilteredAxis(1);

	vtkImageLogarithmicScale *imageLog=vtkImageLogarithmicScale::New();
		imageLog->SetInput(imageFlip->GetOutput());
		imageLog->SetConstant(k);

	vtkLookupTable *lut = vtkLookupTable::New();
		lut->SetTableRange(0,255);
		lut->SetHueRange(0.0,0.0);
		lut->SetSaturationRange(0,0);
		lut->SetValueRange(0, 1);
		lut->SetAlphaRange(1, 1);
		lut->Build();

	vtkImageMapToColors *grey=vtkImageMapToColors::New();
		grey->SetInput(imageLog->GetOutput());
		grey->SetLookupTable(lut);

	vtkImageActor *imgActor = vtkImageActor::New();
		imgActor->SetInput( grey->GetOutput() );

	vtkRenderer *ren1= vtkRenderer::New();
		ren1->AddActor(imgActor);
		ren1->SetBackground( 0,0,.5 );

	vtkRenderWindow *renWin=vtkRenderWindow::New();
		renWin->AddRenderer(ren1);
		renWin->SetSize(700,700);

	vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();
		iren->SetRenderWindow(renWin);
		iren->Initialize();
		iren->Start();

I have the image in an array, because I need to introduce some calculations 
in it before displaying.It seems to read the whole image , but for some 
reason it is compressing in Z and giving a 2D output. I am not sure of where 
I am going wrong.

Thanks in advance,

varshini

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee® 
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963




More information about the vtkusers mailing list