[vtkusers] Create a 3d Volume with a series of jpeg images
lindeval at dmat.ufrr.br
lindeval at dmat.ufrr.br
Fri Jul 15 18:44:33 EDT 2011
You have to add the renderer to your window:
this.renderWindow3D.RenderWindow.AddRenderer(renderer);
----- Mensagem original -----
De: "Luca" <luca.pedr at gmail.com>
Para: vtkusers at vtk.org
Enviadas: Quinta-feira, 14 de Julho de 2011 12:30:05 (GMT-0300) Auto-Detected
Assunto: [vtkusers] Create a 3d Volume with a series of jpeg images
Hi!
I've a series of slices, derivated form dicom images and exported in
jpeg (named Slice1.jpeg... Slice23.jpeg).
I've to reconstruct a 3d volume. If I use directly dicom files it's very
simple, using vtkDicomImageReader class and specificating the folder.
But if i have to make the same thing with vtkJpegReader the result is an
all black windows...
Having dicom images too, i can use one of these to get the width, the
height of the image and origin, spacing and extent of the series.
This is my code, written in c# .net using activiz
##########
jpegreader.SetFilePrefix(folderName+"\\Slice");
jpegreader.SetFilePattern("%d.jpeg");
vtkDICOMImageReader header = vtkDICOMImageReader.New();
header.SetFileName("C:\\Users\\Luca\\Desktop" + "\\IM-0001-0001.dcm");
header.Update();
int height = header.GetHeight();
int width = header.GetWidth();
int depth = 23;
jpegreader.SetFileNameSliceOffset(1);
jpegreader.SetFileNameSliceSpacing(1);
double[] spacing = new double[3];
double[] origin = new double[3];
int[] extent = new int[6];
spacing=header.GetDataSpacing();
origin = header.GetDataOrigin();
jpegreader.SetDataSpacing(spacing[0], spacing[1], spacing[2]);
jpegreader.SetDataOrigin(origin[0],origin[1],origin[2]);
jpegreader.SetDataExtent(0, width - 1, 0, height - 1, 0, depth - 1);
jpegreader.SetDataScalarTypeToUnsignedChar();
vtkRenderer renderer =
renderWindow3D.RenderWindow.GetRenderers().GetFirstRenderer();
vtkFixedPointVolumeRayCastMapper texMapper =
vtkFixedPointVolumeRayCastMapper.New();
vtkVolume vol = vtkVolume.New();
vtkColorTransferFunction ctf = vtkColorTransferFunction.New();
vtkPiecewiseFunction spwf = vtkPiecewiseFunction.New();
vtkPiecewiseFunction gpwf = vtkPiecewiseFunction.New();
//Go through the visulizatin pipeline
texMapper.SetInputConnection(jpegreader.GetOutputPort());
//Set the color curve for the volume
ctf.AddHSVPoint(0, .67, .07, 1);
ctf.AddHSVPoint(94, .67, .07, 1);
ctf.AddHSVPoint(139, 0, 0, 0);
ctf.AddHSVPoint(160, .28, .047, 1);
ctf.AddHSVPoint(254, .38, .013, 1);
//Set the opacity curve for the volume
spwf.AddPoint(84, 0);
spwf.AddPoint(151, .1);
spwf.AddPoint(255, 1);
//Set the gradient curve for the volume
gpwf.AddPoint(0, .2);
gpwf.AddPoint(10, .2);
gpwf.AddPoint(25, 1);
vol.GetProperty().SetColor(ctf);
vol.GetProperty().SetScalarOpacity(spwf);
vol.GetProperty().SetGradientOpacity(gpwf);
vol.SetMapper(texMapper);
//Go through the Graphics Pipeline
renderer.AddVolume(vol);
renderer.ResetCamera();
this.renderWindow3D.RenderWindow.Render();
renderer.Render();
#########
Where I'm wrong??
Thanks
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list