1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
include <imhdr.h>
# DP_GSUBRAST -- Extract a sub-raster around a specified position such that
# all pixels within the specified radius are included.
pointer procedure dp_gsubrast (im, x, y, radius, lowx, lowy, nxpix, nypix)
pointer im # image descriptor
real x,y # position
real radius # radius
int lowx, lowy # lower boundaries of subraster
int nxpix, nypix # number of pixels in subraster
pointer imgs2r()
begin
# Determine the boundaries of the area.
lowx = int (x - radius) + 1
lowy = int (y - radius) + 1
lowx = max (1, lowx)
lowy = max (1, lowy)
# Compute the size of the area.
nxpix = min (int (x + radius), IM_LEN(im, 1)) - lowx + 1
nypix = min (int (y + radius), IM_LEN(im, 2)) - lowy + 1
# Return a pointer to the pixel buffer.
if ((nxpix < 1) || (nypix < 1))
return (NULL)
else
return (imgs2r (im, lowx, lowx + nxpix - 1, lowy, lowy + nypix - 1))
end
|