[vtkusers] Re: Re: Re: Creating a Volume from 2D BMP files.

Sharwari Mavalankar sharwari at gmail.com
Thu Sep 7 12:34:12 EDT 2006


hi Yixun,
I'll try and look into why the volume appears darker.

However I'll there are many lines that are appearing on the volume (they
look like striations).
Do you know what the reason for that could be?


Also if I have to visualize color bmp slices (24 bit ) I need
vtkFixedPointVolumeRayCastMapper
right?
Thanks
Sharwari


On 9/6/06, Yixun Liu <yxliu at fudan.edu.cn> wrote:
>
>  Hi,
> You are right and alwayse taking mm as the unit.
> SpacingX = 5.12*10/256;
> SpacingY = 5.12*10/256;
>
> Many reason can make the volume look darker.
> You can change the opacity and color interpolation function to adjust the
> appearance of the volume. If you use shade you can also change ambient or
> diffusion coefficient to make the volume look more lighter. Another method
> is to change the vtkLight in the renderer. vtkLight is a virtual light for
> 3D rendering. It provides methods to locate and point the light, turn it on
> and off, and set its brightness and color.
>
> Cheers,
>
> Yixun Liu
>
>  ----- Original Message -----
> *From:* Sharwari Mavalankar <sharwari at gmail.com>
> *To:* Yixun Liu <yxliu at fudan.edu.cn>
> *Cc:* VTK <vtkusers at vtk.org>
>  *Sent:* Thursday, September 07, 2006 1:43 AM
> *Subject:* Re: Re: Re: Creating a Volume from 2D BMP files.
>
>
> hi Yixun,
> Thank you very much for your email.
> What exactly do you mean by the physical size of the image?
> Does it mean the size of the image in cm or mm?
>
> For example if my original images are 5.12 cm * 5.12 cm and are 256 * 256
> images.
> What will the data spacing be?
>
>
> Also can you tell me the reason why the 3D volume seems darker than the
> original images?
> Is there any way I can scale the intensity of the images?
> Thanks again,
> Sharwari
>
>
> On 9/3/06, Yixun Liu <yxliu at fudan.edu.cn> wrote:
> >
> >  Hi,
> > If you read color bmp files you should update vtk to 5.0 version and use
> > vtkFixedPointVolumeRayCastMapper(see last mail). Otherwise, you should not
> > call
> > br->SetNumberOfScalarComponents(3);
> >
> > 1. You can decide the physical spacing accroding to the image
> > extent(pixel unit) and its physical size(mm): spacing = size/(extent-1); If
> > no physical size you have to give a estimation for the spacing.
> >
> > 2.The point1 and point2 will define a linear opacity function, which can
> > be interpolated from the two points. For example, define two points
> > (intensity1, opacity1)and (intensity2, opacity2) you can get the opacity3 at
> > intensity3 by opacity3 =
> > (intensity3-intensity1)/(intensity2-intensity1)*(opacity2-opacity1) +
> > opacity1
> >
> > Hope it help.
> >
> > Cheers,
> >
> > Yixun Liu
> >
> >   ----- Original Message -----
> > *From:* Sharwari Mavalankar <sharwari at gmail.com>
> > *To:* Yixun Liu <yxliu at fudan.edu.cn>
> > *Cc:* VTK <vtkusers at vtk.org>
> >  *Sent:* Monday, September 04, 2006 6:50 AM
> > *Subject:* Re: Re: Creating a Volume from 2D BMP files.
> >
> >
> > hi Yixun,
> > I implemented the suggestions that you had made.
> > Now I am getting a 3D volume but it doesnt look anything like the
> > original 2D slices.
> > It is much darker in appearance and it's got lines all over it ( it
> > looks as though it's some kind of aliasing).
> >
> > I have the following questions to ask you
> > 1.While using the function SetDataSpacing(x,y,z) how do I decide the
> > values of the parameters x,y and z.
> >
> > 2.While using the Addpoint()  function of class vtkPiecewiseFunction
> > what do the two parameters in the Addpoint function mean?
> > How do they affect the output?
> >
> >
> > This is code I have used. Do let me know if you can make any more
> > sugestions.
> >
> >
> >
> > //This program reads a single BMP file and plots it as an image.
> > //The same program will be extended to read multiple images and create a
> > 3D volume out of 2D slices.
> >
> >
> > #include "vtkRenderer.h"
> > #include "vtkRenderWindow.h"
> > #include "vtkRenderWindowInteractor.h"
> > #include "vtkBMPReader.h"
> > #include "vtkPolyDataMapper.h"
> > #include "vtkActor.h"
> > #include "vtkActor2D.h"
> > #include "vtkImageActor.h"
> > #include "vtkOutlineFilter.h"
> > #include "vtkCamera.h"
> > #include "vtkProperty.h"
> > #include "vtkPolyDataNormals.h"
> > #include "vtkContourFilter.h"
> > #include "vtkDataSetMapper.h"
> > #include "vtkImageMapper.h"
> > #include "vtkVolumeMapper.h"
> > #include " vtkVolumeRayCastMapper.h"
> > #include "vtkVolumeRayCastCompositeFunction.h"
> > #include "vtkPiecewiseFunction.h"
> > #include "vtkVolumeProperty.h"
> >
> >
> > void main (void)
> > {
> >
> >  vtkRenderer *aRenderer = vtkRenderer::New();
> >     vtkRenderWindow *renWin = vtkRenderWindow::New();
> >
> >  renWin->AddRenderer(aRenderer);
> >     vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
> >     iren->SetRenderWindow(renWin);
> >
> >
> >  //create an instance of the class vtkBMPReader
> >  vtkBMPReader *br = vtkBMPReader::New();
> >
> >  br->SetFilePrefix("C:\\Images\\conductivities\\slice");
> >  br->SetFilePattern("%s%d.bmp");
> >  br->SetFileNameSliceOffset(1);
> >  br->SetFileNameSliceSpacing(1);
> >  br->SetNumberOfScalarComponents(3);
> >  br->SetDataSpacing(0.4,0.4,10);
> >  br->SetDataOrigin(0,0,0);
> >  br->SetDataExtent(0,255,0,255,0,7);
> >  br->Update();
> >
> >     vtkPiecewiseFunction *opacityTransferFunction =
> > vtkPiecewiseFunction::New();
> >  opacityTransferFunction->AddPoint(20,0.2);
> >  opacityTransferFunction->AddPoint(255,1.0);
> >
> >  vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
> >  volumeProperty->SetScalarOpacity(opacityTransferFunction);
> >
> >
> >
> >
> >  vtkVolumeRayCastMapper *VolumeMapper = vtkVolumeRayCastMapper::New();
> >     vtkVolumeRayCastCompositeFunction *RayCastFunction =
> > vtkVolumeRayCastCompositeFunction::New();
> >     VolumeMapper->SetVolumeRayCastFunction(RayCastFunction);
> >     VolumeMapper->SetInput(br->GetOutput());
> >
> >
> >  vtkVolume *volume = vtkVolume::New();
> >
> >     VolumeMapper->SetInput(br->GetOutput());
> >    volume->SetMapper(VolumeMapper);
> >
> >     vtkCamera *aCamera = vtkCamera::New();
> >     aCamera->SetViewUp (0, 0,-1);
> >     aCamera->SetPosition (0, 1, 0);
> >     aCamera->SetFocalPoint (0, 0, 0);
> >     aCamera->ComputeViewPlaneNormal();
> >
> >
> >   aRenderer->AddActor(volume);
> >  aRenderer->SetActiveCamera(aCamera);
> >     aRenderer->ResetCamera ();
> >  aRenderer->SetBackground(1,1,1);
> >  renWin->Render();
> >
> >     iren->Initialize();
> >     iren->Start();
> >
> > }
> >
> > Thanks again for all your help.
> > Sharwari
> >
> >
> > On 8/31/06, Yixun Liu <yxliu at fudan.edu.cn> wrote:
> > >
> > >  Hi,
> > > Assuming image is 256x256x100. The first file name is image1 and the
> > > last file name is image100. So, SetDataExtent(0, 255, 0, 255, 1, 100); The
> > > access violation may be caused by wrong extent setting.
> > >
> > > If you use vtkVolume, use vtkVolumeRayCastMapper(vtk4.2.2) or use
> > > vtkFixedPointVolumeRayCastMapper(vtk5.0). Note that if you use
> > > vtkFixedPointVolumeRayCastMapper you no need to call
> > > SetVolumeRayCastFunction();
> > >
> > > Hope it help.
> > >
> > > Yixun Liu
> > >
> > > ----- Original Message -----
> > > *From:* Sharwari Mavalankar <sharwari at gmail.com>
> > > *To:* Yixun Liu <yxliu at fudan.edu.cn>
> > > *Cc:* VTK <vtkusers at vtk.org>
> > > *Sent:* Thursday, August 31, 2006 6:37 PM
> > > *Subject:* Re: Creating a Volume from 2D BMP files.
> > >
> > >
> > > hi Yixun,
> > > Thanks for your email.I had a couple of more questions though.
> > > 1.I do not want to visualize colour slices.They are grey level images.
> > >
> > > 2.Also if I put SetDataExtent() before the Update() then I am getting
> > > an access violation error.What does the Update function do exactly?
> > > Also can you tell me what the five parameters in SetDataExtent() mean?
> > >
> > > 3.If I use vtkVolume what mapper should I use to visualize the slices?
> > >
> > >
> > > Thanks again for all your help.
> > > Sharwari
> > >
> > >
> > >
> > > On 8/23/06, Yixun Liu <yxliu at fudan.edu.cn> wrote:
> > > >
> > > >  Hi,
> > > >
> > > > If you want to visualize color slices, you need to
> > > > 1. read these slices. You need to put the SetDataExtent(0, 111, 0,
> > > > 127, 1, 300);
> > > > before Update();
> > > >
> > > >  vtkTIFFReader *v16 = vtkTIFFReader::New();
> > > >
> > > >  v16->SetFilePrefix("D:\\MyVC\\VTKtest\\Raycasting\\Data\\BrainColor\\brain");
> > > >  v16->SetFilePattern("%s%d.TIF");
> > > >  v16->SetDataExtent(0, 111, 0, 127, 1, 300);
> > > >  v16->SetDataSpacing(1.2,1.2,0.5);
> > > >  v16->SetDataOrigin(0.0, 0.0, 0.0);
> > > >  v16->SetNumberOfScalarComponents(3);
> > > >  v16->Update();
> > > >
> > > > 2. Add the 4th component. The first three components are color and
> > > > the 4th is used to map to opacity. I compute the luminancy according to the
> > > > firft three components and take it as the 4th component.
> > > >
> > > > 3. Opacity map using vtkPiecewiseFunction
> > > >
> > > > 4. no need color map function
> > > >
> > > > 5. you need vtk5.0
> > > >
> > > > Regads,
> > > >
> > > > Yixun Liu
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060907/82d56e63/attachment.htm>


More information about the vtkusers mailing list