annotate Meerwald/wavelet.h @ 0:be303a3f5ea8

import
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Sun, 12 Aug 2007 13:14:34 +0200
parents
children f83ef905a63d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
1 #ifndef WAVELET_H
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
2
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
3 #include <stdio.h>
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
4
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
5 extern char dbgstr[1000];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
6
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
7 /* this are internal functions - don't use 'em! */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
8 extern void out_dbg_str(const char *str);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
9 extern void start_trace(void);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
10 extern void stop_trace(void);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
11 extern void flush_trace_file(void);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
12
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
13 /* public functions / macros */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
14 #define StartTrace
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
15 #define StopTrace
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
16
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
17 #define Trace(str)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
18 #define TraceVar(str,var)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
19
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
20 #define Entering
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
21 #define Leaving
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
22 #define LeavingErr
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
23 #define FlushTrace
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
24
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
25 #define Warning(str)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
26
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
27 #define PreCondition(exp,str)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
28 #define PostCondition(exp,str)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
29
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
30 /* Note that if an error is added, an errormessage for this specific
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
31 error must also be added. Otherwise no appropriate message can
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
32 be displayed in an error window. ( Then "Unknown error ocurred"
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
33 will be displayed.)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
34 The errormessage must be added to the case-construct in the
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
35 procedure err_GetErrorMessage
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
36 */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
37
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
38 typedef enum
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
39 {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
40 Error_NoError, /* No Error has happened. */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
41 Error_NotImplemented, /* A needed part has not (yet) been
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
42 implemented */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
43 Error_AssertionFailed, /* An assertion, pre- or postcondition failed.
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
44 Occurs only in buggy programs. */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
45 Error_NotEnoughMemory, /* We can't allocate the memory we need. */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
46
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
47 Error_Limitation, /* Some limitation exceeded, e.g. a string
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
48 variable is too short */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
49
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
50
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
51 Error_CantOpenFile, /* The file cannot be opened */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
52 Error_CantCreateFile,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
53 Error_CantWriteIntoFile,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
54 Error_CantCloseFile,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
55 Error_WrongFileFormat,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
56
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
57 Error_WidthOrHeightZero,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
58 Error_CompressedZeroContent,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
59 Error_OriginalZeroContent,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
60
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
61 Error_InternalError
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
62
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
63 }Error;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
64
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
65
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
66 /************************************************************************/
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
67 /* Functionname: err_simple_message */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
68 /* -------------------------------------------------------------------- */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
69 /* Parameter: */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
70 /* char *: string that contains information about an */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
71 /* error the user should know. */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
72 /* -------------------------------------------------------------------- */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
73 /* Description: */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
74 /* Prints error messages for the user. */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
75 /************************************************************************/
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
76 void err_SimpleMessage(char *message);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
77
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
78 /************************************************************************/
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
79 /* Functionname: err_get_message */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
80 /* -------------------------------------------------------------------- */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
81 /* Return value: Errormessage for this specific error. */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
82 /* Parameter: */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
83 /* Error err: Error whose errormessage should be returned */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
84 /* -------------------------------------------------------------------- */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
85 /* Description: */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
86 /************************************************************************/
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
87 char * err_GetErrorMessage(Error err);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
88
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
89 #include <stddef.h>
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
90
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
91 typedef double Pixel;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
92
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
93 typedef struct Image_struct {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
94 Pixel *data;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
95 int width,height;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
96
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
97 /* redundant, for our fun only :-) */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
98 Pixel min_val,max_val; /* range of pixel-values in data */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
99 /* [min_val..max_val] */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
100 int size; /* = width * height */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
101 int bpp; /* bits per pixel of original image */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
102 } *Image;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
103
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
104 typedef unsigned int IntPixel;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
105
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
106 typedef struct IntImage_struct {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
107 IntPixel *data;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
108 int width, height;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
109
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
110 /* redundant, for our fun only :-) */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
111 IntPixel min_val,max_val; /* range of values in data */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
112 /* [min_val..max_val] */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
113 int size; /* = width * height */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
114 int bpp; /* bits per pixel of original image */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
115 } *IntImage;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
116
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
117 typedef struct Image_tree_struct {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
118 double entropy;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
119 struct Image_tree_struct *coarse,*horizontal,*vertical,*diagonal,*doubletree;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
120 Image image;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
121 int level;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
122 int flag;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
123
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
124 void *codec_data;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
125 IntImage significance_map;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
126 } *Image_tree;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
127
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
128 typedef struct Image_info_struct {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
129 Pixel min,max,mean,var,rms;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
130 } *Image_info;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
131
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
132 enum zigzag_direction {zigzag_up,zigzag_down,zigzag_right,zigzag_left};
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
133
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
134 typedef struct Zigzag_data_struct {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
135 int x,y,w,h;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
136 enum zigzag_direction dir;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
137 } *Zigzag_data;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
138
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
139 #define get_intpixel(image,x,y) ( ((image)==NULL || \
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
140 (x)<0 || (x)>=(image)->width || (y)<0 || (y)>=(image)->height) \
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
141 ? (IntPixel) 0 : (image)->data[(x)+(y)*(image)->width])
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
142
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
143 #define set_intpixel(image,x,y,val) if (!((image)==NULL || \
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
144 (x)<0 || (x)>=(image)->width || (y)<0 || (y)>=(image)->height)) \
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
145 (image)->data[(x)+(y)*(image)->width]=(IntPixel) (val)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
146
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
147 #define get_pixel(image,x,y) ( ((image)==NULL || \
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
148 (x)<0 || (x)>=(image)->width || (y)<0 || (y)>=(image)->height) \
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
149 ? (Pixel) 0 : (image)->data[(x)+(y)*(image)->width])
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
150
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
151 #define set_pixel(image,x,y,val) if (!((image)==NULL || \
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
152 (x)<0 || (x)>=(image)->width || (y)<0 || (y)>=(image)->height)) \
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
153 (image)->data[(x)+(y)*(image)->width]=(Pixel) (val)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
154
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
155 #define get_pixel_adr(image,x,y) ( ((image)==NULL || \
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
156 (x)<0 || (x)>=(image)->width || (y)<0 || (y)>=(image)->height) \
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
157 ? (Pixel*) NULL : (image)->data+((x)+(y)*(image)->width))
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
158
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
159 /* functions: */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
160
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
161 extern IntImage new_intimage(int width, int height);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
162 extern IntImage load_intimage(char *file, int max_val);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
163 extern void free_intimage(IntImage img);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
164
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
165 extern void clear_intimage(IntImage img);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
166 extern void copy_into_intimage(IntImage img1,IntImage img2,int x,int y);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
167 extern void copy_part_of_intimage(IntImage img1,IntImage img2,int x,int y);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
168
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
169 extern Image new_image(int width, int height);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
170 extern void free_image(Image img);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
171 extern void clear_image(Image img);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
172 extern void copy_into_image(Image img1,Image img2,int x,int y);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
173 extern void scale_image(Image img,int maximum);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
174 extern void copy_part_of_image(Image img1,Image img2,int x,int y);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
175
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
176 extern void copy_part_of_image_into_image(
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
177 Image dest_img, int dest_x, int dest_y,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
178 Image src_img, int src_x, int src_y,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
179 int width, int height);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
180
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
181
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
182 extern int string_to_pixel(char *str, Pixel *p);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
183
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
184 extern Image load_image(char *file, int max_val);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
185 extern int save_image_P5(char *file, Image img);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
186
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
187 extern Image intimage_to_image(IntImage i);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
188 extern IntImage image_to_intimage(Image i);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
189
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
190 extern Image_tree new_image_tree();
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
191 extern void free_image_tree(Image_tree t);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
192
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
193 extern Image get_difference_image(Image image1, Image image2);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
194
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
195 extern void get_image_infos(Image image, Image_info info);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
196
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
197 extern void get_intimage_infos(IntImage image, IntPixel *min, IntPixel *max, Pixel *avg, Pixel *var);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
198
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
199 extern void init_zigzag(Zigzag_data zz, int width, int height);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
200 extern void next_zigzag(Zigzag_data zz);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
201 extern Image get_absolute_image_scaled(Image img);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
202
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
203 /* common macros */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
204
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
205 #ifndef MIN
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
206 #define MIN(a,b) ((a)<(b)?(a):(b))
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
207 #endif
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
208
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
209 #ifndef MAX
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
210 #define MAX(a,b) ((a)>(b)?(a):(b))
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
211 #endif
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
212
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
213 enum FilterType { FTNoSymm, FTSymm, FTAntiSymm};
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
214
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
215 typedef struct FilterStruct {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
216 enum FilterType type;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
217 int hipass;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
218 Pixel * data;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
219 int start,end;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
220
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
221 int len;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
222 } *Filter;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
223
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
224 extern Filter new_filter(int size);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
225
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
226 extern int filter_cutoff(Image in, int in_start, int in_len, int in_step,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
227 Image out, int out_start, int out_len, int out_step,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
228 Filter f);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
229
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
230 extern int filter_inv_cutoff(Image in, int in_start, int in_len, int in_step,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
231 Image out, int out_start, int out_len, int out_step,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
232 Filter f);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
233
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
234 extern int filter_periodical(Image in, int in_start, int in_len, int in_step,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
235 Image out, int out_start, int out_len, int out_step,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
236 Filter f);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
237
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
238 extern int filter_inv_periodical(Image in, int in_start, int in_len, int in_step,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
239 Image out, int out_start, int out_len, int out_step,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
240 Filter f);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
241
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
242 extern int filter_mirror(Image in, int in_start, int in_len, int in_step,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
243 Image out, int out_start, int out_len, int out_step,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
244 Filter f);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
245
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
246 extern int filter_inv_mirror(Image in, int in_start, int in_len, int in_step,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
247 Image out, int out_start, int out_len, int out_step,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
248 Filter f);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
249
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
250 extern Pixel get_filter_center(Filter f);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
251
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
252 enum FilterGHType { FTOrtho, FTBiOrtho, FTOther};
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
253
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
254 typedef struct FilterGHStruct {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
255 enum FilterGHType type;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
256 Filter g, h, gi, hi;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
257 char *name;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
258 } *FilterGH;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
259
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
260 typedef struct AllFilterStruct {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
261 FilterGH *filter;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
262 int count;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
263 } *AllFilters;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
264
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
265
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
266 extern AllFilters load_filters(char *name);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
267
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
268 typedef struct SegmentsStruct {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
269 int width,height; /* segment width & height*/
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
270 int *data;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
271 } *Segments;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
272
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
273 enum FilterMethod{cutoff,inv_cutoff,periodical,inv_periodical,mirror,inv_mirror};
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
274
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
275 enum Information_Cost{threshold,log_energy,entropy,norml,norml2,gauss_markov,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
276 shanon,weak_l,weak_lq,compression_number,compression_numberq,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
277 compression_area,compression_areaq,sdiscrepancy,discrepancy,concentration};
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
278
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
279 extern Image_tree wavelettransform(Image original,int level,FilterGH *flt,enum FilterMethod method);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
280 extern Image_tree wavelettransform_wp(Image original,int level,FilterGH *flt,enum FilterMethod method);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
281
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
282 extern Image_tree best_basis(Image original,int level,FilterGH *flt,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
283 enum FilterMethod method,enum Information_Cost cost,double epsilon);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
284
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
285 extern Image_tree best_level(Image original,int maxlevel,int *bestlevel,FilterGH *flt,enum FilterMethod method,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
286 enum Information_Cost cost,double epsilon);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
287
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
288 extern Image build_image(Image_tree quadtree,int width,int height);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
289
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
290 extern Image inv_transform(Image_tree quadtree,FilterGH *flt,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
291 enum FilterMethod method);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
292
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
293 extern Image inv_transform_wp(Image_tree quadtree,FilterGH *flt,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
294 enum FilterMethod method);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
295
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
296 extern int rec_double(Image_tree dtree,int level,FilterGH *flt,enum FilterMethod method,enum Information_Cost cost,double epsilon);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
297
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
298 extern Image_tree decompose_to_level(Image original,int level,FilterGH *flt,enum FilterMethod method);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
299
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
300 extern decompose_all(Image_tree tree,int maxlevel,FilterGH *flt,enum FilterMethod method,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
301 enum Information_Cost cost,double epsilon);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
302
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
303 extern int find_deepest_level(int width,int height);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
304
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
305 /*Selective methods*/
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
306 extern int selectiv_tiling1(Image img,Segments seg,int filternumber,char *file,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
307 enum Information_Cost cost,double epsilon);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
308 extern Image inv_selectiv_tiling1(char *file);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
309
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
310 extern int selectiv_tiling2(Image img,Segments seg,int filternumber,char *file,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
311 enum Information_Cost cost,double epsilon);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
312 extern Image inv_selectiv_tiling2(char *file);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
313
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
314 extern int selectiv_quant1(Image img,IntImage area,int filternumber,char *file,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
315 enum Information_Cost cost,double epsilon);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
316 extern Image inv_selectiv_quant1(char *file);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
317
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
318 extern int selectiv_quant2(Image img,IntImage area,int filternumber,char *file,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
319 enum Information_Cost cost,double epsilon);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
320 extern Image inv_selectiv_quant2(char *file);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
321
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
322 extern int selectiv_quant3(Image img,IntImage area,int filternumber,char *file,
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
323 enum Information_Cost cost,double epsilon);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
324 extern Image inv_selectiv_quant3(char *file);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
325
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
326 extern smooth_block(Image img,int x,int y, int width,int height);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
327
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
328 extern compute_map(Image_tree tree,IntImage map);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
329
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
330 extern int *pixelarray_to_intarray(Pixel *pdata,int size);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
331 extern Pixel *intarray_to_pixelarray(int *idata,int size);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
332
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
333 #define WAVELET_H
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
334 #endif

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.