[Insight-users] questions about generate and display sparse point cloud
Shaohua Fan
sfan53704 at yahoo . com
Thu, 2 Oct 2003 20:01:59 -0700 (PDT)
Hi Luis,
Thank you very much for answering my questions. I
enclosed the VTK file behind. I will take your advices
and generate/display the sparse points that way.
Currently I just want to get my program run and see
something on the screen, instead of worrying about the
efficiency:-).
I am writing some codes to approximate a 3D surface
using level set method from a point cloud input. The
sample and application codes in ITK seem either for
segmentation or registration, not one for 3D
reconstruction. The deformation in the
SimpleLevelSetsExample only use regular geometric
objects, i.e. those can be represented with analytical
form. I am not sure how to efficiently update the
distance funciton for irregular surface yet. Do you
have some suggestions about what application codes I
should look into which may be helpful for my project?
A side question: I think I have quite extensive c++
programming experience, but still feel kind of
difficult to write my own codes in ITk( I have some
STL experience, no generic programming experience).
What would be a relatively easy way for me to start?
-- I scanned the ITK user manual and am reading a book
about generic programming.
Thanks,
Shaohua
==============
viewSparsePointsVTK.tcl
package require vtkinteraction
set X 63
set Y 63
set Z 63
#
# This script renders the initial and the final
images from
# itk3DSimpleLevelSetsExample. The zero level set is
the
# surface of interest.
#
#
set img_data1 "sparse_spherePoints_3D.raw"
vtkImageReader imgReader1
imgReader1 SetDataExtent 0 $X 0 $Y 0 $Z
imgReader1 SetFileName $img_data1
imgReader1 SetDataByteOrderToLittleEndian
imgReader1 SetNumberOfScalarComponents 1
imgReader1 SetFileDimensionality 3
imgReader1 SetDataScalarTypeToFloat
vtkContourFilter marcher1
marcher1 SetNumberOfContours 1
marcher1 SetValue 0 0.0
marcher1 SetInput [imgReader1 GetOutput]
vtkOpenGLPolyDataMapper map1
map1 ScalarVisibilityOff
map1 ImmediateModeRenderingOn
map1 SetInput [marcher1 GetOutput]
vtkRenderer ren1
ren1 SetViewport 0 0 1 1
vtkRenderWindow renWin1
renWin1 AddRenderer ren1
renWin1 SetSize 256 256
vtkActor blob1
blob1 SetMapper map1
eval [blob1 GetProperty] SetColor 1.0 0.8 0.5
ren1 AddActor blob1
frame .windows
frame .buttons
vtkTkRenderWidget .windows.r1 -width 256 -height 256
-rw renWin1
pack .windows.r1 -side left -expand true -fill both
-padx 1 -pady 1
pack .windows .buttons -expand true -fill both
BindTkRenderWidget .windows.r1
--- Luis Ibanez <luis . ibanez at kitware . com> wrote:
>
> Hi Shaohua
>
>
> You will have to post the code of the VTK
> pipeline
> that you are using for visualization if you want
> to
> get some guidance on it.
>
> Without lookit at the code it is quite hard to
> figure
> out why you see are seeing a mesh and not a set
> of
> points. :-)
>
> Your attached program only contains the ITK code
> related to the generation of the sparse points.
>
> ---
>
> Why do you want to visualize the spare points as
> an image ?
>
> You probably will get better performance by
> saving
> the coordinates of the spare points and loading
> them in a
>
> vtkPolyData
>
>
http://www . vtk . org/doc/nightly/html/classvtkPolyData . html
>
> then pass them to a Glyp filter
>
>
http://www . vtk . org/doc/nightly/html/classvtkGlyph3D . html
>
>
>
> Some lateral advice:
>
> in lines 177 to 190 you are initializing the
> image
> to a value using three nested for-loops and
> SetPixel().
> This is very, very inefficient. You can simple
> invoke
>
> image->FillBuffer( value );
>
> or,
> use an ImageRegioniterator and a single while
> loop.
> (FillBuffer will be faster anyways).
>
>
>
>
> You will get a better interface to VTK if you
> save the image in VTK format instead of RAW.
>
> You can save in VTK format by simply using the
> extension ".vtk" in the filename. You don't
> even need to explicitly instantiate a
> VTKImageIO
> class.
>
>
>
>
>
> Regards,
>
>
>
> Luis
>
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping . yahoo . com