[vtkusers] vtkImageReslice

Pedro Patron Pedro.Patron at imag.fr
Thu May 22 14:23:44 EDT 2003


Hi everybody!

I'm trying to represent an oblique slice in 3D.
I've got a point and the normal vector of the plane.
My problem is that the image is deplaced in the plane in relation with the 
volume when I render it. That is because the center of the image is fixed to 
the point but the point is not in the center of the oblique slice.

I'm sure that's it's an easy problem for you but I have not be able to make it 
runs.
Thank you in advance for your answers.

Pedro

That's my code:

		// I'm getting this vector as the normal plane vector 
		// I'm starting with an horizontal slice
		CVector3D tangent(0.0, 0.0, 1.0);
		tangent.Normalize();

		CVector3D aux(tangent);
		aux.Y()+= 1.0;
		
		CVector3D vec1 = aux^tangent;
		vec1.Normalize();
		CVector3D vec2 = tangent^vec1;
		vec2.Normalize();
	
		vtkImageReslice * reslice = vtkImageReslice::New();
		reslice->SetInput(v16->GetOutput());
		reslice->SetInterpolationModeToCubic();
		reslice->SetResliceAxesDirectionCosines(	vec1.X(), vec1.Y(), vec1.Z(),
													vec2.X(), vec2.Y(), vec2.Z(),
													tangent.X(), tangent.Y(), tangent.Z());
		reslice->SetResliceAxesOrigin(cdata[i][0], cdata[i][1], cdata[i][2]);
		reslice->SetOutputDimensionality(2);
		reslice->SetOutputSpacing(pixelX, pixelY, spacingZ);

/*
		// I've tried the vtkImageChangeInformation too but I don't know exacly how 
it runs
		vtkImageChangeInformation * information = vtkImageChangeInformation::New();
		information->SetInput(reslice->GetOutput());
		information->SetOutputOrigin(cdata[i][0], cdata[i][1], 0.0);
*/		
		vtkTexture * texture = vtkTexture::New();
		texture->SetInput(reslice->GetOutput());
//		texture->SetInput(information->GetOutput());		
		texture->InterpolateOn();
		texture->SetLookupTable(bwLut);
	
		vtkPlaneSource * plane = vtkPlaneSource::New();
		plane->SetOrigin (0.0, 0.0, 0.0);
		plane->SetPoint1(rows*pixelX, 0.0, 0.0);
		plane->SetPoint2(0.0, columns*pixelY, 0.0);
		plane->SetResolution(rows*pixelX, columns*pixelY);
	
		plane->SetCenter(cdata[i][0], cdata[i][1], cdata[i][2]);	
		plane->SetNormal(tangent.X(), tangent.Y(), tangent.Z());
	
		vtkPolyDataMapper * planeMapper = vtkPolyDataMapper::New();
		planeMapper->SetInput(plane->GetOutput());
		
		vtkActor * planeActor = vtkActor::New();
		planeActor->SetMapper(planeMapper);
		planeActor->SetTexture(texture);
	
		ren1->AddActor(planeActor);
		renWin1->Render();	



More information about the vtkusers mailing list