2. Example programs
Before anything else, let's look at some VXL example programs.
2.0.1 Hello world
Here's one to print "Hello world":
// Include standard C++ input/output library
// main is the first function to be called
// send string "hello world" to the standard
// output stream cout.
vcl_cout << "Hello world\n";
// Must return something from main
This is the same example that one might see in any C++ book, but for the
include line at the start. C++ books assume that your C++ compiler works,
which is not true of any C++ compiler in the year 2000. Chapter 3 goes
into more detail, but for the moment, include standard headers such as
2.0.2 Loading an image
Because most vxl programs use images in some form, here's an example of
loading an image, and printing the pixel value at (100,100). It assumes
the image is greyscale, and does no error checking.
// Load image into memory.
vil_image_view<vil_rgb<vxl_byte> > img = vil_load("foo.ppm");
// Access pixel (100,100) and print its value as an int.
vcl_cerr << "Pixel 100,100 = " << img(100,100) << vcl_endl;
This document was generated by Rumpelstiltskin on November, 22 2009 using texi2html 1.78.