<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face="Bookman Old Style">Hi,</FONT></DIV>
<DIV>vtkVolumeRayCastMapper does not support short type, so rescale it to
unsigned short using vtkImageShiftScale or use
vtkFixedPointVolumeRayCastMapper instead of vtkVolumeRayCastMapper.</DIV>
<DIV> </DIV>
<DIV><FONT face="Bookman Old Style">Hope it help.</FONT></DIV>
<DIV><FONT face="Bookman Old Style"></FONT> </DIV>
<DIV><FONT face="Bookman Old Style">Yixun</FONT></DIV>
<DIV><FONT face="Bookman Old Style"></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 9pt 宋体">----- Original Message ----- </DIV>
<DIV style="BACKGROUND: #e4e4e4; FONT: 9pt 宋体; font-color: black"><B>From:</B>
<A title=mrasingh@gmail.com href="mailto:mrasingh@gmail.com">Ashish Singh</A>
</DIV>
<DIV style="FONT: 9pt 宋体"><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: 9pt 宋体"><B>Sent:</B> Thursday, September 14, 2006 1:02
PM</DIV>
<DIV style="FONT: 9pt 宋体"><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> <BR> vtkRenderer *arenderer =
vtkRenderer::New();<BR> vtkRenderWindow *renwin =
vtkRenderWindow::New();<BR> vtkDICOMImageReader
*img1=vtkDICOMImageReader::New(); <BR><BR>
img1->SetFilePrefix("D:\\testimages\\dicomset\\IM");<BR>
img1->SetFilePattern("%s%d.dcm");<BR>
img1->SetFileNameSliceOffset(1);<BR>
img1->SetFileNameSliceSpacing(1);<BR>
img1->SetDataExtent(0,511,0,511,1,10);//512x512 images and 10 slices
<BR> img1->SetDataSpacing(360.0/512,360.0/512,1.0); //my image is
36cm x 36cm and 512x512<BR>
img1->SetDataOrigin(0.0,0.0,0.0);<BR>
img1->Update();<BR><BR> vtkVolume *vol=vtkVolume::New();<BR>
vtkVolumeRayCastMapper *volumemapper = vtkVolumeRayCastMapper::New();
<BR> vtkVolumeRayCastCompositeFunction
*rcf=vtkVolumeRayCastCompositeFunction::New();<BR>
volumemapper->SetVolumeRayCastFunction(rcf);<BR>
volumemapper->SetInput(img1->GetOutput());<BR>
vol->SetMapper(volumemapper); <BR><BR> vtkCamera
*cam=vtkCamera::New();<BR> cam->SetViewUp(0,0,-1);<BR>
cam->SetPosition(0,1,0);<BR> cam->SetFocalPoint(0,0,0);<BR>
cam->ComputeViewPlaneNormal();<BR><BR>
arenderer->AddActor(vol);<BR>
arenderer->SetActiveCamera(cam);<BR>
arenderer->ResetCamera();<BR>
arenderer->SetBackground(1,1,1);<BR> <BR>
renwin->AddRenderer(arenderer);<BR> vtkRenderWindowInteractor
*iren=vtkRenderWindowInteractor::New(); <BR>
iren->SetRenderWindow(renwin);<BR> renwin->Render();<BR>
iren->Initialize();<BR> iren->Start();<BR><BR>
img1->Delete();<BR> iren->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> <<A href="mailto:yxliu@fudan.edu.cn">yxliu@fudan.edu.cn</A>>
wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<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><FONT face="Bookman Old Style"></FONT> </DIV>
<DIV><FONT face="Bookman Old Style">Cheers,</FONT></DIV></DIV>
<DIV><SPAN class=sg>
<DIV><FONT face="Bookman Old Style"></FONT> </DIV>
<DIV><FONT face="Bookman Old Style">Yixun</FONT></DIV></SPAN></DIV>
<DIV><SPAN class=e id=q_10da9c15c887d41a_2>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: rgb(228,228,228) 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> 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>
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> <<A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:amy.squillacote@kitware.com"
target=_blank>amy.squillacote@kitware.com</A>> wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<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:
<BLOCKQUOTE
cite=http://mide275438e0609130955v6357c893r163226c364b56c12@mail.gmail.com
type="cite"></BLOCKQUOTE></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> (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> <BR> vtkRenderer *arenderer =
vtkRenderer::New();<BR> vtkRenderWindow *renwin =
vtkRenderWindow::New();<BR> vtkDICOMImageReader
*img1=vtkDICOMImageReader::New(); <BR><BR>
img1->SetFilePrefix("D:\\testimages\\dicomset\\IM");<BR>
img1->SetFilePattern("%s%d.dcm");<BR>
img1->SetFileNameSliceOffset(1);<BR>
img1->SetFileNameSliceSpacing(1);<BR>
img1->SetDataExtent(0,511,0,511,1,10);//512x512 images and 10 slices
<BR> img1->SetDataSpacing(360.0/512,360.0/512,1.0); //my image
is 36cm x 36cm and 512x512<BR>
img1->SetDataOrigin(0.0,0.0,0.0);<BR>
img1->Update();<BR><BR> vtkVolume
*vol=vtkVolume::New();<BR> vtkVolumeRayCastMapper *volumemapper =
vtkVolumeRayCastMapper::New(); <BR>
vtkVolumeRayCastCompositeFunction
*rcf=vtkVolumeRayCastCompositeFunction::New();<BR>
volumemapper->SetVolumeRayCastFunction(rcf);<BR>
volumemapper->SetInput(img1->GetOutput());<BR>
vol->SetMapper(volumemapper); <BR><BR> vtkCamera
*cam=vtkCamera::New();<BR> cam->SetViewUp(0,0,-1);<BR>
cam->SetPosition(0,1,0);<BR>
cam->SetFocalPoint(0,0,0);<BR>
cam->ComputeViewPlaneNormal();<BR><BR>
arenderer->AddActor(vol);<BR>
arenderer->SetActiveCamera(cam);<BR>
arenderer->ResetCamera();<BR>
arenderer->SetBackground(1,1,1);<BR> <BR>
renwin->AddRenderer(arenderer);<BR> vtkRenderWindowInteractor
*iren=vtkRenderWindowInteractor::New(); <BR>
iren->SetRenderWindow(renwin);<BR>
renwin->Render();<BR> iren->Initialize();<BR>
iren->Start();<BR><BR> img1->Delete();<BR>
iren->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> <<A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:sharwari@gmail.com" target=_blank>
sharwari@gmail.com</A>> wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV>hi Yixun,</DIV>
<DIV>I'll try and look into why the volume appears darker.</DIV>
<DIV> </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> </DIV>
<DIV> </DIV>
<DIV>Also if I have to visualize color bmp slices (24 bit ) 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> </DIV></SPAN></DIV>
<DIV><SPAN>
<DIV><SPAN class=gmail_quote>On 9/6/06, <B
class=gmail_sendername>Yixun Liu</B> <<A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:yxliu@fudan.edu.cn" target=_blank>yxliu@fudan.edu.cn</A>
> wrote: </SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<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> </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 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 <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> </DIV>
<DIV><FONT face="Bookman Old Style">Cheers,</FONT></DIV></DIV>
<DIV><SPAN>
<DIV> </DIV>
<DIV><FONT face="Bookman Old Style">Yixun
Liu</FONT></DIV></SPAN></DIV>
<DIV></DIV>
<DIV><SPAN>
<DIV>----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: rgb(228,228,228) 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> </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> </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> </DIV>
<DIV> </DIV>
<DIV>Also can you tell me the reason why the 3D volume seems darker
than the original images? </DIV>
<DIV>Is there any way I can scale the intensity of the images?</DIV>
<DIV>Thanks again,</DIV>
<DIV>Sharwari<BR><BR> </DIV>
<DIV><SPAN class=gmail_quote>On 9/3/06, <B
class=gmail_sendername>Yixun Liu</B> <<A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:yxliu@fudan.edu.cn"
target=_blank>yxliu@fudan.edu.cn</A> > wrote: </SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<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->SetNumberOfScalarComponents(3);</FONT></DIV>
<DIV> </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> </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> </DIV>
<DIV><FONT face="Bookman Old Style">Hope it help.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Bookman Old Style">Cheers,</FONT></DIV></DIV>
<DIV><SPAN>
<DIV> </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></DIV>
<DIV><SPAN>
<DIV>----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: rgb(228,228,228) 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> </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> </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> </DIV>
<DIV>2.While using the Addpoint() function of class
vtkPiecewiseFunction what do the two parameters in the Addpoint
function mean?</DIV>
<DIV>How do they affect the output?</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>This is code I have used. Do let me know if you can make any
more sugestions.</DIV>
<DIV> </DIV>
<DIV> </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> <BR> vtkRenderer
*aRenderer = vtkRenderer::New();<BR>
vtkRenderWindow *renWin =
vtkRenderWindow::New();<BR>
<BR> renWin->AddRenderer(aRenderer);<BR>
vtkRenderWindowInteractor *iren =
vtkRenderWindowInteractor::New(); <BR>
iren->SetRenderWindow(renWin);</P>
<P><BR> //create an instance of the class
vtkBMPReader<BR> vtkBMPReader *br =
vtkBMPReader::New();<BR> <BR> br->SetFilePrefix("C:\\Images\\conductivities\\slice");
<BR> br->SetFilePattern("%s%d.bmp");
<BR> br->SetFileNameSliceOffset(1);<BR> br->SetFileNameSliceSpacing(1);<BR> br->SetNumberOfScalarComponents(3);<BR> br->SetDataSpacing(0.4,0.4,10);<BR> br->SetDataOrigin(0,0,0);<BR> br->SetDataExtent(0,255,0,255,0,7);
<BR> br->Update();<BR> <BR>
vtkPiecewiseFunction *opacityTransferFunction =
vtkPiecewiseFunction::New();<BR> opacityTransferFunction->AddPoint(20,0.2);<BR> opacityTransferFunction->AddPoint(255,1.0);</P>
<P> vtkVolumeProperty *volumeProperty =
vtkVolumeProperty::New();<BR> volumeProperty->SetScalarOpacity(opacityTransferFunction);<BR> </P>
<P><BR> <BR> vtkVolumeRayCastMapper *VolumeMapper =
vtkVolumeRayCastMapper::New();<BR>
vtkVolumeRayCastCompositeFunction *RayCastFunction =
vtkVolumeRayCastCompositeFunction::New();<BR>
VolumeMapper->SetVolumeRayCastFunction(RayCastFunction);
<BR>
VolumeMapper->SetInput(br->GetOutput());</P>
<P> <BR> vtkVolume *volume =
vtkVolume::New();<BR> <BR>
VolumeMapper->SetInput(br->GetOutput());<BR>
volume->SetMapper(VolumeMapper);</P>
<P> vtkCamera *aCamera =
vtkCamera::New();<BR> aCamera->SetViewUp (0,
0,-1);<BR> aCamera->SetPosition (0, 1,
0);<BR> aCamera->SetFocalPoint (0, 0,
0);<BR>
aCamera->ComputeViewPlaneNormal();</P>
<P><BR> aRenderer->AddActor(volume);<BR> aRenderer->SetActiveCamera(aCamera);<BR>
aRenderer->ResetCamera
();<BR> aRenderer->SetBackground(1,1,1);<BR> renWin->Render();<BR> <BR>
iren->Initialize(); <BR> iren->Start();
<BR> <BR>}</P></DIV>
<DIV> </DIV>
<DIV>Thanks again for all your help.</DIV>
<DIV>Sharwari<BR><BR> </DIV>
<DIV><SPAN class=gmail_quote>On 8/31/06, <B
class=gmail_sendername>Yixun Liu</B> <<A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:yxliu@fudan.edu.cn" target=_blank>yxliu@fudan.edu.cn
</A>> wrote: </SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<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> </DIV>
<DIV><FONT face="Bookman Old Style">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(); </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Bookman Old Style">Hope it
help.</FONT></DIV></DIV>
<DIV><SPAN>
<DIV> </DIV>
<DIV><FONT face="Bookman Old Style"><SPAN name="st">Yixun</SPAN>
Liu</FONT></DIV></SPAN></DIV>
<DIV><SPAN>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
<DIV>----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: rgb(228,228,228) 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> </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> </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> </DIV>
<DIV>3.If I use vtkVolume what mapper should I use to
visualize the slices?</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Thanks again for all your help.</DIV>
<DIV>Sharwari</DIV>
<DIV><BR><BR> </DIV>
<DIV><SPAN class=gmail_quote>On 8/23/06, <B
class=gmail_sendername>Yixun Liu</B> <<A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:yxliu@fudan.edu.cn"
target=_blank>yxliu@fudan.edu.cn </A>> wrote: </SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV bgcolor="#ffffff">
<DIV><FONT face="Bookman Old Style">Hi,</FONT></DIV>
<DIV> </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> </DIV>
<DIV><FONT face="Bookman Old Style"> vtkTIFFReader *v16
= vtkTIFFReader::New();<BR></FONT><FONT
face="Bookman Old Style"> v16->SetFilePrefix("D:\\MyVC\\VTKtest\\Raycasting\\Data\\BrainColor\\brain");<BR> v16->SetFilePattern("%s%d.TIF");
<BR> v16->SetDataExtent(0, 111, 0, 127, 1,
300);<BR> v16->SetDataSpacing(1.2,1.2,0.5);<BR> v16->SetDataOrigin(0.0,
0.0, 0.0);</FONT></DIV>
<DIV><FONT
face="Bookman Old Style"> v16->SetNumberOfScalarComponents(3);<BR></FONT><FONT
face="Bookman Old Style"> v16->Update();</FONT></DIV>
<DIV> </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> </DIV>
<DIV><FONT face="Bookman Old Style">3. Opacity map using
vtkPiecewiseFunction</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Bookman Old Style">4. no need color map
function</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Bookman Old Style">5. you need
vtk5.0</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Bookman Old Style">Regads,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Bookman Old Style"><SPAN
name="st">Yixun</SPAN> Liu</FONT></DIV>
<DIV><BR> </DIV>
<DIV> </DIV></DIV></DIV></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></SPAN></DIV></DIV></BLOCKQUOTE></DIV><BR></SPAN></DIV>
<DIV></DIV></DIV></BLOCKQUOTE></DIV><BR></SPAN></DIV>
<DIV></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 width="90%" SIZE=4></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></DIV></DIV></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></SPAN></DIV>
<DIV></DIV></DIV></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>