1
/*===========================================================================
2
Copyright (C) 1993-2009 European Southern Observatory (ESO)
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public
15
License along with this program; if not, write to the Free
16
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
19
Correspondence concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
28
/******************************************************************************
34
** Author: Jean-Luc Starck
43
*******************************************************************************
45
** DESCRIPTION plane interpolation routines
48
******************************************************************************
50
** wavelet_interpol_plan_file (File_Name_Imag, File_Name_Transform,
51
** Num_Plan, Num_Plan_Up)
53
** Interpolates from a wavelet transform, which is in the file of name
54
** File_Name_Transform, a plane of resolution number Num_Plan to a plane
55
** of resolution number Num_Plan_Up . The interpolated plane is saved in
56
** a image of name File_Name_Imag
57
** we need 0 < Num_Plan_Up < Num_Plan <= Nbr_Plan
59
** File_Name_Imag = output file name of the image
60
** File_Name_Transform = input file name of the wavelet transform
61
** Num_Plan = plane number to interpolates (Num_Plan = 1 .. Number_of_Planes)
62
** Num_Plan_up = interpolated plane number (Num_Plan = 1 .. Num_Plan)
64
******************************************************************************
66
** wavelet_interpol_plan (Wavelet, Imag, Nl, Nc, Num_Plan, Num_Plan_Up)
68
** wave_transf_des *Wavelet;
69
** int *Nl, *Nc, Num_Plan, Num_Plan_Up;
71
** Interpolates from a wavelet transform a plane of resolution number
72
** Num_Plan to a plane of resolution number Num_Plan_Up
74
** we need 0 < Num_Plan_Up < Num_Plan <= Nbr_Plan
75
** output: Imag = Wavelet.Plan[Num_Plan] interpolated to Num_Plan_Up
77
** Wavelet = INPUT: wavelet transform
78
** Imag = OUTPUT: interpolated plane
79
** Nl = OUTPUT: ptr to the number of lines of Imag
80
** Nc = OUTPUT: ptr to the number of columns of Imag
81
** Num_Plan = plane number to interpolated (Num_Plan = 1 .. Number_of_Planes)
82
** Num_Plan_up = interpolated plane number (Num_Plan = 1 .. Num_Plan)
84
** The Mallat's wavelet transform is not treated by this routine
86
******************************************************************************/
96
#include "Def_Wavelet.h"
98
extern void wave_io_read(), wave_io_free(), wavelet_interpol_plan();
99
extern void io_err_message_exit(), io_write_pict_f_to_file();
100
extern void pyr_2d_interp_plan(), pyr_2d_cf_interp_plan();
104
/*****************************************************************************/
106
void wavelet_interpol_plan_file (File_Name_Imag, File_Name_Transform,
107
Num_Plan, Num_Plan_Up)
108
char *File_Name_Imag, *File_Name_Transform;
109
int Num_Plan, Num_Plan_Up;
112
wave_transf_des Wavelet;
115
/* read the wavelet file */
116
wave_io_read (File_Name_Transform, &Wavelet);
118
if (Wavelet.Type_Wave_Transform == TO_MALLAT_BARLAUD)
120
io_err_message_exit (ERR_NOT_IMPLEMENTED, " ");
124
wavelet_interpol_plan (&Wavelet,&Imag,&Nl, &Nc, Num_Plan, Num_Plan_Up);
126
/* we save the result */
127
io_write_pict_f_to_file (File_Name_Imag, Imag, Nl, Nc);
129
wave_io_free (&Wavelet);
130
free ((char *) Imag);
133
/*****************************************************************************/
135
void wavelet_interpol_plan (Wavelet, Imag, Nl, Nc, Num_Plan, Num_Plan_Up)
137
wave_transf_des *Wavelet;
138
int *Nl, *Nc, Num_Plan, Num_Plan_Up;
144
/* number of planes */
145
Nbr_Plan = Wavelet->Nbr_Plan;
147
/* Test the plane number Num_Plan */
148
if ((Num_Plan <= 0) || (Num_Plan > Nbr_Plan))
150
/* The plane number Num_Plan is false */
151
sprintf (Mes_Memory,", Number of planes = %d\n", Nbr_Plan);
152
io_err_message_exit (ERR_PLANE_NUMBER, Mes_Memory);
155
/* Test the plane number Num_Plan_Up */
156
if ((Num_Plan_Up >= Num_Plan) || (Num_Plan_Up <= 0))
158
/* The plane number Num_Plan_Up is false */
159
sprintf (Mes_Memory,"interpolated plane number must be in 1 .. %d\n",
161
io_err_message_exit (ERR_INTERP_PLANE_NUMBER, Mes_Memory);
164
switch (Wavelet->Type_Wave_Transform)
167
case TO_PAVE_BSPLINE:
168
case TO_PAVE_BSPLINE_FFT:
169
*Nl = Wavelet->Nbr_Ligne;
170
*Nc = Wavelet->Nbr_Col;
171
Ptr = Wavelet->Pave.Data + (Num_Plan - 1) * *Nl * *Nc;
172
*Imag = f_vector_alloc (*Nl * *Nc);
173
for (i = 0; i < *Nl * *Nc; i++) (*Imag)[i] = Ptr[i];
177
*Nl = (Wavelet->Pyramid.Tab_Nl) [Num_Plan_Up - 1];
178
*Nc = (Wavelet->Pyramid.Tab_Col)[Num_Plan_Up - 1];
179
*Imag = f_vector_alloc (*Nl * *Nc);
180
pyr_2d_interp_plan (Wavelet->Pyramid.Data,
182
Wavelet->Pyramid.Tab_Nl,
183
Wavelet->Pyramid.Tab_Col,
184
Wavelet->Pyramid.Tab_Pos,
185
Num_Plan-1, Num_Plan_Up-1);
187
case TO_PYR_FFT_DIFF_RESOL:
188
case TO_PYR_FFT_DIFF_SQUARE_RESOL:
189
*Nl = (Wavelet->Pyramid.Tab_Nl) [Num_Plan_Up - 1];
190
*Nc = (Wavelet->Pyramid.Tab_Col)[Num_Plan_Up - 1];
191
*Imag = f_vector_alloc (*Nl * *Nc);
192
pyr_2d_cf_interp_plan (Wavelet->Pyramid.Data,
194
Wavelet->Pyramid.Tab_Nl,
195
Wavelet->Pyramid.Tab_Col,
196
Wavelet->Pyramid.Tab_Pos,
197
Num_Plan-1, Num_Plan_Up-1);
199
case TO_MALLAT_BARLAUD:
200
io_err_message_exit (ERR_NOT_IMPLEMENTED, " ");
203
io_err_message_exit (ERR_TRANSF, " ");