<!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><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><FONT face="Bookman Old Style"></FONT> </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><FONT face="Bookman Old Style"></FONT> </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><FONT face="Bookman Old Style"></FONT> </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">Cheers,</FONT></DIV>
<DIV><FONT face="Bookman Old Style"></FONT> </DIV>
<DIV><FONT face="Bookman Old Style">Yixun Liu</FONT></DIV>
<DIV><FONT face="Bookman Old Style"><BR></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=sharwari@gmail.com href="mailto:sharwari@gmail.com">Sharwari
Mavalankar</A> </DIV>
<DIV style="FONT: 9pt 宋体"><B>To:</B> <A title=yxliu@fudan.edu.cn
href="mailto:yxliu@fudan.edu.cn">Yixun Liu</A> </DIV>
<DIV style="FONT: 9pt 宋体"><B>Cc:</B> <A title=vtkusers@vtk.org
href="mailto:vtkusers@vtk.org">VTK</A> </DIV>
<DIV style="FONT: 9pt 宋体"><B>Sent:</B> Monday, September 04, 2006 6:50
AM</DIV>
<DIV style="FONT: 9pt 宋体"><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 href="mailto:yxliu@fudan.edu.cn">yxliu@fudan.edu.cn</A>>
wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 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><FONT face="Bookman Old Style"></FONT> </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><FONT face="Bookman Old Style"></FONT> </DIV>
<DIV><FONT face="Bookman Old Style">Hope it help.</FONT></DIV></DIV>
<DIV><SPAN class=sg>
<DIV><FONT face="Bookman Old Style"></FONT> </DIV>
<DIV><FONT face="Bookman Old Style"><SPAN class=st id=st
name="st">Yixun</SPAN> Liu</FONT></DIV></SPAN></DIV>
<DIV><SPAN class=e id=q_10d66d8eca6b69f3_2>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>----- Original Message ----- </DIV>
<DIV style="BACKGROUND: #e4e4e4"><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: #ccc 1px solid">
<DIV>
<DIV bgcolor="#ffffff">
<DIV><FONT face="Bookman Old Style">Hi,</FONT></DIV>
<DIV><FONT face="Bookman Old Style"></FONT> </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><FONT face="Bookman Old Style"></FONT> </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><FONT face="Bookman Old Style"></FONT> </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><FONT face="Bookman Old Style"></FONT> </DIV>
<DIV><FONT face="Bookman Old Style">3. Opacity map using
vtkPiecewiseFunction</FONT></DIV>
<DIV><FONT face="Bookman Old Style"></FONT> </DIV>
<DIV><FONT face="Bookman Old Style">4. no need color map
function</FONT></DIV>
<DIV><FONT face="Bookman Old Style"></FONT> </DIV>
<DIV><FONT face="Bookman Old Style">5. you need vtk5.0</FONT></DIV>
<DIV><FONT face="Bookman Old Style"></FONT> </DIV>
<DIV><FONT face="Bookman Old Style">Regads,</FONT></DIV>
<DIV><FONT face="Bookman Old Style"></FONT> </DIV>
<DIV><FONT face="Bookman Old Style"><SPAN name="st">Yixun</SPAN>
Liu</FONT></DIV>
<DIV><BR> </DIV>
<DIV><FONT
face="Bookman Old Style"></FONT> </DIV></DIV></DIV></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></SPAN></DIV>
<DIV></DIV></DIV></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>