~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to contrib/wavelet/libsrc/interpol.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*===========================================================================
 
2
  Copyright (C) 1993-2009 European Southern Observatory (ESO)
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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, 
 
17
  MA 02139, USA.
 
18
 
 
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 
 
25
                        GERMANY
 
26
===========================================================================*/
 
27
 
 
28
/******************************************************************************
 
29
**
 
30
**    UNIT
 
31
**
 
32
**    Version: 19.1
 
33
**
 
34
**    Author: Jean-Luc Starck
 
35
**
 
36
**    Date:  03/02/25
 
37
**    
 
38
**    File:  interpol.c
 
39
**
 
40
.VERSION
 
41
 090804         last modif
 
42
 
 
43
*******************************************************************************
 
44
**
 
45
**    DESCRIPTION  plane interpolation routines
 
46
**    -----------  
 
47
**                 
 
48
******************************************************************************
 
49
**
 
50
** wavelet_interpol_plan_file (File_Name_Imag, File_Name_Transform, 
 
51
**                            Num_Plan, Num_Plan_Up)
 
52
**
 
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
 
58
** 
 
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)
 
63
**
 
64
******************************************************************************
 
65
**
 
66
** wavelet_interpol_plan (Wavelet, Imag, Nl, Nc, Num_Plan, Num_Plan_Up)
 
67
** float **Imag;
 
68
** wave_transf_des *Wavelet;
 
69
** int *Nl, *Nc, Num_Plan, Num_Plan_Up;
 
70
** 
 
71
** Interpolates from a wavelet transform a plane of resolution number
 
72
**  Num_Plan to a plane of resolution number Num_Plan_Up 
 
73
** 
 
74
** we need  0 < Num_Plan_Up < Num_Plan <= Nbr_Plan
 
75
** output: Imag = Wavelet.Plan[Num_Plan] interpolated to Num_Plan_Up 
 
76
** 
 
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)
 
83
** 
 
84
** The Mallat's wavelet transform is not treated by this routine 
 
85
** 
 
86
******************************************************************************/
 
87
 
 
88
 
 
89
#include <stdio.h>
 
90
#include <stdlib.h>
 
91
#include <math.h>
 
92
#include <string.h>
 
93
 
 
94
#include "Def_Math.h"
 
95
#include "Def_Mem.h"
 
96
#include "Def_Wavelet.h"
 
97
 
 
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();
 
101
 
 
102
 
 
103
 
 
104
/*****************************************************************************/
 
105
 
 
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;
 
110
{
 
111
    float *Imag;
 
112
    wave_transf_des Wavelet;
 
113
    int Nl, Nc;
 
114
 
 
115
    /* read the wavelet file */
 
116
    wave_io_read (File_Name_Transform, &Wavelet);
 
117
 
 
118
    if (Wavelet.Type_Wave_Transform == TO_MALLAT_BARLAUD)
 
119
    {
 
120
        io_err_message_exit (ERR_NOT_IMPLEMENTED, " ");
 
121
    }
 
122
    
 
123
    /* interpolation */
 
124
    wavelet_interpol_plan (&Wavelet,&Imag,&Nl, &Nc, Num_Plan, Num_Plan_Up);
 
125
 
 
126
    /* we save the result */
 
127
    io_write_pict_f_to_file (File_Name_Imag, Imag, Nl, Nc);
 
128
 
 
129
    wave_io_free (&Wavelet);
 
130
    free ((char *) Imag);
 
131
}
 
132
 
 
133
/*****************************************************************************/
 
134
 
 
135
void wavelet_interpol_plan (Wavelet, Imag, Nl, Nc, Num_Plan, Num_Plan_Up)
 
136
float **Imag;
 
137
wave_transf_des *Wavelet;
 
138
int *Nl, *Nc, Num_Plan, Num_Plan_Up;
 
139
{
 
140
    float *Ptr;
 
141
    int i, Nbr_Plan;
 
142
    string Mes_Memory;
 
143
 
 
144
    /* number of planes */
 
145
    Nbr_Plan = Wavelet->Nbr_Plan;
 
146
 
 
147
    /* Test the plane number Num_Plan */
 
148
    if ((Num_Plan <= 0) || (Num_Plan > Nbr_Plan))
 
149
    {
 
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);
 
153
    }
 
154
 
 
155
    /* Test the plane number Num_Plan_Up */
 
156
    if ((Num_Plan_Up >= Num_Plan) || (Num_Plan_Up <= 0))
 
157
    {
 
158
        /* The plane number Num_Plan_Up is false */
 
159
        sprintf (Mes_Memory,"interpolated plane number must be in 1 .. %d\n",
 
160
                 Num_Plan-1);
 
161
        io_err_message_exit (ERR_INTERP_PLANE_NUMBER, Mes_Memory);
 
162
    }
 
163
    
 
164
    switch (Wavelet->Type_Wave_Transform)
 
165
    {
 
166
        case TO_PAVE_LINEAR:
 
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];
 
174
                   break;
 
175
        case TO_PYR_LINEAR:
 
176
        case TO_PYR_BSPLINE:
 
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, 
 
181
                                        *Imag, 
 
182
                                        Wavelet->Pyramid.Tab_Nl, 
 
183
                                        Wavelet->Pyramid.Tab_Col, 
 
184
                                        Wavelet->Pyramid.Tab_Pos, 
 
185
                                        Num_Plan-1, Num_Plan_Up-1);
 
186
                   break;
 
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, 
 
193
                                          *Imag, 
 
194
                                          Wavelet->Pyramid.Tab_Nl, 
 
195
                                          Wavelet->Pyramid.Tab_Col, 
 
196
                                          Wavelet->Pyramid.Tab_Pos, 
 
197
                                          Num_Plan-1, Num_Plan_Up-1);
 
198
                   break;
 
199
        case TO_MALLAT_BARLAUD:
 
200
                   io_err_message_exit (ERR_NOT_IMPLEMENTED, " ");
 
201
                   break;
 
202
        default:
 
203
                   io_err_message_exit (ERR_TRANSF, " ");
 
204
                   break;
 
205
    }   
 
206
}
 
207
 
 
208
 
 
209
 
 
210