<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Ashish,<br>
<br>
You have to address the first error message before worrying about the
data type going into the vtkVolumeRayCastMapper. According to the 1st
error message, the vtkDICOMImageReader does not think it has any files
to read. Try using the SetDirectoryName() method in vtkDICOMImageReader
instead of SetFilePrefix() from its superclass (vtkImageReader2). Once
you resolve the first error, then if the data is not of type unsigned
short or unsigned char, follow Yixun's advice (below) about getting
your data into a ray cast mapper.<br>
<br>
- Amy<br>
<br>
Yixun Liu wrote:
<blockquote cite="mid000e01c6d7bb$fb283410$3a64a8c0@dmrc6700512"
 type="cite">
  <meta http-equiv="Content-Type" content="text/html; ">
  <meta content="MSHTML 6.00.2900.2963" name="GENERATOR">
  <style></style>
  <div><font face="Bookman Old Style">Hi,</font></div>
  <div>vtkVolumeRayCastMapper&nbsp; does not support short type, so rescale
it to unsigned short using vtkImageShiftScale&nbsp; or use
vtkFixedPointVolumeRayCastMapper instead of vtkVolumeRayCastMapper.</div>
  <div>&nbsp;</div>
  <div><font face="Bookman Old Style">Hope it help.</font></div>
  <div>&nbsp;</div>
  <div><font face="Bookman Old Style">Yixun</font></div>
  <div>&nbsp;</div>
  <blockquote
 style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
    <div
 style="font-family: &#23435;&#20307;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 9pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">-----
Original Message ----- </div>
    <div
 style="background: rgb(228, 228, 228) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-family: &#23435;&#20307;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 9pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>From:</b>
    <a title="mrasingh@gmail.com" href="mailto:mrasingh@gmail.com">Ashish
Singh</a> </div>
    <div
 style="font-family: &#23435;&#20307;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 9pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>To:</b>
    <a title="yxliu@fudan.edu.cn" href="mailto:yxliu@fudan.edu.cn">Yixun
Liu</a> ; <a title="vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>
    </div>
    <div
 style="font-family: &#23435;&#20307;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 9pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Sent:</b>
Thursday, September 14, 2006 1:02 PM</div>
    <div
 style="font-family: &#23435;&#20307;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 9pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Subject:</b>
Re: [vtkusers] Re: Re: Re: Creating a Volume from 2D BMP files.</div>
    <div><br>
    </div>
Hi Yixun,<br>
    <br>
I am using the volumerendering library as you mentioned. But still I am
getting the following errors.<br>
1)ERROR: In ..\..\IO\vtkDICOMImageReader
    <div>.cxx, line 255<br>
vtkDICOMImageReader (0033C900): Either a filename was not specified or
the specified directory does not contain any DICOM images. <br>
    <br>
2)ERROR: In ..\..\VolumeRendering\vtkVolumeRayCastMapper.cxx, line 326<br>
vtkVolumeRayCastMapper (02953718): Cannot volume render data of type
short, only unsigned char or unsigned short.<br>
    <br>
The 2nd error keeps repeating itself again and again. <br>
    <br>
How can I rectify these errors?<br>
    <br>
My code is as follows:<br>
    </div>
    <br>
-----<br>
#include "vtkConeSource.h"<br>
#include "vtkPolyDataMapper.h "<br>
#include "vtkRenderWindow.h"<br>
#include "vtkCamera.h"<br>
#include "vtkActor.h"
    <div><span class="q">#include "vtkImageActor.h"<br>
#include "vtkOutlineFilter.h"<br>
    </span></div>
    <div><span class="q">#include " vtkProperty.h"<br>
#include "vtkPolyDataNormals.h"<br>
#include "vtkContourFilter.h"<br>
#include "vtkDataSetMapper.h"<br>
#include "vtkImageMapper.h"<br>
    </span></div>
    <div><span class="q">#include "vtkPiecewiseFunction.h "<br>
#include "vtkVolumeProperty.h"<br>
    </span></div>
#include "vtkRenderer.h"<br>
#include "conio.h"<br>
#include "vtkDICOMImageReader.h"<br>
#include "vtkImageViewer2.h" <br>
#include " vtkJPEGReader.h"<br>
#include "vtkRenderWindowInteractor.h"<br>
#include "vtkVolumeMapper.h"<br>
#include "vtkActor2D.h"<br>
#include "vtkPolyDataMapper.h"<br>
#include "vtkVolumeRayCastCompositeFuncti
    <div>on.h "<br>
#include "vtkVolumeRayCastMapper.h"<br>
    <br>
void main()<br>
{<br>
&nbsp; <br>
&nbsp; vtkRenderer *arenderer = vtkRenderer::New();<br>
&nbsp; vtkRenderWindow *renwin = vtkRenderWindow::New();<br>
&nbsp; vtkDICOMImageReader *img1=vtkDICOMImageReader::New(); <br>
    <br>
&nbsp; img1-&gt;SetFilePrefix("D:\\testimages\\dicomset\\IM");<br>
&nbsp; img1-&gt;SetFilePattern("%s%d.dcm");<br>
&nbsp; img1-&gt;SetFileNameSliceOffset(1);<br>
&nbsp; img1-&gt;SetFileNameSliceSpacing(1);<br>
&nbsp; img1-&gt;SetDataExtent(0,511,0,511,1,10);//512x512 images and 10
slices <br>
&nbsp; img1-&gt;SetDataSpacing(360.0/512,360.0/512,1.0); //my image is 36cm
x 36cm and 512x512<br>
&nbsp; img1-&gt;SetDataOrigin(0.0,0.0,0.0);<br>
&nbsp; img1-&gt;Update();<br>
    <br>
&nbsp; vtkVolume *vol=vtkVolume::New();<br>
&nbsp; vtkVolumeRayCastMapper *volumemapper = vtkVolumeRayCastMapper::New();
    <br>
&nbsp; vtkVolumeRayCastCompositeFunction
*rcf=vtkVolumeRayCastCompositeFunction::New();<br>
&nbsp; volumemapper-&gt;SetVolumeRayCastFunction(rcf);<br>
&nbsp; volumemapper-&gt;SetInput(img1-&gt;GetOutput());<br>
&nbsp; vol-&gt;SetMapper(volumemapper); <br>
    <br>
&nbsp; vtkCamera *cam=vtkCamera::New();<br>
&nbsp; cam-&gt;SetViewUp(0,0,-1);<br>
&nbsp; cam-&gt;SetPosition(0,1,0);<br>
&nbsp; cam-&gt;SetFocalPoint(0,0,0);<br>
&nbsp; cam-&gt;ComputeViewPlaneNormal();<br>
    <br>
&nbsp; arenderer-&gt;AddActor(vol);<br>
&nbsp; arenderer-&gt;SetActiveCamera(cam);<br>
&nbsp; arenderer-&gt;ResetCamera();<br>
&nbsp; arenderer-&gt;SetBackground(1,1,1);<br>
&nbsp; <br>
&nbsp; renwin-&gt;AddRenderer(arenderer);<br>
&nbsp; vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New(); <br>
&nbsp; iren-&gt;SetRenderWindow(renwin);<br>
&nbsp; renwin-&gt;Render();<br>
&nbsp; iren-&gt;Initialize();<br>
&nbsp; iren-&gt;Start();<br>
    <br>
&nbsp; img1-&gt;Delete();<br>
&nbsp; iren-&gt;Delete();<br>
}<br>
--------<br>
    <br>
I would appreciate all help. <br>
    <br>
Thanks,<br>
Ashish<br>
    </div>
    <br>
    <br>
    <div><span class="gmail_quote">On 9/13/06, <b
 class="gmail_sendername">Yixun Liu</b> &lt;<a
 href="mailto:yxliu@fudan.edu.cn">yxliu@fudan.edu.cn</a>&gt; wrote:</span>
    <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
      <div>
      <div bgcolor="#ffffff">
      <div><font face="Bookman Old Style">Hi,</font></div>
      <div><font face="Bookman Old Style">When you update vtk from 4.2
to 5.0 the old rendering.lib has been replaced with
volumerendering.lib, so be sure that you use the volumerendering.lib
instead of rendering.lib in you project configuration.</font></div>
      <div>&nbsp;</div>
      <div><font face="Bookman Old Style">Cheers,</font></div>
      </div>
      <div><span class="sg">
      <div>&nbsp;</div>
      <div><font face="Bookman Old Style">Yixun</font></div>
      </span></div>
      <div><span class="e" id="q_10da9c15c887d41a_2">
      <blockquote
 style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
        <div>----- Original Message ----- </div>
        <div
 style="background: rgb(228, 228, 228) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b>From:</b>
        <a title="mrasingh@gmail.com"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:mrasingh@gmail.com" target="_blank">Ashish Singh</a> </div>
        <div><b>To:</b> <a title="vtkusers@vtk.org"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a> </div>
        <div><b>Cc:</b> <a title="yxliu@fudan.edu.cn"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:yxliu@fudan.edu.cn" target="_blank">Yixun Liu</a> ; <a
 title="amy.squillacote@kitware.com"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:amy.squillacote@kitware.com" target="_blank">Amy
Squillacote</a> </div>
        <div><b>Sent:</b> Thursday, September 14, 2006 1:23 AM</div>
        <div><b>Subject:</b> Re: [vtkusers] Re: Re: Re: Creating a
Volume from 2D BMP files.</div>
        <div><br>
        </div>
Hi Amy,<br>
        <br>
I don't remember if VTK_USE_RENDERING variable was ON or not. Is there
a way to confirm that? However I am able to compile and run other
programs from the examples/tutorials directory such as cones etc. as
well as read and display single dicom image and interact with it using
renderwindowinteractor. <br>
        <br>
Here is my cmakelists.txt file for cone example:<br>
---<br>
PROJECT (Step1)<br>
        <br>
FIND_PACKAGE(VTK REQUIRED)<br>
IF(NOT VTK_USE_RENDERING)<br>
&nbsp; MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires
VTK_USE_RENDERING.") <br>
ENDIF(NOT VTK_USE_RENDERING)<br>
INCLUDE(${VTK_USE_FILE})<br>
        <br>
ADD_EXECUTABLE(Cone Cone.cxx)<br>
TARGET_LINK_LIBRARIES(Cone vtkRendering)<br>
----<br>
This works fine.<br>
        <br>
The cmakelists.txt file that I use for dicom volume problem is : <br>
----<br>
PROJECT (multiimagereader)<br>
        <br>
INCLUDE (${CMAKE_ROOT}/Modules/FindVTK.cmake)<br>
IF (USE_VTK_FILE)<br>
&nbsp; INCLUDE(${USE_VTK_FILE})<br>
ENDIF (USE_VTK_FILE)<br>
        <br>
ADD_EXECUTABLE(multiimagereader multiimagereader.cxx )<br>
TARGET_LINK_LIBRARIES(multiimagereader vtkRendering)<br>
----<br>
Is there anything that I need to modify in this file?<br>
        <br>
Thanks,<br>
Ashish<br>
        <br>
        <br>
        <div><span class="gmail_quote">On 9/13/06, <b
 class="gmail_sendername">Amy Squillacote</b> &lt;<a
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:amy.squillacote@kitware.com" target="_blank">amy.squillacote@kitware.com</a>&gt;
wrote:</span>
        <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
          <div>
          <div bgcolor="#ffffff" text="#000000">Hi Ashish,<br>
          <br>
When you built VTK, was the VTK_USE_RENDERING CMake variable set to ON?
If it was, are you linking against the vtkVolumeRendering library?<br>
          <br>
- Amy<br>
          <br>
Ashish Singh wrote: </div>
          <div><span>Hi Yixun and Sharwari,<br>
          <br>
I am trying to solve exactly similar problem but using DICOM images
rather than bmp. But I am getting errors and I can't figure out why. My
code is based on your previous conversation so far. The error that I
get is: <br>
(1)error LNK2019: unresolved external symbol "public: static class
vtkVolumeRayCastCompositeFunction * __cdecl
vtkVolumeRayCastCompositeFunction::New(void)"
(?New@vtkVolumeRayCastCompositeFunction@@SAPAV1@XZ ) referenced in
function _main<br>
&nbsp;(2)error LNK2019: unresolved external symbol "public: static class
vtkVolumeRayCastMapper * __cdecl vtkVolumeRayCastMapper::New(void)"
(?New@vtkVolumeRayCastMapper@@SAPAV1@XZ) referenced in function _main <br>
(3)fatal error LNK1120: 2 unresolved externals<br>
          <br>
Can you please help me figure out what's going wrong here?<br>
          <br>
My code is as follows:<br>
-----<br>
#include "vtkConeSource.h"<br>
#include "vtkPolyDataMapper.h "<br>
#include "vtkRenderWindow.h"<br>
#include "vtkCamera.h"<br>
#include "vtkActor.h"<br>
#include "vtkImageActor.h"<br>
#include "vtkOutlineFilter.h"<br>
#include " vtkProperty.h"<br>
#include "vtkPolyDataNormals.h"<br>
#include "vtkContourFilter.h"<br>
#include "vtkDataSetMapper.h"<br>
#include "vtkImageMapper.h"<br>
#include "vtkPiecewiseFunction.h "<br>
#include "vtkVolumeProperty.h"<br>
#include "vtkRenderer.h"<br>
#include "conio.h"<br>
#include "vtkDICOMImageReader.h"<br>
#include "vtkImageViewer2.h"<br>
#include " vtkJPEGReader.h"<br>
#include "vtkRenderWindowInteractor.h"<br>
#include "vtkVolumeMapper.h"<br>
#include "vtkActor2D.h"<br>
#include "vtkPolyDataMapper.h"<br>
#include "vtkVolumeRayCastCompositeFunction.h "<br>
#include "vtkVolumeRayCastMapper.h"<br>
          <br>
void main()<br>
{<br>
&nbsp; <br>
&nbsp; vtkRenderer *arenderer = vtkRenderer::New();<br>
&nbsp; vtkRenderWindow *renwin = vtkRenderWindow::New();<br>
&nbsp; vtkDICOMImageReader *img1=vtkDICOMImageReader::New(); <br>
          <br>
&nbsp; img1-&gt;SetFilePrefix("D:\\testimages\\dicomset\\IM");<br>
&nbsp; img1-&gt;SetFilePattern("%s%d.dcm");<br>
&nbsp; img1-&gt;SetFileNameSliceOffset(1);<br>
&nbsp; img1-&gt;SetFileNameSliceSpacing(1);<br>
&nbsp; img1-&gt;SetDataExtent(0,511,0,511,1,10);//512x512 images and 10
slices <br>
&nbsp; img1-&gt;SetDataSpacing(360.0/512,360.0/512,1.0); //my image is 36cm
x 36cm and 512x512<br>
&nbsp; img1-&gt;SetDataOrigin(0.0,0.0,0.0);<br>
&nbsp; img1-&gt;Update();<br>
          <br>
&nbsp; vtkVolume *vol=vtkVolume::New();<br>
&nbsp; vtkVolumeRayCastMapper *volumemapper = vtkVolumeRayCastMapper::New();
          <br>
&nbsp; vtkVolumeRayCastCompositeFunction
*rcf=vtkVolumeRayCastCompositeFunction::New();<br>
&nbsp; volumemapper-&gt;SetVolumeRayCastFunction(rcf);<br>
&nbsp; volumemapper-&gt;SetInput(img1-&gt;GetOutput());<br>
&nbsp; vol-&gt;SetMapper(volumemapper); <br>
          <br>
&nbsp; vtkCamera *cam=vtkCamera::New();<br>
&nbsp; cam-&gt;SetViewUp(0,0,-1);<br>
&nbsp; cam-&gt;SetPosition(0,1,0);<br>
&nbsp; cam-&gt;SetFocalPoint(0,0,0);<br>
&nbsp; cam-&gt;ComputeViewPlaneNormal();<br>
          <br>
&nbsp; arenderer-&gt;AddActor(vol);<br>
&nbsp; arenderer-&gt;SetActiveCamera(cam);<br>
&nbsp; arenderer-&gt;ResetCamera();<br>
&nbsp; arenderer-&gt;SetBackground(1,1,1);<br>
&nbsp; <br>
&nbsp; renwin-&gt;AddRenderer(arenderer);<br>
&nbsp; vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New(); <br>
&nbsp; iren-&gt;SetRenderWindow(renwin);<br>
&nbsp; renwin-&gt;Render();<br>
&nbsp; iren-&gt;Initialize();<br>
&nbsp; iren-&gt;Start();<br>
          <br>
&nbsp; img1-&gt;Delete();<br>
&nbsp; iren-&gt;Delete();<br>
}<br>
--------<br>
I would really appreciate if anyone can help me. <br>
          <br>
Regards,<br>
Ashish<br>
          <br>
          <div><span class="gmail_quote">On 9/7/06, <b
 class="gmail_sendername">Sharwari Mavalankar</b> &lt;<a
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:sharwari@gmail.com" target="_blank"> sharwari@gmail.com</a>&gt;
wrote:</span>
          <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
            <div>
            <div>hi Yixun,</div>
            <div>I'll try and look into why the volume appears darker.</div>
            <div>&nbsp;</div>
            <div>However I'll there are many lines that are appearing
on the volume (they look like striations).</div>
            <div>Do you know what the reason for that could be?</div>
            <div>&nbsp;</div>
            <div>&nbsp;</div>
            <div>Also if I have to visualize color bmp slices (24 bit
)&nbsp;I need <font face="Bookman Old Style">vtkFixedPointVolumeRayCastMapper
right?</font></div>
            <div><font face="Bookman Old Style">Thanks </font></div>
            </div>
            <div><span>
            <div><font face="Bookman Old Style">Sharwari</font><br>
            <br>
&nbsp;</div>
            </span></div>
            <div><span>
            <div><span class="gmail_quote">On 9/6/06, <b
 class="gmail_sendername">Yixun Liu</b> &lt;<a
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:yxliu@fudan.edu.cn" target="_blank">yxliu@fudan.edu.cn</a>
&gt; wrote: </span>
            <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
              <div>
              <div bgcolor="#ffffff">
              <div><font face="Bookman Old Style">Hi,</font></div>
              <div><font face="Bookman Old Style">You are right and
alwayse taking mm as the unit.</font></div>
              <div><font face="Bookman Old Style">SpacingX =
5.12*10/256;</font></div>
              <div><font face="Bookman Old Style">SpacingY =
5.12*10/256;</font></div>
              <div>&nbsp;</div>
              <div><font face="Bookman Old Style">Many reason can make
the volume look darker.</font></div>
              <div><font face="Bookman Old Style">You can&nbsp;change the
opacity and color interpolation function to adjust the appearance of
the volume. If you use shade you can also&nbsp;change ambient or diffusion
coefficient to make the volume look&nbsp;more lighter. Another method is to
change the <a>vtkLight</a> in the renderer. <a>vtkLight</a> 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. </font></div>
              <div>&nbsp;</div>
              <div><font face="Bookman Old Style">Cheers,</font></div>
              </div>
              <div><span>
              <div>&nbsp;</div>
              <div><font face="Bookman Old Style">Yixun Liu</font></div>
              </span></div>
              <div><span>
              <div>----- Original Message ----- </div>
              <div
 style="background: rgb(228, 228, 228) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b>From:</b>
              <a title="sharwari@gmail.com"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:sharwari@gmail.com" target="_blank">Sharwari Mavalankar</a>
              </div>
              <div><b>To:</b> <a title="yxliu@fudan.edu.cn"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:yxliu@fudan.edu.cn" target="_blank">Yixun Liu</a> </div>
              <div><b>Cc:</b> <a title="vtkusers@vtk.org"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:vtkusers@vtk.org" target="_blank">VTK</a> </div>
              </span></div>
              <div><span>
              <div><b>Sent:</b> Thursday, September 07, 2006 1:43 AM</div>
              <div><b>Subject:</b> Re: Re: Re: Creating a Volume from
2D BMP files.</div>
              <div><br>
&nbsp;</div>
              <div>hi Yixun,</div>
              <div>Thank you very much for your email.</div>
              <div>What exactly do you mean by the physical size of the
image?</div>
              <div>Does it mean the size of the image in cm or mm?</div>
              <div>&nbsp;</div>
              <div>For example if my original images are 5.12 cm * 5.12
cm and are 256 * 256 images.</div>
              <div>What will the data spacing be?</div>
              <div>&nbsp;</div>
              <div>&nbsp;</div>
              <div>Also can you tell me the reason why the 3D volume
seems darker than the original images?&nbsp;</div>
              <div>Is there any way I can scale the intensity of the
images?</div>
              <div>Thanks again,</div>
              <div>Sharwari<br>
              <br>
&nbsp;</div>
              <div><span class="gmail_quote">On 9/3/06, <b
 class="gmail_sendername">Yixun Liu</b> &lt;<a
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:yxliu@fudan.edu.cn" target="_blank">yxliu@fudan.edu.cn</a>
&gt; wrote: </span>
              <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
                <div>
                <div bgcolor="#ffffff">
                <div><font face="Bookman Old Style">Hi,</font></div>
                <div><font face="Bookman Old Style">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</font></div>
                <div><font face="Bookman Old Style">br-&gt;SetNumberOfScalarComponents(3);</font></div>
                <div>&nbsp;</div>
                <div><font face="Bookman Old Style">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. </font></div>
                <div>&nbsp;</div>
                <div><font face="Bookman Old Style">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 </font></div>
                <div>&nbsp;</div>
                <div><font face="Bookman Old Style">Hope it help.</font></div>
                <div>&nbsp;</div>
                <div><font face="Bookman Old Style">Cheers,</font></div>
                </div>
                <div><span>
                <div>&nbsp;</div>
                <div><font face="Bookman Old Style"><span name="st">Yixun</span>
Liu</font></div>
                <div><font face="Bookman Old Style"><br>
                </font></div>
                </span></div>
                <div><span>
                <div>----- Original Message ----- </div>
                <div
 style="background: rgb(228, 228, 228) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b>From:</b>
                <a title="sharwari@gmail.com"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:sharwari@gmail.com" target="_blank">Sharwari Mavalankar</a>
                </div>
                <div><b>To:</b> <a title="yxliu@fudan.edu.cn"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:yxliu@fudan.edu.cn" target="_blank"><span name="st">Yixun</span>
Liu</a> </div>
                <div><b>Cc:</b> <a title="vtkusers@vtk.org"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:vtkusers@vtk.org" target="_blank">VTK</a> </div>
                </span></div>
                <div><span>
                <div><b>Sent:</b> Monday, September 04, 2006 6:50 AM</div>
                <div><b>Subject:</b> Re: Re: Creating a Volume from 2D
BMP files.</div>
                <div><br>
&nbsp;</div>
                <div>hi Yixun,</div>
                <div>I implemented the suggestions that you had made.</div>
                <div>Now I am getting a 3D volume but it doesnt look
anything like the original 2D slices.</div>
                <div>It is much darker in appearance and it's got lines
all over it ( it looks as though it's some kind of aliasing).</div>
                <div>&nbsp;</div>
                <div>I have the following questions to ask you </div>
                <div>1.While using the function SetDataSpacing(x,y,z)
how do I decide the values of the parameters x,y and z.</div>
                <div>&nbsp;</div>
                <div>2.While using the Addpoint() &nbsp;function of class
vtkPiecewiseFunction what do the two parameters in the Addpoint
function mean?</div>
                <div>How do they affect the output?</div>
                <div>&nbsp;</div>
                <div>&nbsp;</div>
                <div>This is code I have used. Do let me know if you
can make any more sugestions.</div>
                <div>&nbsp;</div>
                <div>&nbsp;</div>
                <div>
                <p>//This program reads a single BMP file and plots it
as an image.<br>
//The same program will be extended to read multiple images and create
a 3D volume out of 2D slices.</p>
                <p><br>
#include "vtkRenderer.h"<br>
#include "vtkRenderWindow.h"<br>
#include "vtkRenderWindowInteractor.h"<br>
#include "vtkBMPReader.h"<br>
#include "vtkPolyDataMapper.h"<br>
#include "vtkActor.h"<br>
#include "vtkActor2D.h"<br>
#include "vtkImageActor.h"<br>
#include "vtkOutlineFilter.h"<br>
#include "vtkCamera.h"<br>
#include "vtkProperty.h" <br>
#include "vtkPolyDataNormals.h"<br>
#include "vtkContourFilter.h"<br>
#include "vtkDataSetMapper.h"<br>
#include "vtkImageMapper.h"<br>
#include "vtkVolumeMapper.h"<br>
#include " vtkVolumeRayCastMapper.h"<br>
#include "vtkVolumeRayCastCompositeFunction.h"<br>
#include "vtkPiecewiseFunction.h"<br>
#include "vtkVolumeProperty.h"</p>
                <p><br>
void main (void)<br>
{<br>
&nbsp;<br>
&nbsp;vtkRenderer *aRenderer = vtkRenderer::New();<br>
&nbsp;&nbsp;&nbsp; vtkRenderWindow *renWin = vtkRenderWindow::New();<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;renWin-&gt;AddRenderer(aRenderer);<br>
&nbsp;&nbsp;&nbsp; vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
                <br>
&nbsp;&nbsp;&nbsp; iren-&gt;SetRenderWindow(renWin);</p>
                <p><br>
&nbsp;//create an instance of the class vtkBMPReader<br>
&nbsp;vtkBMPReader *br = vtkBMPReader::New();<br>
&nbsp;<br>
&nbsp;br-&gt;SetFilePrefix("C:\\Images\\conductivities\\slice"); <br>
&nbsp;br-&gt;SetFilePattern("%s%d.bmp"); <br>
&nbsp;br-&gt;SetFileNameSliceOffset(1);<br>
&nbsp;br-&gt;SetFileNameSliceSpacing(1);<br>
&nbsp;br-&gt;SetNumberOfScalarComponents(3);<br>
&nbsp;br-&gt;SetDataSpacing(0.4,0.4,10);<br>
&nbsp;br-&gt;SetDataOrigin(0,0,0);<br>
&nbsp;br-&gt;SetDataExtent(0,255,0,255,0,7); <br>
&nbsp;br-&gt;Update();<br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp; vtkPiecewiseFunction *opacityTransferFunction =
vtkPiecewiseFunction::New();<br>
&nbsp;opacityTransferFunction-&gt;AddPoint(20,0.2);<br>
&nbsp;opacityTransferFunction-&gt;AddPoint(255,1.0);</p>
                <p>&nbsp;vtkVolumeProperty *volumeProperty =
vtkVolumeProperty::New();<br>
&nbsp;volumeProperty-&gt;SetScalarOpacity(opacityTransferFunction);<br>
&nbsp;</p>
                <p><br>
&nbsp;<br>
&nbsp;vtkVolumeRayCastMapper *VolumeMapper = vtkVolumeRayCastMapper::New();<br>
&nbsp;&nbsp;&nbsp; vtkVolumeRayCastCompositeFunction *RayCastFunction =
vtkVolumeRayCastCompositeFunction::New();<br>
&nbsp;&nbsp;&nbsp; VolumeMapper-&gt;SetVolumeRayCastFunction(RayCastFunction); <br>
&nbsp;&nbsp;&nbsp; VolumeMapper-&gt;SetInput(br-&gt;GetOutput());</p>
                <p>&nbsp;&nbsp;&nbsp; <br>
&nbsp;vtkVolume *volume = vtkVolume::New();<br>
&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp; VolumeMapper-&gt;SetInput(br-&gt;GetOutput());<br>
&nbsp;&nbsp; volume-&gt;SetMapper(VolumeMapper);</p>
                <p>&nbsp;&nbsp;&nbsp; vtkCamera *aCamera = vtkCamera::New();<br>
&nbsp;&nbsp;&nbsp; aCamera-&gt;SetViewUp (0, 0,-1);<br>
&nbsp;&nbsp;&nbsp; aCamera-&gt;SetPosition (0, 1, 0);<br>
&nbsp;&nbsp;&nbsp; aCamera-&gt;SetFocalPoint (0, 0, 0);<br>
&nbsp;&nbsp;&nbsp; aCamera-&gt;ComputeViewPlaneNormal();</p>
                <p><br>
&nbsp;&nbsp;aRenderer-&gt;AddActor(volume);<br>
&nbsp;aRenderer-&gt;SetActiveCamera(aCamera);<br>
&nbsp;&nbsp;&nbsp; aRenderer-&gt;ResetCamera ();<br>
&nbsp;aRenderer-&gt;SetBackground(1,1,1);<br>
&nbsp;renWin-&gt;Render();<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp; iren-&gt;Initialize(); <br>
&nbsp;&nbsp;&nbsp; iren-&gt;Start(); <br>
&nbsp;<br>
}</p>
                </div>
                <div>&nbsp;</div>
                <div>Thanks again for all your help.</div>
                <div>Sharwari<br>
                <br>
&nbsp;</div>
                <div><span class="gmail_quote">On 8/31/06, <b
 class="gmail_sendername">Yixun Liu</b> &lt;<a
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:yxliu@fudan.edu.cn" target="_blank">yxliu@fudan.edu.cn </a>&gt;
wrote: </span>
                <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
                  <div>
                  <div bgcolor="#ffffff">
                  <div><font face="Bookman Old Style">Hi,</font></div>
                  <div><font face="Bookman Old Style">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. </font></div>
                  <div>&nbsp;</div>
                  <div><font face="Bookman Old Style">If you use
vtkVolume, use vtkVolumeRayCastMapper(vtk4.2.2) or&nbsp;use
vtkFixedPointVolumeRayCastMapper(vtk5.0). Note that if you use
vtkFixedPointVolumeRayCastMapper you no need to call
SetVolumeRayCastFunction(); </font></div>
                  <div>&nbsp;</div>
                  <div><font face="Bookman Old Style">Hope it help.</font></div>
                  </div>
                  <div><span>
                  <div>&nbsp;</div>
                  <div><font face="Bookman Old Style"><span name="st">Yixun</span>
Liu</font></div>
                  </span></div>
                  <div><span>
                  <blockquote
 style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
                    <div>----- Original Message ----- </div>
                    <div
 style="background: rgb(228, 228, 228) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b>From:</b>
                    <a title="sharwari@gmail.com"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:sharwari@gmail.com" target="_blank">Sharwari Mavalankar</a>
                    </div>
                    <div><b>To:</b> <a title="yxliu@fudan.edu.cn"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:yxliu@fudan.edu.cn" target="_blank">Yixun Liu</a> </div>
                    <div><b>Cc:</b> <a title="vtkusers@vtk.org"
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:vtkusers@vtk.org" target="_blank">VTK</a> </div>
                    <div><b>Sent:</b> Thursday, August 31, 2006 6:37 PM</div>
                    <div><b>Subject:</b> Re: Creating a Volume from 2D
BMP files.</div>
                    <div><br>
&nbsp;</div>
                    <div>hi Yixun,</div>
                    <div>Thanks for your email.I had a couple of more
questions though.</div>
                    <div>1.I do not want to visualize colour
slices.They are grey level images.</div>
                    <div>&nbsp;</div>
                    <div>2.Also if I put SetDataExtent() before the
Update() then I am getting an access violation error.What does the
Update function do exactly?</div>
                    <div>Also can you tell me what the five parameters
in SetDataExtent() mean?</div>
                    <div>&nbsp;</div>
                    <div>3.If I use vtkVolume what mapper should I use
to visualize the slices?</div>
                    <div>&nbsp;</div>
                    <div>&nbsp;</div>
                    <div>Thanks again for all your help.</div>
                    <div>Sharwari</div>
                    <div><br>
                    <br>
&nbsp;</div>
                    <div><span class="gmail_quote">On 8/23/06, <b
 class="gmail_sendername">Yixun Liu</b> &lt;<a
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="mailto:yxliu@fudan.edu.cn" target="_blank">yxliu@fudan.edu.cn </a>&gt;
wrote: </span>
                    <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
                      <div>
                      <div bgcolor="#ffffff">
                      <div><font face="Bookman Old Style">Hi,</font></div>
                      <div>&nbsp;</div>
                      <div><font face="Bookman Old Style">If you want
to visualize color slices, you need to </font></div>
                      <div><font face="Bookman Old Style">1. read these
slices. You need to put the SetDataExtent(0, 111, 0, 127, 1, 300);<br>
before Update();</font></div>
                      <div>&nbsp;</div>
                      <div><font face="Bookman Old Style">&nbsp;vtkTIFFReader
*v16 = vtkTIFFReader::New();<br>
                      </font><font face="Bookman Old Style">&nbsp;v16-&gt;SetFilePrefix("D:\\MyVC\\VTKtest\\Raycasting\\Data\\BrainColor\\brain");<br>
&nbsp;v16-&gt;SetFilePattern("%s%d.TIF"); <br>
&nbsp;v16-&gt;SetDataExtent(0, 111, 0, 127, 1, 300);<br>
&nbsp;v16-&gt;SetDataSpacing(1.2,1.2,0.5);<br>
&nbsp;v16-&gt;SetDataOrigin(0.0, 0.0, 0.0);</font></div>
                      <div><font face="Bookman Old Style">&nbsp;v16-&gt;SetNumberOfScalarComponents(3);<br>
                      </font><font face="Bookman Old Style">&nbsp;v16-&gt;Update();</font></div>
                      <div>&nbsp;</div>
                      <div><font face="Bookman Old Style">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. </font></div>
                      <div>&nbsp;</div>
                      <div><font face="Bookman Old Style">3. Opacity
map using vtkPiecewiseFunction</font></div>
                      <div>&nbsp;</div>
                      <div><font face="Bookman Old Style">4. no need
color map function</font></div>
                      <div>&nbsp;</div>
                      <div><font face="Bookman Old Style">5. you need
vtk5.0</font></div>
                      <div>&nbsp;</div>
                      <div><font face="Bookman Old Style">Regads,</font></div>
                      <div>&nbsp;</div>
                      <div><font face="Bookman Old Style"><span
 name="st">Yixun</span> Liu</font></div>
                      <div><br>
&nbsp;</div>
                      <div>&nbsp;</div>
                      </div>
                      </div>
                    </blockquote>
                    </div>
                    <br>
                  </blockquote>
                  </span></div>
                  </div>
                </blockquote>
                </div>
                <br>
                </span></div>
                </div>
              </blockquote>
              </div>
              <br>
              </span></div>
              </div>
            </blockquote>
            </div>
            <br>
            </span></div>
            <br>
_______________________________________________<br>
This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at: <a
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
Follow this link to subscribe/unsubscribe:<br>
            <a onclick="return top.js.OpenExtLink(window,event,this)"
 href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers
            </a><br>
            <br>
            <br>
          </blockquote>
          </div>
          <br>
          </span></div>
          <div>
          <pre><hr size="4" width="90%"></pre>
          </div>
          <div><span>_______________________________________________
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <a
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a>
Follow this link to subscribe/unsubscribe: <a
 onclick="return top.js.OpenExtLink(window,event,this)"
 href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a>
          </span></div>
          </div>
        </blockquote>
        </div>
        <br>
      </blockquote>
      </span></div>
      </div>
    </blockquote>
    </div>
    <br>
  </blockquote>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: <a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>
  </pre>
</blockquote>
</body>
</html>