1
/* make a displayable power spectrum for an image
3
* Author: Nicos Dessipris
4
* Written on: 27/03/1991
7
* - im_ioflag() changed to im_iocheck()
9
* - rewritten for partials
11
* - frees memory more quickly
13
* - any number of bands
23
This file is part of VIPS.
25
VIPS is free software; you can redistribute it and/or modify
26
it under the terms of the GNU Lesser General Public License as published by
27
the Free Software Foundation; either version 2 of the License, or
28
(at your option) any later version.
30
This program is distributed in the hope that it will be useful,
31
but WITHOUT ANY WARRANTY; without even the implied warranty of
32
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33
GNU Lesser General Public License for more details.
35
You should have received a copy of the GNU Lesser General Public License
36
along with this program; if not, write to the Free Software
37
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
44
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
50
#endif /*HAVE_CONFIG_H*/
51
#include <vips/intl.h>
56
#include <vips/vips.h>
57
#include "pfreqfilt.h"
59
typedef VipsFreqfilt VipsSpectrum;
60
typedef VipsFreqfiltClass VipsSpectrumClass;
62
G_DEFINE_TYPE( VipsSpectrum, vips_spectrum, VIPS_TYPE_FREQFILT );
65
vips_spectrum_build( VipsObject *object )
67
VipsFreqfilt *freqfilt = VIPS_FREQFILT( object );
68
VipsImage **t = (VipsImage **) vips_object_local_array( object, 5 );
72
if( VIPS_OBJECT_CLASS( vips_spectrum_parent_class )->
78
if( in->BandFmt != VIPS_FORMAT_COMPLEX ) {
79
if( vips_fwfft( in, &t[0], NULL ) )
84
if( vips_abs( in, &t[1], NULL ) ||
85
vips_scale( t[1], &t[2], "log", TRUE, NULL ) ||
86
vips_wrap( t[2], &t[3], NULL ) )
89
if( vips_image_write( t[3], freqfilt->out ) )
96
vips_spectrum_class_init( VipsSpectrumClass *class )
98
VipsObjectClass *vobject_class = VIPS_OBJECT_CLASS( class );
100
vobject_class->nickname = "spectrum";
101
vobject_class->description = _( "make displayable power spectrum" );
102
vobject_class->build = vips_spectrum_build;
107
vips_spectrum_init( VipsSpectrum *spectrum )
115
* @...: %NULL-terminated list of optional named arguments
117
* Make a displayable (ie. 8-bit unsigned int) power spectrum.
119
* If @in is non-complex, it is transformed to Fourier space. Then the
120
* absolute value is passed through vips_scale() in log mode, and vips_wrap().
122
* See also: vips_fwfft(), vips_scale(), vips_wrap().
124
* Returns: 0 on success, -1 on error.
127
vips_spectrum( VipsImage *in, VipsImage **out, ... )
133
result = vips_call_split( "spectrum", ap, in, out );