home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
vis-ftp.cs.umass.edu
/
vis-ftp.cs.umass.edu.tar
/
vis-ftp.cs.umass.edu
/
pub
/
Software
/
ASCENDER
/
ascendMar8.tar
/
UMass
/
BoldtNew
/
LLVS
/
average_plane.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-31
|
2KB
|
76 lines
/*
* ------------------------------------------------------------------
* average_plane.c - average plane
* Created by Robert Heller on Tue Feb 11 09:26:14 1992
* ------------------------------------------------------------------
* Modification History:
* ------------------------------------------------------------------
* Contents:
* ------------------------------------------------------------------
*
* Copyright (c) 1992 by University of Massachuetts
* All Rights Reserved
*
*/
#include <stdio.h>
#include <llvs_per_plane.h>
average_plane(inplane,inplane_info,outplane,outplane_info,limits,scale_factor)
PLANE *inplane, *outplane;
PLANE_INFO *inplane_info, *outplane_info;
LIMITS *limits;
float scale_factor;
{
int runlevel, indeltalev, outdeltalev;
int current_row, current_column, in_row, in_col, out_row, out_col;
float fpixel, sum, fback, divisor;
int wsize, wr, wc;
/* compute delta level */
runlevel = limits->level;
indeltalev = runlevel - inplane_info->level;
outdeltalev = runlevel - outplane_info->level;
wsize = 1 << (-indeltalev);
divisor = wsize * wsize;
/* grab background value */
if (inplane_info->datatype == FLOAT)
fback = inplane_info->background.flonum;
else fback = inplane_info->background.fixnum;
/* row loop */
for (current_row = limits->startrow;
current_row <= limits->endrow;
current_row += limits->deltarow) {
/* translate row offset */
TRANSLEVEL(in_row, current_row, indeltalev,
inplane_info->row_location);
TRANSLEVEL(out_row, current_row, outdeltalev,
outplane_info->row_location);
/* column loop */
for (current_column = limits->startcol;
current_column <= limits->endcol;
current_column += limits->deltacol) {
/* translate column offsets */
TRANSLEVEL(in_col, current_column, indeltalev,
inplane_info->column_location);
TRANSLEVEL(out_col, current_column, outdeltalev,
outplane_info->column_location);
sum = 0.0;
for (wr = 0; wr < wsize; wr++) {
for (wc = 0; wc < wsize; wc++) {
/* fetch pixel */
GET_PIXEL(fpixel, fback, inplane,
in_row + wr, in_col + wc,
(*inplane_info));
sum += fpixel;
}
}
fpixel = (sum / divisor) * scale_factor;
SET_PIXEL(fpixel, outplane, out_row, out_col,
(*outplane_info));
}
}
}