[vtkusers] Real colours in 3D CT image(DICOM)

Bill Lorensen bill.lorensen at gmail.com
Tue Oct 6 11:48:48 EDT 2009


I think you are getting the correct image according to the code:

SetColor() sets the Ambient, Diffuse, and Specular colors.
in your case, SetColor(.75,.75,.75) sets each of those colors to grey.
Then, you call:
SetAmbientColor(.75, .10, .25);
since the Ambient coefficient (SetAmbient()) is 0 by default, the
SetAmbientColor(.75, .10, .25) has no effect.
SetDiffuseColor(0.75, .04, .025);
is a reddish color and since the Diffuse coefficient is .75,
SetDiffuse(0.75), it has .75 contribution to the final color.
>From the SetColor(.75,.75,.75), the Specular color is .75,.75,.75 with
a .4 contribution. A SpecularPower of 100 will give very small
highlights of the Specular color.

A description of this type of shading is given here:
http://en.wikipedia.org/wiki/Phong_shading

In summary, your picture corresponds to your property settings.

Since the bone is represented by a single isosurface, that surface can
only have "one color".

I suggest you study the wikipedia article and experiment by varying
each parameter individually.



On Tue, Oct 6, 2009 at 10:29 AM, Gururajan.R <gururajan.r at raster.in> wrote:
> Bill
>
>
> Please find the below actor coding
>
> Thanks for your kind effort
>    vtkLODActor boneActor = new vtkLODActor();
>                //vtkActor boneActor = new vtkActor();
>                boneActor.SetNumberOfCloudPoints(500000);
>                boneActor.SetMapper(geobonemapper);
>                boneActor.GetProperty().SetColor(0.75,0.5,0.75);
>                boneActor.GetProperty().SetAmbientColor(.75, .10, .25);
>                boneActor.GetProperty().SetDiffuseColor(0.75, .04, .025);
>                boneActor.GetProperty().BackfaceCullingOn();
>                boneActor.GetProperty().EdgeVisibilityOn();
>                boneActor.GetProperty().FrontfaceCullingOn();
>                boneActor.GetProperty().GlobalWarningDisplayOn();
>
> boneActor.GetProperty().SetColor(boneActor.GetProperty().GetColor());
>                boneActor.GetProperty().SetOpacity(0.75);
>                boneActor.GetProperty().SetSpecularPower(100);
>                boneActor.GetProperty().SetDiffuse(0.75);
>                boneActor.GetProperty().SetSpecular(.4)
>
>
> Thanks
> Guru
> Bill Lorensen wrote:
>> Show me the exact actor portion of code that produced this image.
>>
>> On Tue, Oct 6, 2009 at 2:46 AM, Gururajan.R <gururajan.r at raster.in> wrote:
>>
>>> Bill
>>> Please find the attached image for your kind view
>>> Thanks
>>> Guru
>>>
>>>
>>> Bill Lorensen wrote:
>>>
>>>> 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