[vtkusers] Create a 3d Volume with a series of jpeg images

Dženan Zukić dzenanz at gmail.com
Fri Jul 15 01:58:46 EDT 2011


http://itk.org/Wiki/ITK/Examples/IO/VolumeFromSlices

HTH

On Thu, Jul 14, 2011 at 17:30, Luca <luca.pedr at gmail.com> wrote:

> 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.**SetDataScalarTypeToUnsignedCha**r();
>
> vtkRenderer renderer = renderWindow3D.RenderWindow.**GetRenderers().**
> GetFirstRenderer();
>
> vtkFixedPointVolumeRayCastMapp**er texMapper =
> vtkFixedPointVolumeRayCastMapp**er.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<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 <http://www.vtk.org/Wiki/VTK_FAQ>
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/**listinfo/vtkusers<http://www.vtk.org/mailman/listinfo/vtkusers>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110715/e935771a/attachment.htm>


More information about the vtkusers mailing list