Пример #1
0
static filt_init()
{
    /* count the filters to set nfilt */
    for (nfilt=0; nfilt<NFILTMAX && filt[nfilt].name; nfilt++);
    /* better way?? */
    mitchell_init(1./3., 1./3., (char *)&md);
    kaiser_init(6.5, 0., (char *)&kd);
}
Пример #2
0
/*!
 * Selects which filter to use in image reduction with [type] and sets the scaling factor
 * with [zoom], a value that must be less than 1.  The type can be 0 for a box
 * (equivalent to binning), 1 for a Blackman window, 2 for a triangle filter, 3 for a
 * Mitchell filter, or 4 or 5 for Lanczos 2 or Lanczos 3.  The total
 * width of the filter in the source image is returned in [outWidth].  Returns 1 for
 * a filter type out of range or 2 for a zoom out of range.
 */
int selectZoomFilter(int type, double zoom, int *outWidth)
{
    sFilt_func = NULL;
    if (type < 0 || type >= NUM_FILT)
        return 1;
    if (zoom >= 1. || zoom <= 0.)
        return 2;
    sFilt_func = filters[type].func;
    sXscale = sYscale = 1. / zoom;
    sXsupport = sYsupport = filters[type].supp * sXscale;
    sXwidth = sYwidth = (int)ceil(2. * sXsupport);
    *outWidth = sXwidth;
    if (type == 3)
        mitchell_init(1./3., 1./3.);
    return 0;
}