Source codes for all chapters of "Visual Computing: Geometry, Graphics, and Vision"
Chapter 2: Abstract Data Structures.
- Fibonacci.cpp: Compute the first elements of Fibonacci series with or without pointer arithmetic.
- indexremapping.cpp: Conversions between 1D and 2D array indices of arrays.
- multidim-indexremapping.cpp: Conversions between 1D and dD array indices of arrays.
- linkedlist.cpp: Simple templated linked list class.
- areafloodfill.cpp: Area flood-filling using a queue.
Input image fillex.ppm (Result is written in floodfill-result.ppm)
- genericdictionary.cpp:
This short program shows how to overload the less than comparison operator to get a generic dictionary.
Two segments defining the diagonals of a square are created. We associate to them two line equations.
Depending on the position of the sweep line, we show that seg1 is below or above seg2.
- ShamosHoey.cpp:
Detect whether a set of line segments intersect or not.
Implement in a STL fashion a simple but optimal algorithm
to detect whether there exists an intersection point among a set of n segments in O(n log n) time.
Snapshot 1 PNG,
Snapshot 2 PNG and
Snapshot 3 PNG.
- srg.cpp: Statistical region growing segmentation using the union-find data structure of Tarjan.
Call srg.exe srg-source.ppm.
Input image srg-source.ppm (Result is written in srg-output.ppm)
- priorityqueue-stl.cpp: Priority queue in C++ STL (sample program)
- hashing-stl.cpp: 1D Hashing in C++ STL (sample program)
- traits-numerics.cpp: Traits class concept using the numerics class in C++
- traits-geometrykernel.cpp: Geometric traits class are useful for encapsulating the geometric kernel and the predicates of algorithms.
The code computes the convex hull of a point set using Andrew's algorithm (traits adapted from the class notes of Lutz Kettner). (This code is not robust. See chapter Robustness for more.)
Require OpenGL, see snapshot (PNG).
Chapter 3: Coordinate Pipelines.
- casting.cpp: Sample program which shows how to cast Euclidean into projective points and vice-versa.
- segmentintersection-projective.cpp: Compute the potential intersection point of two line segments using the cross-product: cross-product for
defining supporting lines and cross-product of the line vectors for determining the intersection projective point
(require OpenGL(R)).
snapshot1 PNG
snapshot2 PNG
- PolygonTransform.cpp: 2D polygon transformations (rotations, symmetries, shears, etc.). Require OpenGL(R).
snapshot1 PNG
snapshot2 PNG
snapshot3 PNG
- 3dtransformations.cpp: 3D mesh transformations (rotations, symmetries, shears, etc.). Require OpenGL(R).
Require the Stanford bunny mesh in the include file bunny.h.
snapshot1 PNG
snapshot2 PNG
snapshot3 PNG
The 3D bunny model is courtesy of (c) The Stanford 3D scanning repository, Marc Levoy.
- rotation-by-quaternion.cpp: Sample program that shows how to use quaternion arithmetic for performing rotations
around some given axis. Require OpenGL(R)
snapshot1 PNG
snapshot2 PNG
- isometricprojection.cpp: Choosing the view direction and hence the projection plane for getting an isometric projection of cube(s). Require OpenGL(R)
snapshot PNG
- openglviewport.cpp: Render several views onto a same device display using viewport mappings. Require OpenGL(R)
snapshot PNG
- Unperspective.cpp:
Rectify an input perspective image so that the planar surface (eg., sign, etc.) looks as if taken from front position.
You need the input image newcourt.ppm.
Result image is called unperspective-newcourt.ppm
- BlendHomography.cpp:
Match two perspective images by an homography related a common planar surface (book cover).
You need the input image bookcovers1.ppm and bookcovers2.ppm.
Result image is called blendhomography.ppm
- logpolartransform.cpp:
Log-polar transform on a source image.
You need the input image cambridge512.ppm.
Result image is called logpolar.ppm
- sphericalmapping.cpp:
Spherical mapping (theta-phi) of an image (with given field of view).
You need the input image normal120deg.ppm.
Result image is called sphericalimage.ppm
- lineconics.cpp:
An easy way to rasterize conics, line conics and dual conics.
Result image is called draw.ppm
- plucker.cpp:
A sample program using Plucker coordinates of lines to answer incidence or intersection test of lines.
Define the dot product of Plucker lines.
- radialdistortion.cpp:
A simple interactive interface for visualizing the radial distortion. Require OpenGL(R).
snapshot PNG
- checkerboard.cpp:
Create a checkerboard image, save this image into checkerboard.ppm and display a textured quad. Require OpenGL(R).
snapshot PNG
- spheremap.cpp:
Reflection mapping using a sphere map environment image and the Utah teapot. Require OpenGL(R).
You need this sphere map image: mirrorball512.ppm.
snapshot PNG
- latlong2spherical.cpp:
Environment map conversion procedure using generic pixel-to-ray and ray-to-pixel primitives.
You need this equirectangular environment map image: latlong.ppm.
The output is a spherical mirror ball image spherical.ppm that you can also use in the former
OpenGL(R) reflection mapping program.
Chapter 4: Images.
Chapter 5: Meshes.
- osculatingcircle.cpp: An interactive demo of osculating circles used to define a parametric curve curvature. Require OpenGL(R)
snapshot PNG.
- spheresubdivision.cpp: Approximating the sphere by a subdivision mesh. Start from the icosahedron base mesh and iteratively refine the subdivision.
Require OpenGL(R).
snapshot level 2 PNG,
snapshot level 4PNG.
- bunny-quadremeshing.off: Quad-dominant remeshing of the Stanford bunny in OFF file format (courtesy of Marinov).
The original bunny model is available from Stanford university. Here is the bunny.off file.
- bunny-proxyremeshing.off: Anisotropic remeshing of the Stanford bunny in OFF file format (courtesy of Alliez).
- bunny-conformal.obj: Conformal parameterization of the Stanford bunny in OBJ file format (courtesy of Degener).
- bunny-authalic.obj: Authalic/Conformal (obtained by a minimizing some tradeoff criterion) parameterization of the Stanford bunny in OBJ file format (courtesy of Alliez).
The 3D object converter shareware can display and convert numerous mesh formats.
The bunny 3D model is courtesy of (c) The Stanford 3D scanning repository, Marc Levoy.
Chapter 6: Animation.
- slerp.cpp: Interactive demo in OpenGL(R) of the spherical linear interpolation (SLERP) scheme.
snapshot PNG.
Chapter 7: Randomization.
- quicksort.cpp: Implementation of the randomized Quicksort comparison-based sorting algorithm.
- OrderStatistics.cpp: Implementation of the randomized SelectElement comparison-based order statistics algorithm.
Select the k-th smallest element of an array.
- matchsegments.cpp: Compute the scaled rigid transformation that matches a given pair of segments.
- ransac.cpp: Implementation of RANSAC from a pure combinatorial point of view.
- MiniBall.cpp: Implementation of the randomized recursive incremental construction of the smallest
enclosing ball of a 2D point set (as known as Welzl MINIBALL algorithm).
Chapter 8: Higher Dimensions for 3D.
Chapter 9: Robustness.
- heron.cpp: Floating-point computation of triangle areas using Heron's formula. Emphasize on the numerical errors (float or double data type) and their
impact in the flow of algorithm.
- segmentintersection-primitive.cpp: Define the predicate that answers true if and only if two line segments intersect.
The predicate uses only Orient2D orientation tests.
Snapshot 1 PNG,
Snapshot 1 PNG.
 
Last updated, May 2005.