Getting Started
A good program for viewing pgm and ppm images in Windows is Irfanview. If you download the
plugins, Irfanview will also extract frames from mpgs to bmp.
pgm and ppm files usually have a 3 or 4 line header. The first line contains the
"magic number," a 'P' followed by a 2 (ascii pgm), 3 (ascii ppm), 5 (binary pgm),
or 6 (binary ppm). pgm are greyscale (0 black to 255 white) and ppm are color,
with three values per pixel: red, green, blue. An image in ascii mode can be
viewed easily in a text editor. This is less true for binary mode images, since
each integer gets exactly one character and also is not separated by spaces. You
should view each type in a text editor before beginning. In Windows, right-click
(or shift+right-click) the file and select "open with," then choose a text editor,
such as Notepad or Word.
ascii pgm:
input images: scascii.pgm
scbinary.pgm
"An edge point is a point in an image at the location of a significant local intensity change
in the image." Machine Vision 1995 McGraw-Hill. (The blue one with the eye.) You are
looking for a change in the image, which means: derivatives. You will find the gradient in the
x-direction (wrt x) and in the y-direction (wrt y.) The magnitude of the gradient is sqrt(gradx^2
+ grady^2) and the direction of the gradient is arctan(grady / gradx). The edge detection
algorithms below use a convolution mask to accomplish this. The Marr-Hildreth and Canny edge
detectors use Gaussian masks, whereas the Sobel operator is fixed.
Dr. Lobo's Robot Vision course: Two (garb34 & face05) input
images as well as diffpic.c, sobel.c, and marrh.c. If you have problems with this code,
try altering fopen calls to "rb" or "wb" instead of simply "r" and "w".
input and result images: sodacan.pgm
sobel.pgm
marrh.pgm
canny.pgm
View files
I might clean it up some more; please send me any special
requests. ;) The actual input to my segmentation stuff is just the skeleton;
you can get the skeleton any way you want. You do need a smooth silhouette
for the skeleton calculation to work. I've added in a little something to
turn the bgsub into a smoother skeleton, but it is in no way sophisticated.
It assumes that you're interested in the largest single region and deletes
all the pixels not connected to it, then dilates the white pixels, then erodes
them by dilating the black pixels. Just comment out that portion of the code
if you have your own silhouettes. It's partitioned off and should be easy
to spot. Please let me know if there are any more problems.
jdever@cs.ucf.edu
Last updated: 28 MAY 2003
Edge Detection
binary pgm:
"Getting" and "putting" images: filedemo.cpp
Background Subtraction
Sobel, Marr-Hildreth, and Canny: edgedemonc.cpp (no canny)
edgedemo.exe (canny)
REU Students: You should/will implements canny YOURSELF.
This background subtraction was put together by two former students of
the REU. This paper from 2000
by Stauffer and Grimson is cited for the algorithm. K (2+, 3-5
recommended) Gaussian distributions are used to determine to what model
a pixel belongs; each model belongs either to the background or foreground.
A foreground model which remains for many frames without moving will
eventually be called a background model unless the learn rate is set to zero.
Either pgm or ppm files are accepted; "writebackground" creates a pgm
file with the background black and the fore white.
My Very Simple Silhouette Extraction
Download zip
View sample batch file: dobgsub in\orig_####.pgm 1 85
View files
My Skeleton Segmentation
Download zip
View "readme"
View files
Download zip