1
/* creates an ideal filter.
9
This file is part of VIPS.
11
VIPS is free software; you can redistribute it and/or modify
12
it under the terms of the GNU Lesser General Public License as published by
13
the Free Software Foundation; either version 2 of the License, or
14
(at your option) any later version.
16
This program is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
GNU Lesser General Public License for more details.
21
You should have received a copy of the GNU Lesser General Public License
22
along with this program; if not, write to the Free Software
23
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
40
#endif /*HAVE_CONFIG_H*/
41
#include <vips/intl.h>
48
#include <vips/vips.h>
54
G_DEFINE_TYPE( VipsMaskIdeal, vips_mask_ideal, VIPS_TYPE_MASK );
57
vips_mask_ideal_point( VipsMask *mask, double dx, double dy )
59
VipsMaskIdeal *ideal = (VipsMaskIdeal *) mask;
60
double fc = ideal->frequency_cutoff;
62
double dist2 = dx * dx + dy * dy;
65
return( dist2 <= fc2 ? 1.0 : 0.0 );
69
vips_mask_ideal_class_init( VipsMaskIdealClass *class )
71
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
72
VipsObjectClass *vobject_class = VIPS_OBJECT_CLASS( class );
73
VipsMaskClass *mask_class = VIPS_MASK_CLASS( class );
75
gobject_class->set_property = vips_object_set_property;
76
gobject_class->get_property = vips_object_get_property;
78
vobject_class->nickname = "mask_ideal";
79
vobject_class->description = _( "make an ideal filter" );
81
mask_class->point = vips_mask_ideal_point;
83
VIPS_ARG_DOUBLE( class, "frequency_cutoff", 6,
84
_( "Frequency cutoff" ),
85
_( "Frequency cutoff" ),
86
VIPS_ARGUMENT_REQUIRED_INPUT,
87
G_STRUCT_OFFSET( VipsMaskIdeal, frequency_cutoff ),
88
0.0, 1000000.0, 0.5 );
93
vips_mask_ideal_init( VipsMaskIdeal *ideal )
95
ideal->frequency_cutoff = 0.5;
102
* @height: image size
104
* @...: %NULL-terminated list of optional named arguments
106
* Optional arguments:
108
* @nodc: don't set the DC pixel
109
* @reject: invert the filter sense
110
* @optical: coordinates in optical space
111
* @uchar: output a uchar image
113
* Make an ideal high- or low-pass filter, that is, one with a sharp cutoff
114
* positioned at @frequency_cutoff, where @frequency_cutoff is in
117
* This operation creates a one-band float image of the specified size.
119
* values in the range [0, 1] and is typically used for multiplying against
120
* frequency domain images to filter them.
121
* Masks are created with the DC component at (0, 0). The DC pixel always
124
* Set @nodc to not set the DC pixel.
126
* Set @optical to position the DC component in the centre of the image. This
127
* makes the mask suitable for multiplying against optical Fourier transforms.
130
* Set @reject to invert the sense of
131
* the filter. For example, low-pass becomes low-reject.
133
* Set @uchar to output an 8-bit unsigned char image rather than a
134
* float image. In this case, pixels are in the range [0 - 255].
136
* See also: vips_mask_ideal(), vips_mask_ideal_ring(),
137
* vips_mask_ideal_band(), vips_mask_butterworth(),
138
* vips_mask_butterworth_ring(), vips_mask_butterworth_band(),
139
* vips_mask_gaussian(), vips_mask_gaussian_ring(),
140
* vips_mask_gaussian_band().
142
* Returns: 0 on success, -1 on error
145
vips_mask_ideal( VipsImage **out, int width, int height,
146
double frequency_cutoff, ... )
151
va_start( ap, frequency_cutoff );
152
result = vips_call_split( "mask_ideal", ap, out, width, height,