~ubuntu-branches/ubuntu/trusty/vips/trusty-proposed

« back to all changes in this revision

Viewing changes to libvips/deprecated/im_freq_mask.c

  • Committer: Package Import Robot
  • Author(s): Jay Berkenbilt
  • Date: 2014-03-29 12:29:29 UTC
  • mfrom: (1.1.21) (30.1.16 sid)
  • Revision ID: package-import@ubuntu.com-20140329122929-fvxnaann32ex0gzk
Tags: 7.38.5-2
Enable dh-autoreconf. (Closes: #742872)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Create masks and filter with them.
 
2
 *
 
3
 * Copyright: N. Dessipris 1991,
 
4
 * Written on: Nov 1991
 
5
 * Updated on: Dec 1991
 
6
 * 20/9/95 JC
 
7
 *      - modernised 
 
8
 * 22/3/10
 
9
 *      - gtkdoc
 
10
 */
 
11
 
 
12
/*
 
13
 
 
14
    This file is part of VIPS.
 
15
    
 
16
    VIPS is free software; you can redistribute it and/or modify
 
17
    it under the terms of the GNU Lesser General Public License as published by
 
18
    the Free Software Foundation; either version 2 of the License, or
 
19
    (at your option) any later version.
 
20
 
 
21
    This program is distributed in the hope that it will be useful,
 
22
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
23
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
24
    GNU Lesser General Public License for more details.
 
25
 
 
26
    You should have received a copy of the GNU Lesser General Public License
 
27
    along with this program; if not, write to the Free Software
 
28
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
29
    02110-1301  USA
 
30
 
 
31
 */
 
32
 
 
33
/*
 
34
 
 
35
    These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
 
36
 
 
37
 */
 
38
 
 
39
#ifdef HAVE_CONFIG_H
 
40
#include <config.h>
 
41
#endif /*HAVE_CONFIG_H*/
 
42
#include <vips/intl.h>
 
43
 
 
44
#include <stdio.h>
 
45
#include <math.h>
 
46
#include <stdarg.h>
 
47
 
 
48
#include <vips/vips.h>
 
49
#include <vips/internal.h>
 
50
 
 
51
/* Make a mask image.
 
52
 */
 
53
static int 
 
54
build_freq_mask( IMAGE *out, int xs, int ys, ImMaskType flag, va_list ap )
 
55
{
 
56
        /* May be fewer than 4 args ... but extract them all anyway. Should be
 
57
         * safe.
 
58
         */
 
59
        double p0 = va_arg( ap, double );
 
60
        double p1 = va_arg( ap, double );
 
61
        double p2 = va_arg( ap, double );
 
62
        double p3 = va_arg( ap, double );
 
63
        double p4 = va_arg( ap, double );
 
64
 
 
65
        VipsImage *t;
 
66
 
 
67
        switch( flag ) {
 
68
        case IM_MASK_IDEAL_HIGHPASS:
 
69
                if( vips_mask_ideal( &t, xs, ys, p0,
 
70
                        "reject", TRUE, 
 
71
                        NULL ) )
 
72
                        return( -1 );
 
73
                break;
 
74
 
 
75
        case IM_MASK_IDEAL_LOWPASS:
 
76
                if( vips_mask_ideal( &t, xs, ys, p0,
 
77
                        NULL ) )
 
78
                        return( -1 );
 
79
                break;
 
80
 
 
81
        case IM_MASK_BUTTERWORTH_HIGHPASS:
 
82
                if( vips_mask_butterworth( &t, xs, ys, p0, p1, p2,
 
83
                        "reject", TRUE, 
 
84
                        NULL ) )
 
85
                        return( -1 );
 
86
                break;
 
87
 
 
88
        case IM_MASK_BUTTERWORTH_LOWPASS:
 
89
                if( vips_mask_butterworth( &t, xs, ys, p0, p1, p2,
 
90
                        NULL ) )
 
91
                        return( -1 );
 
92
                break;
 
93
 
 
94
        case IM_MASK_GAUSS_HIGHPASS:
 
95
                if( vips_mask_gaussian( &t, xs, ys, p0, p1, 
 
96
                        "reject", TRUE, 
 
97
                        NULL ) )
 
98
                        return( -1 );
 
99
                break;
 
100
 
 
101
        case IM_MASK_GAUSS_LOWPASS:
 
102
                if( vips_mask_gaussian( &t, xs, ys, p0, p1, 
 
103
                        NULL ) )
 
104
                        return( -1 );
 
105
                break;
 
106
 
 
107
        case IM_MASK_IDEAL_RINGPASS:
 
108
                if( vips_mask_ideal_ring( &t, xs, ys, p0, p1, 
 
109
                        NULL ) )
 
110
                        return( -1 );
 
111
                break;
 
112
 
 
113
        case IM_MASK_IDEAL_RINGREJECT:
 
114
                if( vips_mask_ideal_ring( &t, xs, ys, p0, p1, 
 
115
                        "reject", TRUE, 
 
116
                        NULL ) )
 
117
                        return( -1 );
 
118
                break;
 
119
 
 
120
        case IM_MASK_BUTTERWORTH_RINGPASS:
 
121
                if( vips_mask_butterworth_ring( &t, xs, ys, p0, p1, p2, p3,
 
122
                        NULL ) )
 
123
                        return( -1 );
 
124
                break;
 
125
 
 
126
        case IM_MASK_BUTTERWORTH_RINGREJECT:
 
127
                if( vips_mask_butterworth_ring( &t, xs, ys, p0, p1, p2, p3,
 
128
                        "reject", TRUE, 
 
129
                        NULL ) )
 
130
                        return( -1 );
 
131
                break;
 
132
 
 
133
        case IM_MASK_GAUSS_RINGPASS:
 
134
                if( vips_mask_gaussian_ring( &t, xs, ys, p0, p1, p2, 
 
135
                        NULL ) )
 
136
                        return( -1 );
 
137
                break;
 
138
 
 
139
        case IM_MASK_GAUSS_RINGREJECT:
 
140
                if( vips_mask_gaussian_ring( &t, xs, ys, p0, p1, p2, 
 
141
                        "reject", TRUE, 
 
142
                        NULL ) )
 
143
                        return( -1 );
 
144
                break;
 
145
 
 
146
        case IM_MASK_FRACTAL_FLT:
 
147
                if( vips_mask_fractal( &t, xs, ys, p0, 
 
148
                        NULL ) )
 
149
                        return( -1 );
 
150
                break;
 
151
 
 
152
        case IM_MASK_IDEAL_BANDPASS:
 
153
                if( vips_mask_ideal_band( &t, xs, ys, p0, p1, p2, 
 
154
                        NULL ) )
 
155
                        return( -1 );
 
156
                break;
 
157
 
 
158
        case IM_MASK_IDEAL_BANDREJECT:
 
159
                if( vips_mask_ideal_band( &t, xs, ys, p0, p1, p2, 
 
160
                        "reject", TRUE, 
 
161
                        NULL ) )
 
162
                        return( -1 );
 
163
                break;
 
164
 
 
165
        case IM_MASK_BUTTERWORTH_BANDPASS:
 
166
                if( vips_mask_butterworth_band( &t, xs, ys, p0, p1, p2, p3, p4,
 
167
                        NULL ) )
 
168
                        return( -1 );
 
169
                break;
 
170
 
 
171
        case IM_MASK_BUTTERWORTH_BANDREJECT:
 
172
                if( vips_mask_butterworth_band( &t, xs, ys, p0, p1, p2, p3, p4,
 
173
                        "reject", TRUE, 
 
174
                        NULL ) )
 
175
                        return( -1 );
 
176
                break;
 
177
 
 
178
        case IM_MASK_GAUSS_BANDPASS:
 
179
                if( vips_mask_gaussian_band( &t, xs, ys, p0, p1, p2, p3, 
 
180
                        NULL ) )
 
181
                        return( -1 );
 
182
                break;
 
183
 
 
184
        case IM_MASK_GAUSS_BANDREJECT:
 
185
                if( vips_mask_gaussian_band( &t, xs, ys, p0, p1, p2, p3, 
 
186
                        "reject", TRUE, 
 
187
                        NULL ) )
 
188
                        return( -1 );
 
189
                break;
 
190
 
 
191
        default:
 
192
               im_error( "im_freq_mask", "%s", _( "unimplemented mask type" ) );
 
193
               return( -1 );
 
194
        }
 
195
 
 
196
        if( im_copy( t, out ) ) {
 
197
                g_object_unref( t );
 
198
                return( -1 );
 
199
        }
 
200
        g_object_unref( t );
 
201
 
 
202
        return( 0 );
 
203
}
 
204
 
 
205
int 
 
206
im_flt_image_freq( IMAGE *in, IMAGE *out, ImMaskType flag, ... )
 
207
{
 
208
        IMAGE *mask = im_open_local( out, "tempmask", "p" );
 
209
        va_list ap;
 
210
 
 
211
        if( !mask )
 
212
                return( -1 );
 
213
 
 
214
        /* Generate mask.
 
215
         */
 
216
        va_start( ap, flag );
 
217
        if( build_freq_mask( mask, in->Xsize, in->Ysize, flag, ap ) )
 
218
                return( -1 );
 
219
        va_end( ap );
 
220
 
 
221
        if( im_freqflt( in, mask, out ) )
 
222
                return( -1 );
 
223
 
 
224
        return( 0 );
 
225
}
 
226
 
 
227
int
 
228
im_create_fmask( IMAGE *out, int xsize, int ysize, ImMaskType flag, ... )
 
229
{
 
230
        va_list ap;
 
231
 
 
232
        va_start( ap, flag );
 
233
        if( build_freq_mask( out, xsize, ysize, flag, ap ) )
 
234
                return( -1 );
 
235
        va_end( ap );
 
236
 
 
237
        return( 0 );
 
238
}