Mercurial > hg > wm
diff Meerwald/wavelet.c @ 8:f83ef905a63d
fixing many warnings
increase capacity for coordinates in bruyn
fix some uninit. variables
author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
---|---|
date | Tue, 22 Apr 2008 13:36:05 +0200 |
parents | be303a3f5ea8 |
children | bd669312f068 |
line wrap: on
line diff
--- a/Meerwald/wavelet.c Wed Apr 16 15:55:52 2008 +0200 +++ b/Meerwald/wavelet.c Tue Apr 22 13:36:05 2008 +0200 @@ -4,6 +4,7 @@ #include <math.h> #include "wavelet.h" #include <ctype.h> +#include <values.h> static int read_char(FILE *fp); static int read_int(FILE *fp); @@ -140,7 +141,7 @@ * This function loads an IntImage with load_intimage * and then converts to Image. ************************************************************************/ -extern Image load_image(char *file, int max_val) +Image load_image(char *file, int max_val) { Image img; IntImage intimg; @@ -164,7 +165,7 @@ /* */ /************************************************************************/ -extern int save_image_P5(char *file, Image img) +int save_image_P5(char *file, Image img) { FILE *fp; Pixel *data; long i; @@ -202,7 +203,7 @@ (img->data)[i]=(Pixel) 0; } -extern void copy_into_image(Image img1,Image img2,int x,int y) +void copy_into_image(Image img1,Image img2,int x,int y) /* copy img2 into img1 at position (x,y)*/ { int start,i,j,aim; @@ -219,7 +220,7 @@ } } -extern void copy_into_intimage(IntImage img1,IntImage img2,int x,int y) +void copy_into_intimage(IntImage img1,IntImage img2,int x,int y) {/* copy img2 into img1 at position (x,y)*/ int start,i,j,aim; @@ -258,7 +259,7 @@ } } -extern void copy_part_of_image(Image img1,Image img2,int x,int y) +void copy_part_of_image(Image img1,Image img2,int x,int y) /* copy part of img2 begining at position (x,y) into img1 */ { int i,j,width,height,start,step; Pixel *data; @@ -277,10 +278,10 @@ } -extern void scale_image(Image img,int maximum) +void scale_image(Image img, int maximum) /* scale image to [0..maximum]*/ { int i; - Pixel max,min,multi; + Pixel max = MINDOUBLE, min = MAXDOUBLE, multi; for (i=0;i<img->size;i++) { if (img->data[i]<min) min=img->data[i]; @@ -951,8 +952,6 @@ int fstart,fend; int in_pos; - int in_dir,in_div,in_mod; - Entering; PreCondition(out_len == in_len/2,"out_len != in_len/2 !!!"); @@ -1002,9 +1001,9 @@ Filter f) { int i,j; - Pixel *out_pix, *in_pix, *f_data; + Pixel *out_pix, *in_pix; int fstart,fend; /* Source interval */ - int in_pos,in_dir,in_div,in_mod; + int in_pos; Entering; PreCondition(out_len == in_len*2,"out_len != in_len*2 !!!"); @@ -1353,8 +1352,8 @@ static int compute_best(Image_tree tree,int level,int max_level,FilterGH *flt, enum FilterMethod method,enum Information_Cost cost,double epsilon); static double compute_entropy(Image img,enum Information_Cost cost,double epsilon); -static compute_levels(Image_tree tree,double *entropies,enum Information_Cost cost,double epsilon); -static free_levels(Image_tree tree,int best); +static void compute_levels(Image_tree tree,double *entropies,enum Information_Cost cost,double epsilon); +static void free_levels(Image_tree tree,int best); static Pixel sumationq(Image img); static Pixel normq(Image_tree tree); @@ -1374,7 +1373,7 @@ /* Description: Carries out the wavelettransform */ /* */ /************************************************************************/ -extern Image_tree wavelettransform(Image original,int level,FilterGH *flt,enum FilterMethod method) +Image_tree wavelettransform(Image original,int level,FilterGH *flt,enum FilterMethod method) { int i,width,height,min,max_level,e; Image coarsei,horizontali,verticali,diagonali,tempi; Image_tree ret_tree,temp_tree; @@ -1532,8 +1531,8 @@ return NULL; } -extern Image_tree wavelettransform_wp(Image original, int level, FilterGH *flt, enum FilterMethod method) { - wavelettransform__wp(original, 0, level, flt, method); +Image_tree wavelettransform_wp(Image original, int level, FilterGH *flt, enum FilterMethod method) { + return wavelettransform__wp(original, 0, level, flt, method); } @@ -1551,7 +1550,7 @@ /* Description: carries best basis and near best basis selection */ /* out */ /************************************************************************/ -extern Image_tree best_basis(Image original,int level,FilterGH *flt, +Image_tree best_basis(Image original,int level,FilterGH *flt, enum FilterMethod method,enum Information_Cost cost,double epsilon) { Image_tree tree; @@ -1598,7 +1597,7 @@ /* Description: Carries out the best level selection */ /* */ /************************************************************************/ -extern Image_tree best_level(Image original,int maxlevel,int *bestlevel,FilterGH *flt,enum FilterMethod method, +Image_tree best_level(Image original,int maxlevel,int *bestlevel,FilterGH *flt,enum FilterMethod method, enum Information_Cost cost,double epsilon) { Image_tree tree; Image img; @@ -1752,7 +1751,7 @@ /* Description: whole decompositing down to maxlevel */ /* The original image must be in tree->image */ /************************************************************************/ -extern int decompose_all(Image_tree tree,int maxlevel,FilterGH *flt,enum FilterMethod method, +int decompose_all(Image_tree tree,int maxlevel,FilterGH *flt,enum FilterMethod method, enum Information_Cost cost,double epsilon) { Image original,coarse,horizontal,vertical,diagonal; @@ -1819,7 +1818,7 @@ /* -------------------------------------------------------------------- */ /* Description: Compute the entropies of all decomposition levels */ /************************************************************************/ -static compute_levels(Image_tree tree,double *entropies,enum Information_Cost cost,double epsilon) +static void compute_levels(Image_tree tree,double *entropies,enum Information_Cost cost,double epsilon) { if (tree->image){ entropies[tree->level]+=compute_entropy(tree->image,cost,epsilon); @@ -1840,7 +1839,7 @@ /* -------------------------------------------------------------------- */ /* Description: clean the image tree except the best level */ /************************************************************************/ -static free_levels(Image_tree tree,int best) +static void free_levels(Image_tree tree,int best) { if (tree->level<best) { @@ -1876,7 +1875,7 @@ /* Description: Decomposes an image to an certain level and stores */ /* only this level in the returned quadtree */ /************************************************************************/ -extern Image_tree decompose_to_level(Image original,int level,FilterGH *flt,enum FilterMethod method) +Image_tree decompose_to_level(Image original,int level,FilterGH *flt,enum FilterMethod method) { Image_tree tree; int e; @@ -2004,7 +2003,7 @@ /* Description: builds up an image out of an Image_tree */ /* */ /************************************************************************/ -extern Image build_image(Image_tree quadtree,int width,int height) +Image build_image(Image_tree quadtree,int width,int height) { Image ret_img,coarse,horizontal,vertical,diagonal; @@ -2051,7 +2050,7 @@ /* Description: Inverts the wavelettransform,best_basis,best_level */ /* */ /************************************************************************/ -extern Image inv_transform(Image_tree tree,FilterGH *flt, +Image inv_transform(Image_tree tree,FilterGH *flt, enum FilterMethod method) { int er,width,height; @@ -2109,7 +2108,7 @@ /* Description: Finds the deepest possible level where width and */ /* height can divided by two exactly. */ /************************************************************************/ -extern int find_deepest_level(int width,int height) +int find_deepest_level(int width,int height) { int level=0,w=width,h=height; @@ -2388,7 +2387,7 @@ recarea(tree,list,list_size); abs_list(list,*list_size); - qsort(list,*list_size, sizeof(Pixel), &comp); + qsort(list,*list_size, sizeof(Pixel), (int (*)(const void*, const void*)) comp); for (k=0;k<size;k++) { @@ -2407,7 +2406,7 @@ } static Pixel comp_number(Image_tree tree,int size,int p,double f) -{ Pixel sum=0,*list,min,norm,npf,normf; +{ Pixel sum=0,*list,min=MAXDOUBLE,norm,npf,normf; int *list_size=0,k; list_size=(int *)malloc(sizeof(int)); @@ -2419,7 +2418,7 @@ recarea(tree,list,list_size); abs_list(list,*list_size); - qsort(list,*list_size, sizeof(Pixel), &comp); + qsort(list,*list_size, sizeof(Pixel), (int (*)(const void*, const void*)) comp); norm=sum_list(list,p,size); normf=norm*f; @@ -2458,7 +2457,7 @@ recarea(tree,list,list_size); abs_list(list,*list_size); - qsort(list,*list_size, sizeof(Pixel), &comp); + qsort(list,*list_size, sizeof(Pixel), (int (*)(const void*, const void*)) comp); norm=sum_list(list,p,size); @@ -2494,7 +2493,7 @@ recarea(tree,list,list_size); - qsort(list,*list_size, sizeof(Pixel), &comp); + qsort(list,*list_size, sizeof(Pixel), (int (*)(const void*, const void*)) comp); min=list[0]; max=list[size-1]; @@ -2534,7 +2533,7 @@ recarea(tree,list,list_size); - qsort(list,*list_size, sizeof(Pixel), &comp); + qsort(list,*list_size, sizeof(Pixel), (int (*)(const void*, const void*)) comp); min=list[0]; max=list[size-1]; @@ -2576,7 +2575,7 @@ recarea(tree,list,list_size); - qsort(list,*list_size, sizeof(Pixel), &comp); + qsort(list,*list_size, sizeof(Pixel), (int (*)(const void*, const void*)) comp); min=list[0]; max=list[size-1]; @@ -2694,7 +2693,7 @@ /************************************************************************/ static Pixel compute_non_additive(Image_tree tree,int size,enum Information_Cost cost,double epsilon,int down) { Pixel sum=0,normx; - Image img; + Image img=NULL; if (down) { @@ -2744,7 +2743,7 @@ return sum; } -extern int rec_double(Image_tree dtree,int level,FilterGH *flt,enum FilterMethod method,enum Information_Cost cost,double epsilon) +int rec_double(Image_tree dtree,int level,FilterGH *flt,enum FilterMethod method,enum Information_Cost cost,double epsilon) { int min,width,height; double sum=0; @@ -2854,7 +2853,7 @@ return 0; } -static save_structur(Image_tree tree,FILE *fp,int pos) +static void save_structur(Image_tree tree,FILE *fp,int pos) { int shift,next_pos,max; @@ -2870,7 +2869,6 @@ if (tree->vertical) save_structur(tree->vertical,fp,next_pos+2); if (tree->diagonal) save_structur(tree->diagonal,fp,next_pos+3); } - } static int is_in_list(int *list,int len, int x) @@ -2889,7 +2887,7 @@ return found; } -static write_flags(Image_tree tree,int *list,int len,int pos) +static void write_flags(Image_tree tree,int *list,int len,int pos) { int shift,next_pos,max; @@ -2908,21 +2906,6 @@ } } -static read_structur(Image_tree tree,FILE *fp) -{ - int e, flags[1000],len=0,i=0; - - do - { - e=fscanf(fp,"%d ",&flags[i++]); - if (e!=-1) len++; - } - while (e!=-1); - - write_flags(tree,flags,len,0); - -} - /************************************************************************/ /* Functionname: err_simple_message */ /* -------------------------------------------------------------------- */