[vtkusers] Human Natural Bone and Skin shoule be viewed in 3d
Gururajan.R
gururajan.r at raster.in
Mon Sep 7 04:13:28 EDT 2009
All,
have to apply humans natural bone & skin color as Habib skull diagram,
Plase have attached as reference.
i have pasted Abdomen image which i generated using reading CT 2d
slices dicom image.
Please any one can share me the way where i have to make the change.
Thanks
Guru
My Code below
package in.raster.viewer.component;
//Using Imagewriter to make .raw file and using volume16reader to read
.raw file
//then convert files into .vtk file
import in.raster.viewer.component.VolumeRenderWithBoxWidget.MyVtkCanvas;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import vtk.*;
/**
* An application that displays a JButton and several JRadioButtons. The
* JRadioButtons determine the look and feel used by the application.
*/
public class SimpleVTK extends JPanel implements ActionListener {
static JFrame frame;
//vtkPanel renWin;
JButton exitButton;
MyVtkCanvas renWin;
vtkBoxWidget boxWidget;
vtkVolumeRayCastMapper volumeMapper;
vtkPlanes planes;
public SimpleVTK() {
{
System.loadLibrary("vtkCommonJava");
System.loadLibrary("vtkFilteringJava");
System.loadLibrary("vtkIOJava");
System.loadLibrary("vtkImagingJava");
System.loadLibrary("vtkGraphicsJava");
System.loadLibrary("vtkRenderingJava");
System.loadLibrary("vtkVolumeRenderingJava");
}
setLayout(new BorderLayout());
System.out.println("Here the programm Starts");
vtkDICOMImageReader dicomreader = new vtkDICOMImageReader();
dicomreader .SetDirectoryName("/home/guru/Desktop/3D/DCM");
dicomreader.Update();
vtkImageWriter writer = new vtkImageWriter();//
vtkImageWriter::New()
writer.SetInput(dicomreader.GetOutput());
writer.SetFilePrefix("/home/guru/workspace/ThreeD/Raw/");
writer.SetFilePattern("%s%3d.dcm.raw");
writer.Write();
writer.Update();
vtkVolume16Reader v16 = new vtkVolume16Reader();
v16.SetDataByteOrderToLittleEndian();
v16 .SetFilePrefix("/home/guru/workspace/ThreeD/Raw/");
v16.SetFilePattern("%s%3d.dcm.raw");
v16.SetImageRange(0,100);
v16.GetOutput().ReleaseDataFlagOn();
v16.SetDataSpacing(dicomreader.GetDataSpacing());
v16.SetDataDimensions(dicomreader.GetOutput().GetDimensions());
v16.Update();
vtkMarchingCubes surfaceExtractor = new vtkMarchingCubes();
surfaceExtractor.SetInput(v16.GetOutput());
surfaceExtractor.ComputeNormalsOn();
surfaceExtractor.ComputeGradientsOn();
surfaceExtractor.SetValue(0, 500);
vtkDecimatePro deci = new vtkDecimatePro();
deci.SetInput(surfaceExtractor.GetOutput());
deci.SetTargetReduction(100);
deci.PreserveTopologyOff();
/*
vtkImageGaussianSmooth GauSmooth = new vtkImageGaussianSmooth();
GauSmooth.SetInput(surfaceExtractor.GetOutput());
GauSmooth.SetDimensionality(3);
GauSmooth.SetStandardDeviation(0.0, 4.0);
GauSmooth.SetNumberOfThreads(100);
*/
vtkSmoothPolyDataFilter smoother = new vtkSmoothPolyDataFilter();
smoother.SetInput(surfaceExtractor.GetOutput());
smoother.Update();
smoother.SetNumberOfIterations(700);
vtkPolyDataNormals normals = new vtkPolyDataNormals();
normals.SetInput(smoother.GetOutput());
normals.FlipNormalsOn();
vtkPolyDataWriter pdw = new vtkPolyDataWriter();
pdw.SetInput(normals.GetOutput());
pdw .SetFileName("/home/guru/workspace/ThreeD/Raw/Dicom.vtk");
pdw.Write();
//3d Construction marching cubes
// to be pasted here from volumemapper at desktop
// to be pasted here from volumemapper at desktop
// 3d Construction
String strfilename = new String();
strfilename = "/home/guru/workspace/ThreeD/Raw/Dicom.vtk";
vtkPolyDataReader polyReader = new vtkPolyDataReader();
polyReader.SetFileName(strfilename);
polyReader.Update();
vtkPolyData polyData = new vtkPolyData();
polyData.DeepCopy(polyReader.GetOutput());
vtkPolyDataMapper polyMapper = new vtkPolyDataMapper();
polyMapper.SetInput(polyData);
polyMapper.Update();
polyMapper.ScalarVisibilityOff();
//for skin and bone Diagram
//For setting Bone Colour
vtkGeometryFilter geovolumebone = new vtkGeometryFilter();
geovolumebone.SetInput(polyReader.GetOutput());
vtkPolyDataMapper geobonemapper = new vtkPolyDataMapper();
geobonemapper.SetInput(geovolumebone.GetOutput());
geobonemapper.ScalarVisibilityOff();
vtkLODActor boneActor = new vtkLODActor();
boneActor.SetNumberOfCloudPoints(100500);
boneActor.SetMapper(geobonemapper);
boneActor.GetProperty().SetColor(1,1,1);
boneActor.GetProperty().SetOpacity(3.0);
boneActor.GetProperty().SetDiffuse(0.75);
boneActor.GetProperty().SetSpecular(0.75);
//For setting Bone Colour
//For setting Skin Colour
vtkMarchingCubes skin = new vtkMarchingCubes();
skin.SetInput(v16.GetOutput());
skin.SetValue(0, 500);
skin.ComputeNormalsOn();
vtkGeometryFilter geovolumeSkin = new vtkGeometryFilter();
geovolumeSkin.SetInput(skin.GetOutput());
vtkPolyDataMapper skinmapper = new vtkPolyDataMapper();
skinmapper.SetInput(geovolumeSkin.GetOutput());
skinmapper.ScalarVisibilityOff();
vtkLODActor actorskin = new vtkLODActor();
actorskin.SetNumberOfCloudPoints(100000);
actorskin.SetMapper(skinmapper);
actorskin.GetProperty().SetColor(1, 0, 0);
//actorskin.GetProperty().SetColor(1, 0.547237, 0.319073);
actorskin.GetProperty().SetOpacity( 0.3 );
//For setting Skin Colour
//for skin and bone Diagram
vtkRenderer render = new vtkRenderer();
vtkRenderWindow renwindow = new vtkRenderWindow();
renwindow.AddRenderer(render);
vtkRenderWindowInteractor renintec = new
vtkRenderWindowInteractor();
renintec.SetRenderWindow(renwindow);
//render.AddActor(actorskin);
render.AddActor(boneActor);
render.SetBackground(0, 0, 0);
renwindow.BordersOff();
renwindow.FullScreenOn();
renwindow.SetSize(500, 500);
renwindow.Render();
render.ResetCamera();
renintec.Start();
/*
* exitButton = new JButton("Exit");
exitButton.addActionListener(this);
* //add(renWin, BorderLayout.CENTER); add(exitButton,
* BorderLayout.EAST);
*/
// 3d Construction
/*
* vtkRenderer renderer = new vtkRenderer();
* renderer.AddActor(imgActor); renderer.ResetCamera();
* renderer.UpdateLightsGeometryToFollowCamera(); renWin = new
* vtkPanel(); renWin.GetRenderer().AddActor(imgActor);
*/
}
/** An ActionListener that listens to the radio buttons. */
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(exitButton)) {
System.exit(0);
}
}
public static void main(String s[]) {
SimpleVTK panel = new SimpleVTK();
//
// frame = new JFrame("SimpleVTK"); frame.addWindowListener(new
// WindowAdapter() { public void windowClosing(WindowEvent e)
// {System.exit(0);} }); frame.getContentPane().add("Center",
panel);
// frame.pack(); frame.setVisible(true);
//
}
}
abodomen
-------------- next part --------------
An embedded message was scrubbed...
From: Ali Habib <ali.mahmoud.habib at gmail.com>
Subject: [vtkusers] How to implement that
Date: Sun, 6 Sep 2009 16:01:51 +0300
Size: 65571
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090907/464a67e2/attachment.eml>
More information about the vtkusers
mailing list