[vtkusers] Real colours in 3D CT image(DICOM)
Bill Lorensen
bill.lorensen at gmail.com
Mon Oct 5 12:03:46 EDT 2009
This version of the code does not set the colors (they are commented
out) of the parts and some of the diffuse and specular values still
are > 1.0!
One last chance, please send the code with the corrections I sent
before. Run the program and send to me (not the list) a screenshot of
the results.
Bill
On Mon, Oct 5, 2009 at 10:26 AM, Gururajan.R <gururajan.r at raster.in> wrote:
> bill
>
> for your kind view i have pasted my entire programme,.
>
>
> thanks
> guru
>
>
> //
> package in.raster.viewer.component;
> import in.raster.viewer.component.VolumeRenderWithBoxWidget.MyVtkCanvas;
>
> import java.awt.*;
> import java.awt.event.*;
>
> import javax.swing.*;
>
> import vtk.*;
>
> public class Cubes extends JPanel implements ActionListener {
> /**
> *
> */
> private static final long serialVersionUID = 1L;
> static JFrame frame;
> //vtkPanel renWin;
> JButton exitButton;
> MyVtkCanvas renWin;
> vtkBoxWidget boxWidget;
> vtkVolumeRayCastMapper volumeMapper;
> vtkPlanes planes;
> int intwinHeight=300;
> int intwinWidth = 300;
>
>
> public Cubes() {
> {
> System.loadLibrary("vtkCommonJava");
> System.loadLibrary("vtkFilteringJava");
> System.loadLibrary("vtkIOJava");
> System.loadLibrary("vtkImagingJava");
> System.loadLibrary("vtkGraphicsJava");
> System.loadLibrary("vtkRenderingJava");
> System.loadLibrary("vtkVolumeRenderingJava");
> }
>
> setLayout(new BorderLayout());
> vtkDICOMImageReader dicomreader = new vtkDICOMImageReader();
> dicomreader.SetDirectoryName("/home/guru/Desktop/3D/COU IV");
> dicomreader.SetFileNameSliceOffset(1);
> dicomreader.SetFileNameSliceSpacing(1);
> dicomreader.SetDataExtent(0,511,0,511,0,224);
> dicomreader.SetDataSpacing(360.0/512,360.0/512,1.0);
> dicomreader.SetDataOrigin(0,0,0);
> dicomreader.Update();
> //for skin and bone Diagram
> //For setting Bone Colour
> vtkMarchingCubes bone = new vtkMarchingCubes();
> bone.SetInput(dicomreader.GetOutput());
> bone.SetValue(0, 120);
> bone.ComputeNormalsOn();
>
> vtkGeometryFilter geovolumebone = new vtkGeometryFilter();
> geovolumebone.SetInput(bone.GetOutput());
> vtkPolyDataMapper geobonemapper = new vtkPolyDataMapper();
> geobonemapper.SetInput(geovolumebone.GetOutput());
> geobonemapper.ScalarVisibilityOff();
>
> //vtkLODActor boneActor = new vtkLODActor();
> vtkActor boneActor = new vtkActor();
> //boneActor.SetNumberOfCloudPoints(100000);
> boneActor.SetMapper(geobonemapper);
> //boneActor.GetProperty().SetColor(0.75,0.5,0.75);
> boneActor.GetProperty().SetOpacity(0.75);
> boneActor.GetProperty().SetSpecularPower(100);
> boneActor.GetProperty().SetDiffuse(1.75);
> boneActor.GetProperty().SetSpecular(1.75);
> //For setting Bone Colour
>
> //For setting Skin Colour
> vtkMarchingCubes skin = new vtkMarchingCubes();
> skin.SetInput(dicomreader.GetOutput());
> skin.SetValue(0, -300);
> skin.ComputeNormalsOn();
>
> vtkGeometryFilter geovolumeSkin = new vtkGeometryFilter();
> geovolumeSkin.SetInput(skin.GetOutput());
>
> vtkPolyDataMapper skinmapper = new vtkPolyDataMapper();
> skinmapper.SetInput(geovolumeSkin.GetOutput());
> skinmapper.ScalarVisibilityOff();
>
> //vtkActor actorskin = new vtkActor();
> vtkLODActor actorskin = new vtkLODActor();
> actorskin.SetNumberOfCloudPoints(100000);
> actorskin.SetMapper(skinmapper);
> actorskin.GetProperty().SetSpecularPower(100);
> actorskin.GetProperty().SetDiffuse(1.75);
> actorskin.GetProperty().SetSpecular(1.75);
>
> //actorskin.GetProperty().SetColor(1, 0.547237, 0.319073);
> //actorskin.GetProperty().SetColor(0.75,0.75, 0.75);
> actorskin.GetProperty().SetSpecularPower(100);
>
> actorskin.GetProperty().SetOpacity(1);
> //For setting Skin Colour
>
> vtkCamera camera = new vtkCamera();
>
> //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.SetActiveCamera(camera);
> render.ResetCamera();
> render.SetBackground(0, 0, 0);
> renwindow.BordersOff();
> renwindow.FullScreenOn();
> renwindow.SetSize(intwinWidth,intwinHeight);
>
> renwindow.Render();
> render.ResetCamera();
> renintec.Start();
>
> }
>
>
> /** 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[]) {
> Cubes panel = new Cubes();
> }
> }
>
More information about the vtkusers
mailing list