Time Buffereing Program example
The time-buffer programming model is for situations such as movies where
you want to do some temporal processing; i. e., compute a function on
several image frames. The 3D model could address this problem if the file
was small enough to read into memory. However movies may be too large
to fit into memory. Furthermore, in real time applications you would
like to process the first frames of the movie while data acquisition
for later frames is still in progress. The buffer processing mode
provides support for this application. It provides a buffer of the The example program performs a 3x3x3 mean filter operation similar to the example 3D mean filter. vbmean.c/*********************************************************************/ /* vbmean Compute local 3x3x3 mean using buffer method */ /*********************************************************************/ #include "VisXV4.h" /* VisionX structure include file */ #include "Vutil.h" /* VisionX utility header files */ VXparam_t par[] = /* command line structure */ { { "if=", 0, " input file vbmean: compute local mean"}, { "of=", 0, " output file "}, { 0, 0, 0} }; #define IVAL par[0].val #define OVAL par[1].val int main(argc, argv) int argc; char *argv[]; { V3fstruct (im); V3fstruct (tm); int x,y; /* index counters */ int xx,yy,zz; /* window index counters */ int sum; VXparse(&argc, &argv, par); /* parse the command line */ while (Vbfread( &im, IVAL, 3)) { if ( im.type != VX_PBYTE || im.chan != 1) { /* check format */ fprintf (stderr, "image not byte type\n"); exit (1); } V3fembed(&tm, &im, 1,1,1,1,0,0); /* temp image with border */ for (y = im.ylo; y <= im.yhi; y++) { for (x = im.xlo; x <= im.xhi; x++) { sum = 0; for (zz = tm.zlo; zz <= tm.zhi; zz++) {/* compute the function */ for (yy = -1; yy <= 1; yy++) { for (xx = -1; xx <= 1; xx++) { sum = sum + tm.u[zz][y + yy][x + xx]; } } } im.u[0][y][x] = sum/9; } } V3fwrite (&im, OVAL); } exit(0); } Notes:
|