remove old vips7 mask stuff

just a wrapper now
This commit is contained in:
John Cupitt 2014-01-03 14:24:04 +00:00
parent bd17e1811b
commit 1f51409bf1
14 changed files with 218 additions and 1806 deletions

View File

@ -22,6 +22,7 @@ libcreate_la_SOURCES = \
mask_gaussian.c \
mask_gaussian_ring.c \
mask_gaussian_band.c \
mask_fractal.c \
eye.c \
grey.c \
xyz.c \

View File

@ -57,7 +57,7 @@ typedef struct _VipsMaskButterworthBand {
double order;
double frequency_cutoff_x;
double frequency_cutoff_y;
double r;
double radius;
double amplitude_cutoff;
} VipsMaskButterworthBand;
@ -76,7 +76,7 @@ vips_mask_butterworth_band_point( VipsMask *mask,
double order = butterworth_band->order;
double fcx = butterworth_band->frequency_cutoff_x;
double fcy = butterworth_band->frequency_cutoff_y;
double r2 = butterworth_band->r * butterworth_band->r;
double r2 = butterworth_band->radius * butterworth_band->radius;
double ac = butterworth_band->amplitude_cutoff;
double cnst = (1.0 / ac) - 1.0;
@ -130,11 +130,11 @@ vips_mask_butterworth_band_class_init(
G_STRUCT_OFFSET( VipsMaskButterworthBand, frequency_cutoff_y ),
0.0, 1000000.0, 0.5 );
VIPS_ARG_DOUBLE( class, "r", 9,
_( "r" ),
VIPS_ARG_DOUBLE( class, "radius", 9,
_( "radius" ),
_( "radius of circle" ),
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsMaskButterworthBand, r ),
G_STRUCT_OFFSET( VipsMaskButterworthBand, radius ),
0.0, 1000000.0, 0.1 );
VIPS_ARG_DOUBLE( class, "amplitude_cutoff", 10,
@ -153,7 +153,7 @@ vips_mask_butterworth_band_init(
butterworth_band->order = 1.0;
butterworth_band->frequency_cutoff_x = 0.5;
butterworth_band->frequency_cutoff_y = 0.5;
butterworth_band->r = 0.1;
butterworth_band->radius = 0.1;
butterworth_band->amplitude_cutoff = 0.5;
}
@ -165,7 +165,7 @@ vips_mask_butterworth_band_init(
* @order: filter order
* @frequency_cutoff_x: band position
* @frequency_cutoff_y: band position
* @r: band radius
* @radius: band radius
* @amplitude_cutoff: amplitude threshold
* @...: %NULL-terminated list of optional named arguments
*
@ -178,7 +178,7 @@ vips_mask_butterworth_band_init(
*
* Make an butterworth band-pass or band-reject filter, that is, one with a
* variable, smooth transition positioned at @frequency_cutoff_x,
* @frequency_cutoff_y, of radius @r.
* @frequency_cutoff_y, of radius @radius.
* The shape of the curve is controlled by
* @order: higher values give a sharper transition. See Gonzalez and Wintz,
* Digital Image Processing, 1987.
@ -190,7 +190,7 @@ vips_mask_butterworth_band_init(
int
vips_mask_butterworth_band( VipsImage **out, int width, int height,
double order, double frequency_cutoff_x, double frequency_cutoff_y,
double r, double amplitude_cutoff, ... )
double radius, double amplitude_cutoff, ... )
{
va_list ap;
int result;
@ -198,7 +198,7 @@ vips_mask_butterworth_band( VipsImage **out, int width, int height,
va_start( ap, amplitude_cutoff );
result = vips_call_split( "mask_butterworth_band", ap,
out, width, height,
order, frequency_cutoff_x, frequency_cutoff_y, r,
order, frequency_cutoff_x, frequency_cutoff_y, radius,
amplitude_cutoff );
va_end( ap );

View File

@ -133,7 +133,7 @@ vips_mask_fractal( VipsImage **out, int width, int height,
va_list ap;
int result;
va_start( ap, r );
va_start( ap, fractal_dimension );
result = vips_call_split( "mask_fractal", ap, out, width, height,
fractal_dimension );
va_end( ap );

View File

@ -56,7 +56,7 @@ typedef struct _VipsMaskGaussianBand {
double frequency_cutoff_x;
double frequency_cutoff_y;
double r;
double radius;
double amplitude_cutoff;
} VipsMaskGaussianBand;
@ -72,7 +72,7 @@ vips_mask_gaussian_band_point( VipsMask *mask, double dx, double dy )
double fcx = gaussian_band->frequency_cutoff_x;
double fcy = gaussian_band->frequency_cutoff_y;
double r2 = gaussian_band->r * gaussian_band->r;
double r2 = gaussian_band->radius * gaussian_band->radius;
double ac = gaussian_band->amplitude_cutoff;
double cnst = log( ac );
@ -117,11 +117,11 @@ vips_mask_gaussian_band_class_init( VipsMaskGaussianBandClass *class )
G_STRUCT_OFFSET( VipsMaskGaussianBand, frequency_cutoff_y ),
0.0, 1000000.0, 0.5 );
VIPS_ARG_DOUBLE( class, "r", 9,
_( "r" ),
VIPS_ARG_DOUBLE( class, "radius", 9,
_( "radius" ),
_( "radius of circle" ),
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsMaskGaussianBand, r ),
G_STRUCT_OFFSET( VipsMaskGaussianBand, radius ),
0.0, 1000000.0, 0.1 );
VIPS_ARG_DOUBLE( class, "amplitude_cutoff", 10,
@ -138,7 +138,7 @@ vips_mask_gaussian_band_init( VipsMaskGaussianBand *gaussian_band )
{
gaussian_band->frequency_cutoff_x = 0.5;
gaussian_band->frequency_cutoff_x = 0.5;
gaussian_band->r = 0.1;
gaussian_band->radius = 0.1;
gaussian_band->amplitude_cutoff = 0.5;
}
@ -149,7 +149,7 @@ vips_mask_gaussian_band_init( VipsMaskGaussianBand *gaussian_band )
* @height: image size
* @frequency_cutoff_x: band position
* @frequency_cutoff_y: band position
* @r: band radius
* @radius: band radius
* @amplitude_cutoff: amplitude threshold
* @...: %NULL-terminated list of optional named arguments
*
@ -162,7 +162,7 @@ vips_mask_gaussian_band_init( VipsMaskGaussianBand *gaussian_band )
*
* Make a gaussian band-pass or band-reject filter, that is, one with a
* variable, smooth transition positioned at @frequency_cutoff_x,
* @frequency_cutoff_y, of radius @r.
* @frequency_cutoff_y, of radius @radius.
*
* See also: vips_mask_ideal().
*
@ -170,7 +170,7 @@ vips_mask_gaussian_band_init( VipsMaskGaussianBand *gaussian_band )
*/
int
vips_mask_gaussian_band( VipsImage **out, int width, int height,
double frequency_cutoff_x, double frequency_cutoff_y, double r,
double frequency_cutoff_x, double frequency_cutoff_y, double radius,
double amplitude_cutoff, ... )
{
va_list ap;
@ -178,7 +178,7 @@ vips_mask_gaussian_band( VipsImage **out, int width, int height,
va_start( ap, amplitude_cutoff );
result = vips_call_split( "mask_gaussian_band", ap, out, width, height,
frequency_cutoff_x, frequency_cutoff_y, r,
frequency_cutoff_x, frequency_cutoff_y, radius,
amplitude_cutoff );
va_end( ap );

View File

@ -56,7 +56,7 @@ typedef struct _VipsMaskIdealBand {
double frequency_cutoff_x;
double frequency_cutoff_y;
double r;
double radius;
} VipsMaskIdealBand;
@ -71,7 +71,7 @@ vips_mask_ideal_band_point( VipsMask *mask, double dx, double dy )
VipsMaskIdealBand *ideal_band = (VipsMaskIdealBand *) mask;
double fcx = ideal_band->frequency_cutoff_x;
double fcy = ideal_band->frequency_cutoff_y;
double r2 = ideal_band->r * ideal_band->r;
double r2 = ideal_band->radius * ideal_band->radius;
double d1 = (dx - fcx) * (dx - fcx) + (dy - fcy) * (dy - fcy);
double d2 = (dx + fcx) * (dx + fcx) + (dy + fcy) * (dy + fcy);
@ -108,11 +108,11 @@ vips_mask_ideal_band_class_init( VipsMaskIdealBandClass *class )
G_STRUCT_OFFSET( VipsMaskIdealBand, frequency_cutoff_y ),
0.0, 1000000.0, 0.5 );
VIPS_ARG_DOUBLE( class, "r", 8,
_( "r" ),
VIPS_ARG_DOUBLE( class, "radius", 8,
_( "radius" ),
_( "radius of circle" ),
VIPS_ARGUMENT_REQUIRED_INPUT,
G_STRUCT_OFFSET( VipsMaskIdealBand, r ),
G_STRUCT_OFFSET( VipsMaskIdealBand, radius ),
0.0, 1000000.0, 0.1 );
}
@ -122,7 +122,7 @@ vips_mask_ideal_band_init( VipsMaskIdealBand *ideal_band )
{
ideal_band->frequency_cutoff_x = 0.5;
ideal_band->frequency_cutoff_y = 0.5;
ideal_band->r = 0.1;
ideal_band->radius = 0.1;
}
/**
@ -132,7 +132,7 @@ vips_mask_ideal_band_init( VipsMaskIdealBand *ideal_band )
* @height: image size
* @frequency_cutoff_x: position of band
* @frequency_cutoff_y: position of band
* @r: size of band
* @radius: size of band
* @...: %NULL-terminated list of optional named arguments
*
* Optional arguments:
@ -152,14 +152,15 @@ vips_mask_ideal_band_init( VipsMaskIdealBand *ideal_band )
*/
int
vips_mask_ideal_band( VipsImage **out, int width, int height,
double frequency_cutoff_x, double frequency_cutoff_y, double r, ... )
double frequency_cutoff_x, double frequency_cutoff_y,
double radius, ... )
{
va_list ap;
int result;
va_start( ap, r );
va_start( ap, radius );
result = vips_call_split( "mask_ideal_band", ap, out, width, height,
frequency_cutoff_x, frequency_cutoff_y, r );
frequency_cutoff_x, frequency_cutoff_y, radius );
va_end( ap );
return( result );

View File

@ -1,9 +1,7 @@
noinst_LTLIBRARIES = libfreq_filt.la
libfreq_filt_la_SOURCES = \
fmask4th.c \
im_phasecor_fft.c \
fmaskcir.c \
freq_dispatch.c \
im_disp_ps.c \
im_fractsurf.c \

View File

@ -1,797 +0,0 @@
/* @(#) Typical filter functions
* @(#) va_list is flag, filter parameters
* @(#) The following masks are implemented in this file
* @(#) lowpass highpass filters
* @(#) flag filter shape parameters
* @(#) 0 -\> idealhpf, parameters: frequency cutoff
* @(#) 1 -\> ideallpf, parameters: frequency cutoff
* @(#) 2 -\> buthpf, parameters: order, frequency cutoff, amplitude cutoff
* @(#) 3 -\> butlpf, parameters: order, frequency cutoff, amplitude cutoff
* @(#) 4 -\> gaussianlpf, parameters: frequency cutoff, amplitude cutoff
* @(#) 5 -\> gaussianhpf, parameters: frequency cutoff, amplitude cutoff
* @(#) ring pass ring reject filters
* @(#) 6 -\> idealrpf, parameters: frequency cutoff, width
* @(#) 7 -\> idealrrf, parameters: frequency cutoff, width
* @(#) 8 -\> butrpf, parameters: order, freq cutoff, width, ampl cutoff
* @(#) 9 -\> butrrf, parameters: order, freq cutoff, width, ampl cutoff
* @(#) 10 -\> gaussianrpf, parameters: frequency cutoff, width, ampl cutoff
* @(#) 11 -\> gaussianrrf, parameters: frequency cutoff, width, ampl cutoff
* @(#) fractal filters (for filtering gaussian noises only)
* @(#) 18 -> fractal, parameters: fractal dimension
* @(#)
* @(#) Initially one forth of the coefficients is created and it is copied over
* @(#) the four quadrants for faster processing
* @(#)
* @(#) Functions in this file; for explanations see each function
* @(#)
* @(#) float *
* @(#) im__create_quarter( out, xs, ys, flag, ap )
* @(#) IMAGE *out;
* @(#) int xs, ys;
* @(#) enum mask_type flag;
* @(#) va_list ap;
* @(#)
*
* Written on: Nov 1991
* Updated on: Dec 1991
* 20/9/95 JC
* - modernised
*/
/*
This file is part of VIPS.
VIPS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
/*
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
#include <vips/intl.h>
#include <stdio.h>
#include <math.h>
#include <stdarg.h>
#include <vips/vips.h>
/************************************************************************/
/* malloc space and create normalised coefficients accross */
/* the x (horizontal) and y (vertical) direction. */
/************************************************************************/
static int
alloc( IMAGE *out, int xs, int ys, double **xd, double **yd, float **coeff )
{
int i;
double *x, *y;
float *c;
x = IM_ARRAY( out, xs/2 + 1, double );
y = IM_ARRAY( out, ys/2 + 1, double );
c = IM_ARRAY( out, (xs/2 + 1)*(ys/2 + 1), float );
if( !x || !y || !c )
return( -1 );
for( i = 0; i < ys/2 + 1; i++ )
y[i] = (i * i) / ((double) (ys*ys/4));
for( i = 0; i < xs/2 + 1; i++ )
x[i] = (i * i) / ((double) (xs*xs/4));
*xd = x; *yd = y; *coeff = c;
return( 0 );
}
/* xs and ys are the sizes of the final mask; all functions returns
* the coefficients for one forth of the final mask
*/
/************************************************************************/
/* FLAG = 0 */
/* Creates an ideal high pass filter mask */
/************************************************************************/
static float *
ideal_hpf( IMAGE *out, int xs, int ys, double fc )
{
int x, y;
float *coeff, *cpcoeff;
double *xd, *yd, fc2, distance2;
if( xs != ys || fc < 0.0 ) {
im_error( "ideal_hpf", "%s", _( "bad args" ) );
return( NULL );
}
if( fc > 1.0 && fc <= xs/2 )
fc2 = fc * fc * 4.0 / (double)(xs * ys);
else if( fc <= 1.0 && fc > 0.0 )
fc2 = fc * fc;
else {
im_error( "ideal_hpf", "%s", _( "bad args" ) );
return( NULL );
}
if( alloc( out, xs, ys, &xd, &yd, &coeff ) )
return( NULL );
cpcoeff = coeff;
for( y = 0; y < ys/2 + 1; y++ )
for( x = 0; x < xs/2 + 1; x++ ) {
distance2 = xd[x] + yd[y];
if( distance2 > fc2 )
*cpcoeff++ = 1.0;
else
*cpcoeff++ = 0.0;
}
*coeff = 1.0;
return( coeff );
}
/************************************************************************/
/* FLAG = 1 */
/* Creates an ideal low pass filter mask */
/************************************************************************/
static float *
ideal_lpf( IMAGE *out, int xs, int ys, double fc )
{
int x, y;
float *coeff, *cpcoeff;
double *xd, *yd, fc2, distance2;
if( xs != ys || fc <= 0.0 ) {
im_error( "ideal_lpf", "%s", _( "bad args" ) );
return( NULL );
}
if( fc > 1.0 && fc <= xs/2 )
fc2 = fc * fc * 4.0 / (double)(xs * ys);
else if( fc <= 1.0 && fc > 0.0 )
fc2 = fc * fc;
else {
im_error( "ideal_lpf", "%s", _( "bad args" ) );
return( NULL );
}
if( alloc( out, xs, ys, &xd, &yd, &coeff ) )
return( NULL );
cpcoeff = coeff;
for( y = 0; y < ys/2 + 1; y++ )
for( x = 0; x < xs/2 + 1; x++ ) {
distance2 = xd[x] + yd[y];
if( distance2 <= fc2 )
*cpcoeff++ = 1.0;
else
*cpcoeff++ = 0.0;
}
return( coeff );
}
/************************************************************************/
/* FLAG = 2 */
/* Creates an Butterworth high pass filter mask */
/************************************************************************/
static float *
butterworth_hpf( IMAGE *out, int xs, int ys,
double order, double fc, double ac )
{
int x, y;
float *coeff, *cpcoeff;
double *xd, *yd, fc2, distance2, cnst;
if( xs != ys || fc < 0.0 || order < 1.0 || ac <= 0.0 || ac >= 1.0 ) {
im_error( "butterworth_hpf", "%s", _( "bad args" ) );
return( NULL );
}
if( fc > 1.0 && fc <= xs/2 )
fc2 = fc * fc * 4.0 / (double)(xs * ys);
else if( fc <= 1.0 && fc > 0.0 )
fc2 = fc * fc;
else {
im_error( "butterworth_hpf", "%s", _( "bad args" ) );
return( NULL );
}
if( alloc( out, xs, ys, &xd, &yd, &coeff) )
return( NULL );
cpcoeff = coeff;
cnst = (1.0 / ac) - 1.0;
for( y = 0; y < ys/2 + 1; y++ )
for( x = 0; x < xs/2 + 1; x++ ) {
/* Leave the dc component unaltered
*/
if( x == 0 && y == 0 )
*cpcoeff++ = 1.0;
else {
distance2 = fc2 / (xd[x] + yd[y]);
*cpcoeff++ = 1.0 /
(1.0 + cnst * pow( distance2, order ));
}
}
return( coeff );
}
/************************************************************************/
/* FLAG = 3 */
/* Creates an Butterworth low pass filter mask */
/************************************************************************/
static float *
butterworth_lpf( IMAGE *out, int xs, int ys,
double order, double fc, double ac )
{
int x, y;
float *coeff, *cpcoeff;
double *xd, *yd, fc2, distance2, cnst;
if( xs != ys || fc <= 0.0 || order < 1.0 || ac >= 1.0 || ac <= 0.0 ) {
im_error( "butterworth_lpf", "%s", _( "bad args" ) );
return( NULL );
}
if( fc > 1.0 && fc <= xs/2 )
fc2 = fc * fc * 4.0 / (double)(xs * ys);
else if( fc <= 1.0 && fc > 0.0 )
fc2 = fc * fc;
else {
im_error( "butterworth_lpf", "%s", _( "bad args" ) );
return( NULL );
}
if( alloc( out, xs, ys, &xd, &yd, &coeff ) )
return( NULL );
cpcoeff = coeff;
cnst = (1.0/ac) - 1.0;
for( y = 0; y < ys/2 + 1; y++ )
for( x = 0; x < xs/2 + 1; x++ ) {
distance2 = (xd[x] + yd[y])/fc2;
*cpcoeff++ = 1.0 /
(1.0 + cnst * pow( distance2, order ));
}
return( coeff );
}
/************************************************************************/
/* FLAG = 4 */
/* Creates a gaussian high pass filter mask */
/************************************************************************/
static float *
gaussian_hpf( IMAGE *out, int xs, int ys, double fc, double ac )
{
int x, y;
float *coeff, *cpcoeff;
double *xd, *yd, fc2, distance2, cnst;
if( xs != ys || fc <= 0.0 || ac >= 1.0 || ac <= 0.0 ) {
im_error( "gaussian_hpf", "%s", _( "bad args" ) );
return( NULL );
}
if( fc > 1.0 && fc <= xs/2 )
fc2 = fc * fc * 4.0 / (double)(xs * ys);
else if( fc <= 1.0 && fc > 0.0 )
fc2 = fc * fc;
else {
im_error( "gaussian_hpf", "%s", _( "bad args" ) );
return( NULL );
}
if( alloc( out, xs, ys, &xd, &yd, &coeff ) )
return( NULL );
cpcoeff = coeff;
cnst = -log( ac );
for( y = 0; y < ys/2 + 1; y++ )
for( x = 0; x < xs/2 + 1; x++ ) {
distance2 = (xd[x] + yd[y])/fc2;
*cpcoeff++ = 1.0 - exp( -cnst * distance2 );
}
*coeff = 1.0;
return( coeff );
}
/************************************************************************/
/* FLAG = 5 */
/* Creates a gaussian low pass filter mask */
/************************************************************************/
static float *
gaussian_lpf( IMAGE *out, int xs, int ys, double fc, double ac )
{
int x, y;
float *coeff, *cpcoeff;
double *xd, *yd, fc2, distance2, cnst;
if( xs != ys || fc < 0.0 || ac >= 1.0 || ac <= 0.0 ) {
im_error( "gaussian_lpf", "%s", _( "bad args" ) );
return( NULL );
}
if( fc > 1.0 && fc <= xs/2 )
fc2 = fc * fc * 4.0 / (double)(xs * ys);
else if( fc <= 1.0 && fc > 0.0 )
fc2 = fc * fc;
else {
im_error( "gaussian_lpf", "%s", _( "bad args" ) );
return( NULL );
}
if( alloc( out, xs, ys, &xd, &yd, &coeff ) )
return( NULL );
cpcoeff = coeff;
cnst = -log( ac );
for( y = 0; y < ys/2 + 1; y++ )
for( x = 0; x < xs/2 + 1; x++ ) {
distance2 = (xd[x] + yd[y])/fc2;
*cpcoeff++ = exp( - cnst * distance2 );
}
return( coeff );
}
/************************************************************************/
/* FLAG = 6 */
/* Creates an ideal ring pass filter mask */
/* The band is a RING of internal radius fc-df and external radius fc+df*/
/************************************************************************/
static float *
ideal_rpf( IMAGE *out, int xs, int ys, double fc, double width )
{
int x, y;
float *coeff, *cpcoeff;
double *xd, *yd, df, distance2, radius1_2, radius2_2;
if( xs != ys || fc <= 0 || width <= 0 ) {
im_error( "ideal_rpf", "%s", _( "bad args" ) );
return( NULL );
}
df = width/2.0;
if( fc <= 1.0 && df < 1.0 && fc - df > 0.0 ) {
radius1_2 = (fc-df)*(fc-df);
radius2_2 = (fc+df)*(fc+df);
}
else if( fc - df > 1.0 && df >= 1.0 && fc <= xs/2 ) {
radius1_2 = (fc - df) * (fc - df) * 4.0 / ((double)(xs * xs));
radius2_2 = (fc + df) * (fc + df) * 4.0 / ((double)(xs * xs));
}
else {
im_error( "ideal_rpf", "%s", _( "bad args" ) );
return( NULL );
}
if( alloc( out, xs, ys, &xd, &yd, &coeff ) )
return( NULL );
cpcoeff = coeff;
for( y = 0; y < ys/2 + 1; y++ )
for( x = 0; x < xs/2 + 1; x++ ) {
distance2 = xd[x] + yd[y];
if( distance2 < radius2_2 && distance2 > radius1_2 )
*cpcoeff++ = 1.0;
else
*cpcoeff++ = 0.0;
}
*coeff = 1.0;
return( coeff );
}
/************************************************************************/
/* FLAG = 7 */
/* Creates an ideal band reject filter mask */
/* The band is a RING of internal radius fc-df and external radius fc+df*/
/************************************************************************/
static float *
ideal_rrf( IMAGE *out, int xs, int ys, double fc, double width )
{
int x, y;
float *coeff, *cpcoeff;
double *xd, *yd, df, distance2, radius1_2, radius2_2;
if( xs != ys || fc < 0.0 || width <= 0.0 ) {
im_error( "ideal_rrf", "%s", _( "bad args" ) );
return( NULL );
}
df = width/2.0;
if( fc <= 1.0 && df < 1.0 && fc - df > 0.0 ) {
radius1_2 = (fc-df)*(fc-df);
radius2_2 = (fc+df)*(fc+df);
}
else if( fc - df > 1.0 && df >= 1.0 && fc <= xs/2 ) {
radius1_2 = (fc - df) * (fc - df) * 4.0 / ((double)(xs * xs));
radius2_2 = (fc + df) * (fc + df) * 4.0 / ((double)(xs * xs));
}
else {
im_error( "ideal_rrf", "%s", _( "bad args" ) );
return( NULL );
}
if( alloc( out, xs, ys, &xd, &yd, &coeff ) )
return( NULL );
cpcoeff = coeff;
for( y = 0; y < ys/2 + 1; y++ )
for( x = 0; x < xs/2 + 1; x++ ) {
distance2 = xd[x] + yd[y];
if( distance2 < radius2_2 && distance2 > radius1_2 )
*cpcoeff++ = 0.0;
else
*cpcoeff++ = 1.0;
}
return( coeff );
}
/************************************************************************/
/* FLAG = 8 */
/* Creates a butterworth band pass filter mask */
/* The band is a RING of internal radius fc-df and external radius fc+df*/
/************************************************************************/
static float *
butterworth_rpf( IMAGE *out, int xs, int ys,
double order, double fc, double width, double ac )
{
int x, y;
float *coeff, *cpcoeff;
double *xd, *yd, d, df, ndf, ndf2, nfc, cnst;
if( xs != ys || fc <= 0.0 || width <= 0.0 ||
order < 1.0 || ac >= 1.0 || ac <= 0.0 ) {
im_error( "butterworth_rpf", "%s", _( "bad args" ) );
return( NULL );
}
df = width/2.0;
if( fc <= 1.0 && df < 1.0 && fc-df > 0.0 ) {
nfc = fc;
ndf = width/2.0;
}
else if( fc - df > 1.0 && df >= 1.0 && fc <= xs/2 ) {
nfc = fc * 2.0 /(double)xs;
ndf = width /(double)ys;
}
else {
im_error( "butterworth_rpf", "%s", _( "bad args" ) );
return( NULL );
}
if( alloc( out, xs, ys, &xd, &yd, &coeff ) )
return( NULL );
cpcoeff = coeff;
cnst = (1.0/ac) - 1.0;
ndf2 = ndf * ndf;
for( y = 0; y < ys/2 + 1; y++ )
for( x = 0; x < xs/2 + 1; x++ ) {
d = sqrt( xd[x] + yd[y] );
*cpcoeff++ = 1.0 /
(1.0 + cnst *
pow( (d-nfc)*(d-nfc)/ndf2, order ));
}
*coeff = 1.0;
return( coeff );
}
/************************************************************************/
/* FLAG = 9 */
/* Creates a butterworth ring reject filter mask */
/* The band is a RING of internal radius fc-df and external radius fc+df*/
/************************************************************************/
static float *
butterworth_rrf( IMAGE *out, int xs, int ys,
double order, double fc, double width, double ac )
{
int x, y;
float *coeff, *cpcoeff;
double *xd, *yd, d, df, ndf, ndf2, nfc, cnst;
if( xs != ys || fc <= 0.0 || width <= 0.0 ||
order < 1.0 || ac >= 1.0 || ac <= 0.0 ) {
im_error( "butterworth_rrf", "%s", _( "bad args" ) );
return( NULL );
}
df = width/2.0;
if( fc <= 1.0 && df < 1.0 && fc-df > 0.0 ) {
nfc = fc;
ndf = width/2.0;
}
else if( fc - df > 1.0 && df >= 1.0 && fc <= xs/2 ) {
nfc = fc * 2.0 /(double)xs;
ndf = width /(double)ys;
}
else {
im_error( "butterworth_rrf", "%s", _( "bad args" ) );
return( NULL );
}
if( alloc( out, xs, ys, &xd, &yd, &coeff ) )
return( NULL );
cpcoeff = coeff;
cnst = (1.0/ac) - 1.0;
ndf2 = ndf * ndf;
for( y = 0; y < ys/2 + 1; y++ )
for( x = 0; x < xs/2 + 1; x++ ) {
d = sqrt( xd[x] + yd[y] );
if( d == 0.0 )
*cpcoeff++ = 1.0;
else
*cpcoeff++ = 1.0 /
(1.0 + cnst * pow(
ndf2/((d-nfc)*(d-nfc)), order ));
}
return( coeff );
}
/************************************************************************/
/* FLAG = 10 */
/* Creates a gaussian band pass filter mask */
/* The band is a RING of internal radius fc-df and external radius fc+df*/
/************************************************************************/
static float *
gaussian_rpf( IMAGE *out, int xs, int ys, double fc, double width, double ac )
{
int x, y;
float *coeff, *cpcoeff;
double *xd, *yd, d, df, ndf, ndf2, nfc, cnst;
if( xs != ys || fc < 0.0 || width <= 0.0 || ac <= 0.0 || ac > 1.0 ) {
im_error( "gaussian_rpf", "%s", _( "bad args" ) );
return( NULL );
}
df = width/2.0;
if( fc <= 1.0 && df < 1.0 && fc - df > 0.0 ) {
nfc = fc;
ndf = width/2.0;
}
else if( fc - df > 1.0 && df >= 1.0 && fc <= xs/2 ) {
nfc = fc * 2.0 /(double) xs;
ndf = width /(double)ys;
}
else {
im_error( "gaussian_rpf", "%s", _( "bad args" ) );
return( NULL );
}
if( alloc( out, xs, ys, &xd, &yd, &coeff ) )
return( NULL );
cpcoeff = coeff;
cnst = -log( ac );
ndf2 = ndf * ndf;
for( y = 0; y < ys/2 + 1; y++ )
for( x = 0; x < xs/2 + 1; x++ ) {
d = sqrt( xd[x] + yd[y] );
*cpcoeff++ = exp( -cnst * (d-nfc) * (d-nfc)/ndf2 );
}
*coeff = 1.0;
return( coeff );
}
/************************************************************************/
/* FLAG = 11 */
/* Creates a gaussian band reject filter mask */
/* The band is a RING of internal radius fc-df and external radius fc+df*/
/************************************************************************/
static float *
gaussian_rrf( IMAGE *out, int xs, int ys, double fc, double width, double ac )
{
int x, y;
float *coeff, *cpcoeff;
double *xd, *yd, d, df, ndf, ndf2, nfc, cnst;
if( xs != ys || fc < 0.0 || width <= 0.0 || ac <= 0.0 || ac > 1.0 ) {
im_error( "gaussian_rrf", "%s", _( "bad args" ) );
return( NULL );
}
df = width/2.0;
if( fc <= 1.0 && df < 1.0 && fc - df > 0.0 ) {
nfc = fc;
ndf = width/2.0;
}
else if( fc - df > 1.0 && df >= 1.0 && fc <= xs/2 ) {
nfc = fc * 2.0 /(double) xs;
ndf = width / (double)ys;
}
else {
im_error( "gaussian_rrf", "%s", _( "bad args" ) );
return( NULL );
}
if( alloc( out, xs, ys, &xd, &yd, &coeff ) )
return( NULL );
cpcoeff = coeff;
cnst = -log( ac );
ndf2 = ndf * ndf;
for( y = 0; y < ys/2 + 1; y++ )
for( x = 0; x < xs/2 + 1; x++ ) {
d = sqrt( xd[x] + yd[y] );
*cpcoeff++ = 1.0 -
exp( -cnst * (d-nfc) * (d-nfc) / ndf2 );
}
return( coeff );
}
/************************************************************************/
/* FLAG = 18 */
/* Theoretically the power spectrum of a fractal surface should decay
* according to its fractal dimension
* This program should be used to create fractal images by filtering the
* power spectrum of Gaussian white noise
* More specifically according to PIET:
* since the coefficients of fractal noise
* < |vsubk|^2 > decay as 1/( |f|^(beta+1) )
* or since beta=2*H + 1, beta= 7-2*D
* < |vsubk|^2 > decay as 1/( |f|^(8-2*D) )
* and the fractal filter which should produce vsubk
* should have transfer function decaying as 1/( |f|^((beta+1)/2) )
* where f = sqrt(fsubx * fsubx + fsuby *fsuby)
* Finally the filter has transfer function decaying as
* sqrt(fsubx*fsubx+fsuby*fsuby)^(D-4) or
* (fsubx*fsubx+fsuby*fsuby)^((D-4)/2) <--- This relation is used.
* On the other hand if D=3-H, the filtermask should decay as
* (fsubx*fsubx+fsuby*fsuby)^(-(H+1)/2) , 0<H<1
* which is exactly the same as above (PIET page 108)
* Please note that when a filter mask is created to dc coefficient is
* set to 1.0 and therefore when a mask is scaled for display
* the dc coefficient appears to be wrong (it is not!!)
*/
/************************************************************************/
static float *
fractal_flt( IMAGE *out, int xs, int ys, double frdim )
{
int x, y;
float *coeff, *cpcoeff;
double *xd, *yd, distance2, cnst;
if( xs != ys || frdim <= 2.0 || frdim >= 3.0 ) {
im_error( "fractal_flt", "%s", _( "bad args" ) );
return( NULL );
}
if( alloc( out, xs, ys, &xd, &yd, &coeff ) )
return( NULL );
cpcoeff = coeff;
cnst = (frdim - 4.0)/2.0;
for( y = 0; y < ys/2 + 1; y++ )
for( x = 0; x < xs/2 + 1; x++ ) {
distance2 = xd[x] + yd[y];
if( distance2 == 0.0 )
*cpcoeff++ = 1.0;
else
*cpcoeff++ = pow( distance2, cnst );
}
return( coeff );
}
/* Creates one forth of the mask coefficients. If the final mask is
* xsize by xsize, one forth should have sizes (xsize/2 + 1) by (ysize/2 + 1)
* This happens because the horizontal spatial frequencies extend
* from -xsize/2 up to (xsize/2 - 1) inclusive and
* the vertical spatial frequencies
* from -ysize/2 up to (ysize/2 - 1) inclusive
* In order to calculate the spatial frequencies at location (x, y)
* the maximum spatial frequency at the horizontal direction xsize/2 and
* the maximum spatial frequency at the vertical direction ysize/2 have
* been normalised to 1.0.
* All arithmetic internally has been carried out in double precision;
* however all masks are written as floats with maximum value normalised to 1.0
*/
float *
im__create_quarter( IMAGE *out, int xs, int ys, VipsMaskType flag, va_list ap )
{
/* May be fewer than 4 args ... but extract them all anyway. Should be
* safe.
*/
double p0 = va_arg( ap, double );
double p1 = va_arg( ap, double );
double p2 = va_arg( ap, double );
double p3 = va_arg( ap, double );
switch( flag ) {
/* High pass - low pass
*/
case VIPS_MASK_IDEAL_HIGHPASS:
return( ideal_hpf( out, xs, ys, p0 ) );
case VIPS_MASK_IDEAL_LOWPASS:
return( ideal_lpf( out, xs, ys, p0 ) );
case VIPS_MASK_BUTTERWORTH_HIGHPASS:
return( butterworth_hpf( out, xs, ys, p0, p1, p2 ) );
case VIPS_MASK_BUTTERWORTH_LOWPASS:
return( butterworth_lpf( out, xs, ys, p0, p1, p2 ) );
case VIPS_MASK_GAUSS_HIGHPASS:
return( gaussian_hpf( out, xs, ys, p0, p1 ) );
case VIPS_MASK_GAUSS_LOWPASS:
return( gaussian_lpf( out, xs, ys, p0, p1 ) );
/* Ring pass - ring reject.
*/
case VIPS_MASK_IDEAL_RINGPASS:
return( ideal_rpf( out, xs, ys, p0, p1 ) );
case VIPS_MASK_IDEAL_RINGREJECT:
return( ideal_rrf( out, xs, ys, p0, p1 ) );
case VIPS_MASK_BUTTERWORTH_RINGPASS:
return( butterworth_rpf( out,
xs, ys, p0, p1, p2, p3 ) );
case VIPS_MASK_BUTTERWORTH_RINGREJECT:
return( butterworth_rrf( out,
xs, ys, p0, p1, p2, p3 ) );
case VIPS_MASK_GAUSS_RINGPASS:
return( gaussian_rpf( out, xs, ys, p0, p1, p2 ) );
case VIPS_MASK_GAUSS_RINGREJECT:
return( gaussian_rrf( out, xs, ys, p0, p1, p2 ) );
case VIPS_MASK_FRACTAL_FLT:
return( fractal_flt( out, xs, ys, p0 ) );
default:
im_error( "create_quarter", "%s",
_( "unimplemented mask" ) );
return( NULL );
}
/*NOTREACHED*/
}

View File

@ -1,661 +0,0 @@
/* @(#) Typical filter function
* @(#) va_list is flag, filter parameters
* @(#)
* @(#) The following masks are implemented in this file
* @(#) flag, filter shape, parameters
* @(#) band pass ring reject filters
* @(#) 12 -\> idealbpf, parameters: frequency cutoff, width
* @(#) 13 -\> idealbrf, parameters: frequency cutoff, width
* @(#) 14 -\> butbpf, parameters: order, freq cutoff, width, ampl cutoff
* @(#) 15 -\> butbrf, parameters: order, freq cutoff, width, ampl cutoff
* @(#) 16 -\> gaussianbpf, parameters: frequency cutoff, width, ampl cutoff
* @(#) 17 -\> gaussianbrf, parameters: frequency cutoff, width, ampl cutoff
* @(#)
* @(#) The whole mask is created at once and written into the image file
* @(#)
* @(#) The following functions are contained within this file:
* @(#) Details are preceding the source code of each function
* @(#)
* @(#) int im__fmaskcir( out, flag, ap)
* @(#) IMAGE *out;
* @(#) enum mask_type flag;
* @(#) va_list ap;
* @(#)
*
* Copyright: N. Dessipris, 1991
* Written on: Nov 1991
* Updated on: Dec 1991
* 20/9/95 JC
* - modernised
*/
/*
This file is part of VIPS.
VIPS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
/*
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
#include <vips/intl.h>
#include <stdio.h>
#include <math.h>
#include <stdarg.h>
#include <vips/vips.h>
/************************************************************************
* malloc space and create normalised coefficients accross
* the x (horizontal) and y (vertical) direction.
* xs, ys are the image sizes
* xd and yd are the scrambled distributions of x and y in the rotated
* Fourier transform
* xplusd is the non scrambled distribution of (x+x0)*(x+x0) centred at 0
* xminus is the non scrambled distribution of (x-x0)*(x-x0) centred at 0
* similar for yplusd and yminusd
************************************************************************/
static int
alloc( IMAGE *out,
int xs, int ys,
int **xd, int **yd,
int **xplusd, int **xminusd, int **yplusd, int **yminusd,
int x0, int y0,
float **line )
{
int i;
int *x, *y, *xp, *xm, *yp, *ym;
int *pp, *pm;
float *l;
x = IM_ARRAY( out, xs, int );
y = IM_ARRAY( out, ys, int );
xp = IM_ARRAY( out, xs, int );
xm = IM_ARRAY( out, xs, int );
yp = IM_ARRAY( out, ys, int );
ym = IM_ARRAY( out, ys, int );
l = IM_ARRAY( out, xs, float );
if( !x || !y || !xp || !xm || !yp || !ym || !l )
return( -1 );
/* if ys = 8 then y = {0,1,2,3,-4,-3,-2,-1}.
*/
for( i = 0; i < ys/2; i++ ) {
y[i] = i;
y[i+ys/2] = -ys/2 + i;
}
for( i = 0; i < xs/2; i++ ) {
x[i] = i;
x[i+xs/2] = -xs/2 + i;
}
*xd = x;
*yd = y;
pp = yp + ys/2;
pm = ym + ys/2;
for( i = -ys/2; i < ys/2; i++ ) {
pp[i] = (i + y0)*(i + y0);
pm[i] = (i - y0)*(i - y0);
}
*yplusd = yp + ys/2;
*yminusd = ym + ys/2;
pp = xp + xs/2;
pm = xm + xs/2;
for( i = -xs/2; i < xs/2; i++ ) {
pp[i] = (i+x0)*(i+x0);
pm[i] = (i-x0)*(i-x0);
}
*xplusd = xp + xs/2;
*xminusd = xm + xs/2;
*line = l;
return( 0 );
}
/************************************************************************/
/* FLAG = 12 */
/* Creates an ideal band pass filter mask */
/* The band is two CIRCLEs of radius r centred */
/* at (fcx, fcy) and (-fcx, -fcy) */
/************************************************************************/
static int
ideal_bpf( IMAGE *out, double fcx, double fcy, double r )
{
int x, y;
int xs = out->Xsize;
int ys = out->Ysize;
float *line, *cpline;
int *xd, *yd, *xplusx0d, *xminusx0d, *yplusy0d, *yminusy0d;
int x0, y0, d1_2, d2_2, r2;
int y2plus, y2minus;
if( xs != ys ) {
im_error( "ideal_bpf", "%s", _( "bad sizes" ) );
return( -1 );
}
if( fabs(fcx) <= 1.0 && fabs(fcy) < 1.0 && r > 0.0 && r < 1.0 ) {
x0 = fcx*xs / 2.0;
y0 = fcy*ys / 2.0;
r2 = r*r*xs / 4.0;
}
else if( fabs(fcx) < xs/2 && fabs(fcy) < ys/2 && r >= 1.0 ) {
x0 = fcx;
y0 = fcy;
r2 = r*r;
}
else {
im_error( "ideal_bpf", "%s", _( "bad args" ) );
return( -1 );
}
if( alloc( out, xs, ys,
&xd, &yd, &xplusx0d, &xminusx0d,
&yplusy0d, &yminusy0d, x0, y0, &line ) )
return( -1 );
for( y = 0; y < ys; y++ ) {
cpline = line;
y2plus = yplusy0d[yd[y]];
y2minus = yminusy0d[yd[y]];
for( x = 0; x < xs; x++ ) {
d1_2 = xminusx0d[xd[x]] + y2minus;
d2_2 = xplusx0d[xd[x]] + y2plus;
if( d1_2 <= r2 )
*cpline = 1.0;
else if( d2_2 <= r2 )
*cpline = 1.0;
else
*cpline = 0.0;
if( x == 0 && y == 0 )
*cpline = 1.0; /* allow the dc component */
cpline++;
}
if( im_writeline( y, out, (VipsPel *) line ) )
return( -1 );
}
return( 0 );
}
/************************************************************************/
/* FLAG = 13 */
/* Creates an ideal band reject filter mask */
/* The band is a CIRCLE of internal radius fc-df and external radius fc+df*/
/************************************************************************/
static int
ideal_brf( IMAGE *out, double fcx, double fcy, double r )
{
int x, y;
int xs = out->Xsize;
int ys = out->Ysize;
float *line, *cpline;
int *xd, *yd, *xplusx0d, *xminusx0d, *yplusy0d, *yminusy0d;
int x0, y0, d1_2, d2_2, r2;
int y2plus, y2minus;
if( xs != ys ) {
im_error( "ideal_brf", "%s", _( "bad args" ) );
return( -1 );
}
if( fabs(fcx) <= 1.0 && fabs(fcy) <= 1.0 && r > 0.0 && r < 1.0 ) {
x0 = fcx*xs / 2.0;
y0 = fcy*ys / 2.0;
r2 = r*r*xs / 4.0;
}
else if( fabs(fcx) < xs/2 && fabs(fcy) < ys/2 && r >= 1.0 ) {
x0 = fcx;
y0 = fcy;
r2 = r*r;
}
else {
im_error( "ideal_brf", "%s", _( "bad args" ) );
return( -1 );
}
if( alloc( out, xs, ys,
&xd, &yd, &xplusx0d, &xminusx0d,
&yplusy0d, &yminusy0d, x0, y0, &line ) )
return( -1 );
for( y = 0; y < ys; y++ ) {
cpline = line;
y2plus = yplusy0d[yd[y]];
y2minus = yminusy0d[yd[y]];
for( x = 0; x < xs; x++ ) {
d1_2 = xminusx0d[xd[x]] + y2minus;
d2_2 = xplusx0d[xd[x]] + y2plus;
if( d1_2 <= r2 )
*cpline = 0.0;
else if( d2_2 <= r2 )
*cpline = 0.0;
else
*cpline = 1.0;
if( x == 0 && y == 0 )
*cpline = 1.0;
cpline++;
}
if( im_writeline( y, out, (VipsPel *) line ) )
return( -1 );
}
return( 0 );
}
/************************************************************************/
/* FLAG = 14 */
/* Creates a butterworth band pass filter mask */
/* The band is two CIRCLES centred at (fcx, fcy) and (-fcx, -fcy) */
/* The program assummes that the peaks of the 2d mask are at the */
/* centres above and are set to 1.0. The amplitude of both circle mask */
/* are added and the cuttof frequency is calculated on the plane */
/* which passes though the centre of the circles and the 0 point */
/************************************************************************/
static int
butterworth_bpf( IMAGE *out,
double order, double fcx, double fcy, double r, double ac )
{
int x, y;
int xs = out->Xsize;
int ys = out->Ysize;
float *line, *cpline;
int *xd, *yd, *xplusx0d, *xminusx0d, *yplusy0d, *yminusy0d;
int x0, y0;
double cnst, cnsta, d1_2, d2_2, nr2; /* nr2 is new r squared */
int y2plus, y2minus;
if( xs != ys || order < 1.0 ) {
im_error( "butterworth_bpf", "%s", _( "bad sizes" ) );
return( -1 );
}
if( fabs(fcx) <= 1.0 && fabs(fcy) <= 1.0 && r > 0.0 && r < 1.0 ) {
x0 = fcx*xs / 2.0;
y0 = fcy*ys / 2.0;
nr2 = r*r*xs*xs / 4.0;
}
else if( fabs(fcx) < xs/2 && fabs(fcy) < ys/2 && r >= 1.0 ) {
x0 = fcx;
y0 = fcy;
nr2 = r*r;
}
else {
im_error( "butterworth_bpf", "%s", _( "bad args" ) );
return( -1 );
}
if( ac >= 1.0 || ac < 0.0) {
im_error( "butterworth_bpf", "%s", _( "bad args" ) );
return( -1 );
}
if( alloc( out, xs, ys,
&xd, &yd, &xplusx0d, &xminusx0d,
&yplusy0d, &yminusy0d, x0, y0, &line ) )
return( -1 );
/* Filter shape: radius d0, centres at (x0, y0), (-x0,-y0)
* H(d) = H1(d) + H2(d)
* H(d) = cnst1/(1 + cnst2 * pow((d-d0)/d0, 2*order)) +
* cnst1/(1 + cnst2 * pow((d+d0)/d0, 2*order));
* for d=+d0 H(+d0) = 1.0; for d=-d0 H(-d0) = 1.0;
* for d=+da H(+da) = ampl_cutof; for d=-da H1(-da) = ampl_cutof;
* da = (xa, ya)
* xa = x0*(1 - radius/sqrt(x0*x0+y0*y0))
* ya = y0*(1 - radius/sqrt(x0*x0+y0*y0))
*/
cnst = (1.0/ac) - 1.0;
/* normalise the amplitude at (x0,y0) to 1.0
*/
cnsta = 1.0 / (1.0 + 1.0 /
(1.0 + cnst*pow( 4.0*(x0*x0 + y0*y0)/nr2, order )));
for( y = 0; y < ys; y++ ) {
cpline = line;
y2plus = yplusy0d[yd[y]];
y2minus = yminusy0d[yd[y]];
for( x = 0; x < xs; x++ ) {
d1_2 = xminusx0d[xd[x]] + y2minus;
d2_2 = xplusx0d[xd[x]] + y2plus;
*cpline = cnsta * (
1.0 / (1.0 + cnst * pow( d1_2/nr2, order )) +
1.0 / (1.0 + cnst * pow( d2_2/nr2, order )) );
if( x == 0 && y == 0 )
*cpline = 1.0;
cpline++;
}
if( im_writeline( y, out, (VipsPel *) line ) )
return( -1 );
}
return( 0 );
}
/************************************************************************/
/* FLAG = 15 */
/* Creates a butterworth band pass filter mask */
/* The band is a the 1-H(f) of above */
/************************************************************************/
static int
butterworth_brf( IMAGE *out,
double order, double fcx, double fcy, double r, double ac )
{
int x, y;
int xs = out->Xsize;
int ys = out->Ysize;
float *line, *cpline;
int *xd, *yd, *xplusx0d, *xminusx0d, *yplusy0d, *yminusy0d;
int x0, y0;
double cnst, cnsta, d1_2, d2_2, nr2; /* nr2 is new r squared */
int y2plus, y2minus;
if( xs != ys || order < 1.0 ) {
im_error( "butterworth_brf", "%s", _( "bad sizes" ) );
return( -1 );
}
if( fabs(fcx) <= 1.0 && fabs(fcy) <= 1.0 && r > 0.0 && r < 1.0 ) {
x0 = fcx * xs / 2.0;
y0 = fcy * ys / 2.0;
nr2 = r*r*xs*xs / 4.0;
}
else if( fabs(fcx) < xs/2 && fabs(fcy) < ys/2 && r >= 1.0 ) {
x0 = fcx;
y0 = fcy;
nr2 = r*r;
}
else {
im_error( "butterworth_brf", "%s", _( "bad args" ) );
return( -1 );
}
if( ac >= 1.0 || ac < 0.0) {
im_error( "butterworth_brf", "%s", _( "bad args" ) );
return( -1 );
}
if( alloc( out, xs, ys,
&xd, &yd, &xplusx0d, &xminusx0d,
&yplusy0d, &yminusy0d, x0, y0, &line ) )
return( -1 );
cnst = (1.0/ac) - 1.0;
/* normalise the amplitude at (x0,y0) to 1.0
*/
cnsta = 1.0 / (1.0 + 1.0 / (1.0 +
cnst * pow( 4.0*(x0*x0 + y0*y0)/nr2, order )));
for( y = 0; y < ys; y++ ) {
cpline = line;
y2plus = yplusy0d[yd[y]];
y2minus = yminusy0d[yd[y]];
for( x = 0; x < xs; x++ ) {
d1_2 = xminusx0d[xd[x]] + y2minus;
d2_2 = xplusx0d[xd[x]] + y2plus;
if( d1_2 == 0.0 || d2_2 == 0.0 )
*cpline = 0;
else
*cpline = 1.0 - cnsta *
( 1.0/(1.0 + cnst*pow( d1_2/nr2, order )) +
1.0/(1.0 + cnst*pow( d2_2/nr2, order )) );
if( x == 0 && y == 0 )
*cpline = 1.0;
cpline++;
}
if( im_writeline( y, out, (VipsPel *) line ) )
return( -1 );
}
return( 0 );
}
/************************************************************************/
/* FLAG = 16 */
/* Creates a gaussian band pass filter mask */
/* The band is a RING of internal radius fc-df and external radius fc+df*/
/************************************************************************/
static int
gaussian_bpf( IMAGE *out, double fcx, double fcy, double r, double ac )
{
int x, y;
int xs = out->Xsize;
int ys = out->Ysize;
float *line, *cpline;
int *xd, *yd, *xplusx0d, *xminusx0d, *yplusy0d, *yminusy0d;
int x0, y0;
double cnst, cnsta, d1_2, d2_2, nr2; /* nr2 is new r squared */
int y2plus, y2minus;
if( xs != ys ) {
im_error( "gauss_bpf", "%s", _( "bad sizes" ) );
return( -1 );
}
if( fabs(fcx) <= 1.0 && fabs(fcy) <= 1.0 && r > 0.0 && r < 1.0 ) {
x0 = fcx*xs / 2.0;
y0 = fcy*ys / 2.0;
nr2 = r*r*xs*xs / 4.0;
}
else if( fabs(fcx) < xs/2 && fabs(fcy) < ys/2 && r >= 1.0 ) {
x0 = fcx;
y0 = fcy;
nr2 = r*r;
}
else {
im_error( "gauss_bpf", "%s", _( "bad args (f)" ) );
return( -1 );
}
if( ac >= 1.0 || ac < 0.0 ) {
im_error( "gauss_bpf", "%s", _( "bad args (ac)" ) );
return( -1 );
}
if( alloc( out, xs, ys,
&xd, &yd, &xplusx0d, &xminusx0d,
&yplusy0d, &yminusy0d, x0, y0, &line ) )
return( -1 );
cnst = -log( ac );
/* normalise the amplitude at (x0,y0) to 1.0
*/
cnsta = 1.0/(1.0 + exp( - cnst * 4.0 * (x0*x0+y0*y0) / nr2 ));
for( y = 0; y < ys; y++ ) {
cpline = line;
y2plus = yplusy0d[yd[y]];
y2minus = yminusy0d[yd[y]];
for( x = 0; x < xs; x++ ) {
d1_2 = xminusx0d[xd[x]] + y2minus;
d2_2 = xplusx0d[xd[x]] + y2plus;
*cpline = cnsta *
(exp( -cnst * d1_2/nr2 ) +
exp( -cnst * d2_2/nr2 ));
if( x == 0 && y == 0 )
*cpline = 1.0;
cpline++;
}
if( im_writeline( y, out, (VipsPel *) line ) )
return( -1 );
}
return( 0 );
}
/************************************************************************/
/* FLAG = 17 */
/* Creates a gaussian band reject filter mask */
/* The band is a RING of internal radius fc-df and external radius fc+df*/
/************************************************************************/
static int
gaussian_brf( IMAGE *out, double fcx, double fcy, double r, double ac )
{
int x, y;
int xs = out->Xsize;
int ys = out->Ysize;
float *line, *cpline;
int *xd, *yd, *xplusx0d, *xminusx0d, *yplusy0d, *yminusy0d;
int x0, y0;
double cnst, cnsta, d1_2, d2_2, nr2; /* nr2 is new r squared */
int y2plus, y2minus;
if( xs != ys ) {
im_error( "gauss_brf", "%s", _( "bad sizes" ) );
return( -1 );
}
if( fabs(fcx) <= 1.0 && fabs(fcy) <= 1.0 && r > 0.0 && r < 1.0 ) {
x0 = fcx*xs / 2.0;
y0 = fcy*ys / 2.0;
nr2 = r*r*xs*xs / 4.0;
}
else if( fabs(fcx) < xs/2 && fabs(fcy) < ys/2 && r >= 1.0 ) {
x0 = fcx;
y0 = fcy;
nr2 = r * r;
}
else {
im_error( "gauss_brf", "%s", _( "bad args" ) );
return( -1 );
}
if( ac >= 1.0 || ac < 0.0 ) {
im_error( "gauss_brf", "%s", _( "bad args" ) );
return( -1 );
}
if( alloc( out, xs, ys,
&xd, &yd, &xplusx0d, &xminusx0d,
&yplusy0d, &yminusy0d, x0, y0, &line ) )
return( -1 );
cnst = -log( ac );
/* normalise the amplitude at (x0,y0) to 1.0
*/
cnsta = 1.0/(1.0 + exp( - cnst * 4.0 * (x0*x0+y0*y0) / nr2 ));
for( y = 0; y < ys; y++ ) {
cpline = line;
y2plus = yplusy0d[yd[y]];
y2minus = yminusy0d[yd[y]];
for( x = 0; x < xs; x++ ) {
d1_2 = xminusx0d[xd[x]] + y2minus;
d2_2 = xplusx0d[xd[x]] + y2plus;
*cpline = 1.0 - cnsta *
(exp( -cnst * d1_2/nr2 ) +
exp( -cnst * d2_2/nr2 ));
if( x == 0 && y == 0 )
*cpline = 1.0;
cpline++;
}
if( im_writeline( y, out, (VipsPel *) line ) )
return( -1 );
}
return( 0 );
}
/* Creates bandpass filter masks
* All arithmetic internally has been carried out in double precision;
* however all masks are written as floats with maximum value normalised to 1.0
*/
int
im__fmaskcir( IMAGE *out, VipsMaskType flag, va_list ap )
{
/* May be fewer than 5 args ... but extract them all anyway. Should be
* safe.
*/
double p0 = va_arg( ap, double );
double p1 = va_arg( ap, double );
double p2 = va_arg( ap, double );
double p3 = va_arg( ap, double );
double p4 = va_arg( ap, double );
switch( flag ) {
/* Band pass - band reject.
*/
case VIPS_MASK_IDEAL_BANDPASS:
return( ideal_bpf( out, p0, p1, p2 ) );
case VIPS_MASK_IDEAL_BANDREJECT:
return( ideal_brf( out, p0, p1, p2 ) );
case VIPS_MASK_BUTTERWORTH_BANDPASS:
return( butterworth_bpf( out, p0, p1, p2, p3, p4 ) );
case VIPS_MASK_BUTTERWORTH_BANDREJECT:
return( butterworth_brf( out, p0, p1, p2, p3, p4 ) );
case VIPS_MASK_GAUSS_BANDPASS:
return( gaussian_bpf( out, p0, p1, p2, p3 ) );
case VIPS_MASK_GAUSS_BANDREJECT:
return( gaussian_brf( out, p0, p1, p2, p3 ) );
default:
im_error( "im__fmaskcir", "%s",
_( "unimplemented mask" ) );
return( -1 );
}
/*NOTREACHED*/
}

View File

@ -76,7 +76,7 @@ im_fractsurf( IMAGE *out, int size, double frd )
if( !(noise = im_open_local( out, "im_fractsurf", "p" )) ||
im_gaussnoise( noise, size, size, 0.0, 1.0 ) ||
im_flt_image_freq( noise, out, VIPS_MASK_FRACTAL_FLT, frd ) )
im_flt_image_freq( noise, out, IM_MASK_FRACTAL_FLT, frd ) )
return( -1 );
return( 0 );

View File

@ -48,107 +48,143 @@
#include <vips/vips.h>
#include <vips/internal.h>
/* Create the final mask by copying the 1/4 of the mask held by coeff
* The final mask is written onto image on a line by line basis
* The buffer coeff should hold (xsize/2+1)*(ysize/2+1) elms
* The created mask is not rotated; so the center is at (0, 0)
*/
static int
copy_quarter( IMAGE *out, float *coeff_s )
{
float *line, *cpline;
float *coeff, *cpcoeff;
int x, y;
int hxsplus1;
if( !(line = IM_ARRAY( out, out->Xsize, float )) )
return( -1 );
hxsplus1 = out->Xsize/2 + 1;
coeff = coeff_s;
for( y = 0; y < out->Ysize/2; y++ ) {
cpline = line;
cpcoeff = coeff; coeff += hxsplus1;
for( x = 0; x < out->Xsize/2; x++ )
*cpline++ = *cpcoeff++;
for( x = out->Xsize/2; x < out->Xsize; x++ )
*cpline++ = *cpcoeff--;
if( im_writeline( y, out, (VipsPel *) line ) )
return( -1 );
}
for( y = out->Ysize/2; y < out->Ysize; y++ ) {
cpline = line;
cpcoeff = coeff; coeff -= hxsplus1;
for( x = 0; x < out->Xsize/2; x++ )
*cpline++ = *cpcoeff++;
for( x = out->Xsize/2; x < out->Xsize; x++ )
*cpline++ = *cpcoeff--;
if( im_writeline( y, out, (VipsPel *) line ) )
return( -1 );
}
return( 0 );
}
/* Make a mask image.
*/
static int
build_freq_mask( IMAGE *out, int xs, int ys, VipsMaskType flag, va_list ap )
build_freq_mask( IMAGE *out, int xs, int ys, ImMaskType flag, va_list ap )
{
float *coeff;
extern float *im__create_quarter( IMAGE *,
int, int, VipsMaskType, va_list );
/* Check sizes and create one quarter of the final mask
/* May be fewer than 4 args ... but extract them all anyway. Should be
* safe.
*/
if( !im_ispoweroftwo( xs ) || !im_ispoweroftwo( ys ) ) {
im_error( "im_freq_mask", "%s",
_( "mask sizes power of 2 only" ) );
return( -1 );
}
double p0 = va_arg( ap, double );
double p1 = va_arg( ap, double );
double p2 = va_arg( ap, double );
double p3 = va_arg( ap, double );
double p4 = va_arg( ap, double );
/* Create the output image.
*/
im_initdesc( out, xs, ys, 1, IM_BBITS_FLOAT, IM_BANDFMT_FLOAT,
IM_CODING_NONE, IM_TYPE_B_W, 1.0, 1.0, 0, 0 );
if( im_setupout( out ) )
return( -1 );
VipsImage *t;
switch( flag ) {
case VIPS_MASK_IDEAL_HIGHPASS:
case VIPS_MASK_IDEAL_LOWPASS:
case VIPS_MASK_BUTTERWORTH_HIGHPASS:
case VIPS_MASK_BUTTERWORTH_LOWPASS:
case VIPS_MASK_GAUSS_HIGHPASS:
case VIPS_MASK_GAUSS_LOWPASS:
case VIPS_MASK_IDEAL_RINGPASS:
case VIPS_MASK_IDEAL_RINGREJECT:
case VIPS_MASK_BUTTERWORTH_RINGPASS:
case VIPS_MASK_BUTTERWORTH_RINGREJECT:
case VIPS_MASK_GAUSS_RINGPASS:
case VIPS_MASK_GAUSS_RINGREJECT:
case VIPS_MASK_FRACTAL_FLT:
/* All these are created as a quarter and duplicated.
*/
if( !(coeff = im__create_quarter( out, xs, ys, flag, ap )) ||
copy_quarter( out, coeff ) )
case IM_MASK_IDEAL_HIGHPASS:
if( vips_mask_ideal( &t, xs, ys, p0,
"reject", TRUE,
NULL ) )
return( -1 );
break;
case VIPS_MASK_IDEAL_BANDPASS:
case VIPS_MASK_IDEAL_BANDREJECT:
case VIPS_MASK_BUTTERWORTH_BANDPASS:
case VIPS_MASK_BUTTERWORTH_BANDREJECT:
case VIPS_MASK_GAUSS_BANDPASS:
case VIPS_MASK_GAUSS_BANDREJECT:
/* Created all in one go.
*/
if( im__fmaskcir( out, flag, ap ) )
case IM_MASK_IDEAL_LOWPASS:
if( vips_mask_ideal( &t, xs, ys, p0,
NULL ) )
return( -1 );
break;
case IM_MASK_BUTTERWORTH_HIGHPASS:
if( vips_mask_butterworth( &t, xs, ys, p0, p1, p2,
"reject", TRUE,
NULL ) )
return( -1 );
break;
case IM_MASK_BUTTERWORTH_LOWPASS:
if( vips_mask_butterworth( &t, xs, ys, p0, p1, p2,
NULL ) )
return( -1 );
break;
case IM_MASK_GAUSS_HIGHPASS:
if( vips_mask_gaussian( &t, xs, ys, p0, p1,
"reject", TRUE,
NULL ) )
return( -1 );
break;
case IM_MASK_GAUSS_LOWPASS:
if( vips_mask_gaussian( &t, xs, ys, p0, p1,
NULL ) )
return( -1 );
break;
case IM_MASK_IDEAL_RINGPASS:
if( vips_mask_ideal_ring( &t, xs, ys, p0, p1,
NULL ) )
return( -1 );
break;
case IM_MASK_IDEAL_RINGREJECT:
if( vips_mask_ideal_ring( &t, xs, ys, p0, p1,
"reject", TRUE,
NULL ) )
return( -1 );
break;
case IM_MASK_BUTTERWORTH_RINGPASS:
if( vips_mask_butterworth_ring( &t, xs, ys, p0, p1, p2, p3,
NULL ) )
return( -1 );
break;
case IM_MASK_BUTTERWORTH_RINGREJECT:
if( vips_mask_butterworth_ring( &t, xs, ys, p0, p1, p2, p3,
"reject", TRUE,
NULL ) )
return( -1 );
break;
case IM_MASK_GAUSS_RINGPASS:
if( vips_mask_gaussian_ring( &t, xs, ys, p0, p1, p2,
NULL ) )
return( -1 );
break;
case IM_MASK_GAUSS_RINGREJECT:
if( vips_mask_gaussian_ring( &t, xs, ys, p0, p1, p2,
"reject", TRUE,
NULL ) )
return( -1 );
break;
case IM_MASK_FRACTAL_FLT:
if( vips_mask_fractal( &t, xs, ys, p0,
NULL ) )
return( -1 );
break;
case IM_MASK_IDEAL_BANDPASS:
if( vips_mask_ideal_band( &t, xs, ys, p0, p1, p2,
NULL ) )
return( -1 );
break;
case IM_MASK_IDEAL_BANDREJECT:
if( vips_mask_ideal_band( &t, xs, ys, p0, p1, p2,
"reject", TRUE,
NULL ) )
return( -1 );
break;
case IM_MASK_BUTTERWORTH_BANDPASS:
if( vips_mask_butterworth_band( &t, xs, ys, p0, p1, p2, p3, p4,
NULL ) )
return( -1 );
break;
case IM_MASK_BUTTERWORTH_BANDREJECT:
if( vips_mask_butterworth_band( &t, xs, ys, p0, p1, p2, p3, p4,
"reject", TRUE,
NULL ) )
return( -1 );
break;
case IM_MASK_GAUSS_BANDPASS:
if( vips_mask_gaussian_band( &t, xs, ys, p0, p1, p2, p3,
NULL ) )
return( -1 );
break;
case IM_MASK_GAUSS_BANDREJECT:
if( vips_mask_gaussian_band( &t, xs, ys, p0, p1, p2, p3,
"reject", TRUE,
NULL ) )
return( -1 );
break;
@ -157,6 +193,12 @@ build_freq_mask( IMAGE *out, int xs, int ys, VipsMaskType flag, va_list ap )
return( -1 );
}
if( im_copy( t, out ) ) {
g_object_unref( t );
return( -1 );
}
g_object_unref( t );
return( 0 );
}
@ -175,7 +217,7 @@ build_freq_mask( IMAGE *out, int xs, int ys, VipsMaskType flag, va_list ap )
* Returns: 0 on success, -1 on error
*/
int
im_flt_image_freq( IMAGE *in, IMAGE *out, VipsMaskType flag, ... )
im_flt_image_freq( IMAGE *in, IMAGE *out, ImMaskType flag, ... )
{
IMAGE *mask = im_open_local( out, "tempmask", "p" );
va_list ap;
@ -196,179 +238,8 @@ im_flt_image_freq( IMAGE *in, IMAGE *out, VipsMaskType flag, ... )
return( 0 );
}
/**
* im_create_fmask:
* @out: image to write to
* @xsize: image size
* @ysize: image size
* @flag: mask type
* @Varargs: mask parameters
*
* This operation creates a one-band float image of the specified size. The
* image must be square, and the sides must be a power of two. The image has
* values in the range [0, 1] and is typically used for multiplying against
* frequency domain images to filter them.
*
* All masks are created with the DC component at (0, 0), so you might want to
* rotate the quadrants with im_rotquad() before viewing. The DC pixel always
* has the value 1.0.
*
* The value of @flag sets the type pf mask created, and extra parameters set
* the exact mask shape. All extra parameters are doubles. This table
* summarises the possible values:
*
* <table>
* <title>Parameters for im_create_fmask()</title>
* <tgroup cols='2' align='left' colsep='1' rowsep='1'>
* <thead>
* <row>
* <entry>#VipsMaskType</entry>
* <entry>nargs</entry>
* <entry>Parameters (all double)</entry>
* </row>
* </thead>
* <tbody>
* <row>
* <entry>#VIPS_MASK_IDEAL_HIGHPASS</entry>
* <entry>1</entry>
* <entry>frequency_cutoff</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_IDEAL_LOWPASS</entry>
* <entry>1</entry>
* <entry>frequency_cutoff</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_BUTTERWORTH_HIGHPASS</entry>
* <entry>3</entry>
* <entry>order, frequency_cutoff, amplitude_cutoff</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_BUTTERWORTH_LOWPASS</entry>
* <entry>3</entry>
* <entry>order, frequency_cutoff, amplitude_cutoff</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_GAUSS_HIGHPASS</entry>
* <entry>2</entry>
* <entry>frequency_cutoff, amplitude_cutoff</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_GAUSS_LOWPASS</entry>
* <entry>2</entry>
* <entry>frequency_cutoff, amplitude_cutoff</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_IDEAL_RINGPASS</entry>
* <entry>2</entry>
* <entry>frequency_cutoff, width</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_IDEAL_RINGREJECT</entry>
* <entry>2</entry>
* <entry>frequency_cutoff, width</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_BUTTERWORTH_RINGPASS</entry>
* <entry>4</entry>
* <entry>order, frequency_cutoff, width, amplitude_cutoff</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_BUTTERWORTH_RINGREJECT</entry>
* <entry>4</entry>
* <entry>order, frequency_cutoff, width, amplitude_cutoff</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_GAUSS_RINGPASS</entry>
* <entry>3</entry>
* <entry>frequency_cutoff, width, amplitude_cutoff</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_GAUSS_RINGREJECT</entry>
* <entry>3</entry>
* <entry>frequency_cutoff, width, amplitude_cutoff</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_IDEAL_BANDPASS</entry>
* <entry>3</entry>
* <entry>frequency_cutoffx, frequency_cutoffy, radius</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_IDEAL_BANDREJECT</entry>
* <entry>3</entry>
* <entry>frequency_cutoffx, frequency_cutoffy, radius</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_BUTTERWORTH_BANDPASS</entry>
* <entry>5</entry>
* <entry>order, frequency_cutoffx, frequency_cutoffy, radius,
* amplitude_cutoff</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_BUTTERWORTH_BANDREJECT</entry>
* <entry>5</entry>
* <entry>order, frequency_cutoffx, frequency_cutoffy, radius,
* amplitude_cutoff</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_GAUSS_BANDPASS</entry>
* <entry>4</entry>
* <entry>frequency_cutoffx, frequency_cutoffy, radius,
* amplitude_cutoff</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_GAUSS_BANDREJECT</entry>
* <entry>4</entry>
* <entry>frequency_cutoffx, frequency_cutoffy, radius,
* amplitude_cutoff</entry>
* </row>
* <row>
* <entry>#VIPS_MASK_FRACTAL_FLT</entry>
* <entry>1</entry>
* <entry>fractal_dimension</entry>
* </row>
* </tbody>
* </tgroup>
* </table>
*
* Unless noted below, all parameters are expressed as percentages, scaled to
* [0, 1].
*
* <emphasis>High-pass, low-pass masks:</emphasis> A high pass filter
* mask filters the low frequencies while allowing the high frequencies to
* get through. The reverse happens with a low pass filter mask.
*
* <emphasis>Ring-pass, ring-reject masks:</emphasis> A ring filter passes or
* rejects a range of frequencies. The range is specified by the
* @frequency_cutoff and the @width.
*
* <emphasis>Band-pass, band-reject masks:</emphasis> These masks are used to
* pass or remove spatial frequencies around a given frequency. The position
* of the frequency to pass or remove is given by @frequency_cutoffx and
* @frequency_cutoffy. The size of the region around the point is given by
* @radius.
*
* <emphasis>Ideal filters:</emphasis> These filters pass or reject
* frequencies with a sharp cutoff at the transition.
*
* <emphasis>Butterworth filters:</emphasis> These filters use a Butterworth
* function to separate the frequencies (see Gonzalez and Wintz, Digital
* Image Processing, 1987). The shape of the curve is controlled by @order:
* higher values give a sharper transition.
*
* <emphasis>Gaussian filters:</emphasis> These filters have a smooth Gaussian
* shape, controlled by @amplitude_cutoff.
*
* <emphasis>VIPS_MASK_FRACTAL_FLT:</emphasis> This mask is handy for
* filtering images of gaussian noise in order to create surfaces of a given
* fractal dimension. @fractal_dimension should be between 2 and 3.
*
* See also: im_flt_image_freq(), im_rotquad(),
*
* Returns: 0 on success, -1 on error
*/
int
im_create_fmask( IMAGE *out, int xsize, int ysize, VipsMaskType flag, ... )
int
im_create_fmask( IMAGE *out, int xsize, int ysize, ImMaskType flag, ... )
{
va_list ap;

View File

@ -77,30 +77,30 @@ int im_c2ps( IMAGE *in, IMAGE *out );
int im_clip( IMAGE *in, IMAGE *out );
#define MASK_IDEAL_HIGHPASS VIPS_MASK_IDEAL_HIGHPASS
#define MASK_IDEAL_LOWPASS VIPS_MASK_IDEAL_LOWPASS
#define MASK_BUTTERWORTH_HIGHPASS VIPS_MASK_BUTTERWORTH_HIGHPASS
#define MASK_BUTTERWORTH_LOWPASS VIPS_MASK_BUTTERWORTH_LOWPASS
#define MASK_GAUSS_HIGHPASS VIPS_MASK_GAUSS_HIGHPASS
#define MASK_GAUSS_LOWPASS VIPS_MASK_GAUSS_LOWPASS
#define MASK_IDEAL_HIGHPASS IM_MASK_IDEAL_HIGHPASS
#define MASK_IDEAL_LOWPASS IM_MASK_IDEAL_LOWPASS
#define MASK_BUTTERWORTH_HIGHPASS IM_MASK_BUTTERWORTH_HIGHPASS
#define MASK_BUTTERWORTH_LOWPASS IM_MASK_BUTTERWORTH_LOWPASS
#define MASK_GAUSS_HIGHPASS IM_MASK_GAUSS_HIGHPASS
#define MASK_GAUSS_LOWPASS IM_MASK_GAUSS_LOWPASS
#define MASK_IDEAL_RINGPASS VIPS_MASK_IDEAL_RINGPASS
#define MASK_IDEAL_RINGREJECT VIPS_MASK_IDEAL_RINGREJECT
#define MASK_BUTTERWORTH_RINGPASS VIPS_MASK_BUTTERWORTH_RINGPASS
#define MASK_BUTTERWORTH_RINGREJECT VIPS_MASK_BUTTERWORTH_RINGREJECT
#define MASK_GAUSS_RINGPASS VIPS_MASK_GAUSS_RINGPASS
#define MASK_GAUSS_RINGREJECT VIPS_MASK_GAUSS_RINGREJECT
#define MASK_IDEAL_RINGPASS IM_MASK_IDEAL_RINGPASS
#define MASK_IDEAL_RINGREJECT IM_MASK_IDEAL_RINGREJECT
#define MASK_BUTTERWORTH_RINGPASS IM_MASK_BUTTERWORTH_RINGPASS
#define MASK_BUTTERWORTH_RINGREJECT IM_MASK_BUTTERWORTH_RINGREJECT
#define MASK_GAUSS_RINGPASS IM_MASK_GAUSS_RINGPASS
#define MASK_GAUSS_RINGREJECT IM_MASK_GAUSS_RINGREJECT
#define MASK_IDEAL_BANDPASS VIPS_MASK_IDEAL_BANDPASS
#define MASK_IDEAL_BANDREJECT VIPS_MASK_IDEAL_BANDREJECT
#define MASK_BUTTERWORTH_BANDPASS VIPS_MASK_BUTTERWORTH_BANDPASS
#define MASK_BUTTERWORTH_BANDREJECT VIPS_MASK_BUTTERWORTH_BANDREJECT
#define MASK_GAUSS_BANDPASS VIPS_MASK_GAUSS_BANDPASS
#define MASK_GAUSS_BANDREJECT VIPS_MASK_GAUSS_BANDREJECT
#define MASK_IDEAL_BANDPASS IM_MASK_IDEAL_BANDPASS
#define MASK_IDEAL_BANDREJECT IM_MASK_IDEAL_BANDREJECT
#define MASK_BUTTERWORTH_BANDPASS IM_MASK_BUTTERWORTH_BANDPASS
#define MASK_BUTTERWORTH_BANDREJECT IM_MASK_BUTTERWORTH_BANDREJECT
#define MASK_GAUSS_BANDPASS IM_MASK_GAUSS_BANDPASS
#define MASK_GAUSS_BANDREJECT IM_MASK_GAUSS_BANDREJECT
#define MASK_FRACTAL_FLT VIPS_MASK_FRACTAL_FLT
#define MASK_FRACTAL_FLT IM_MASK_FRACTAL_FLT
#define MaskType VipsMaskType
#define MaskType ImMaskType
/* Copy and swap types.
*/

View File

@ -40,31 +40,6 @@ extern "C" {
#include <vips/vips.h>
typedef enum {
VIPS_MASK_IDEAL_HIGHPASS = 0,
VIPS_MASK_IDEAL_LOWPASS = 1,
VIPS_MASK_BUTTERWORTH_HIGHPASS = 2,
VIPS_MASK_BUTTERWORTH_LOWPASS = 3,
VIPS_MASK_GAUSS_HIGHPASS = 4,
VIPS_MASK_GAUSS_LOWPASS = 5,
VIPS_MASK_IDEAL_RINGPASS = 6,
VIPS_MASK_IDEAL_RINGREJECT = 7,
VIPS_MASK_BUTTERWORTH_RINGPASS = 8,
VIPS_MASK_BUTTERWORTH_RINGREJECT = 9,
VIPS_MASK_GAUSS_RINGPASS = 10,
VIPS_MASK_GAUSS_RINGREJECT = 11,
VIPS_MASK_IDEAL_BANDPASS = 12,
VIPS_MASK_IDEAL_BANDREJECT = 13,
VIPS_MASK_BUTTERWORTH_BANDPASS = 14,
VIPS_MASK_BUTTERWORTH_BANDREJECT = 15,
VIPS_MASK_GAUSS_BANDPASS = 16,
VIPS_MASK_GAUSS_BANDREJECT = 17,
VIPS_MASK_FRACTAL_FLT = 18
} VipsMaskType;
int im_fwfft( VipsImage *in, VipsImage *out );
int im_invfft( VipsImage *in, VipsImage *out );
int im_invfftr( VipsImage *in, VipsImage *out );
@ -73,9 +48,6 @@ int im_freqflt( VipsImage *in, VipsImage *mask, VipsImage *out );
int im_disp_ps( VipsImage *in, VipsImage *out );
int im_phasecor_fft( VipsImage *in1, VipsImage *in2, VipsImage *out );
int im_flt_image_freq( VipsImage *in, VipsImage *out, VipsMaskType flag, ... );
int im_create_fmask( VipsImage *out,
int xsize, int ysize, VipsMaskType flag, ... );
int im_fractsurf( VipsImage *out, int size, double frd );
#ifdef __cplusplus

View File

@ -261,8 +261,6 @@ int *im_offsets45( int size );
int im_conv_f_raw( VipsImage *in, VipsImage *out, DOUBLEMASK *mask );
int im_convsep_f_raw( VipsImage *in, VipsImage *out, DOUBLEMASK *mask );
int im__fmaskcir( VipsImage *out, VipsMaskType flag, va_list ap );
/* inplace
*/

View File

@ -937,6 +937,35 @@ int im_sharpen( VipsImage *in, VipsImage *out,
double x1, double y2, double y3,
double m1, double m2 );
typedef enum {
IM_MASK_IDEAL_HIGHPASS = 0,
IM_MASK_IDEAL_LOWPASS = 1,
IM_MASK_BUTTERWORTH_HIGHPASS = 2,
IM_MASK_BUTTERWORTH_LOWPASS = 3,
IM_MASK_GAUSS_HIGHPASS = 4,
IM_MASK_GAUSS_LOWPASS = 5,
IM_MASK_IDEAL_RINGPASS = 6,
IM_MASK_IDEAL_RINGREJECT = 7,
IM_MASK_BUTTERWORTH_RINGPASS = 8,
IM_MASK_BUTTERWORTH_RINGREJECT = 9,
IM_MASK_GAUSS_RINGPASS = 10,
IM_MASK_GAUSS_RINGREJECT = 11,
IM_MASK_IDEAL_BANDPASS = 12,
IM_MASK_IDEAL_BANDREJECT = 13,
IM_MASK_BUTTERWORTH_BANDPASS = 14,
IM_MASK_BUTTERWORTH_BANDREJECT = 15,
IM_MASK_GAUSS_BANDPASS = 16,
IM_MASK_GAUSS_BANDREJECT = 17,
IM_MASK_FRACTAL_FLT = 18
} ImMaskType;
int im_flt_image_freq( VipsImage *in, VipsImage *out, ImMaskType flag, ... );
int im_create_fmask( VipsImage *out,
int xsize, int ysize, ImMaskType flag, ... );
#ifdef __cplusplus
}
#endif /*__cplusplus*/