little fix

This commit is contained in:
eddyem 2015-02-11 16:23:41 +03:00
parent 35a1e70547
commit 36de9a3712
7 changed files with 66 additions and 63 deletions

View File

@ -691,3 +691,4 @@ free_all:
} }
extern "C" int MedFilter(float *ima, float **result, Filter *f, int sizex, int sizey){return 0;} extern "C" int MedFilter(float *ima, float **result, Filter *f, int sizex, int sizey){return 0;}
extern "C" int GradFilterSimple(float *ima, float **result, Filter *f, int sizex, int sizey){return 0;} extern "C" int GradFilterSimple(float *ima, float **result, Filter *f, int sizex, int sizey){return 0;}

View File

@ -678,60 +678,6 @@ int MedFilter(float *ima,
DBG("time=%f\n", dtime()-t0); DBG("time=%f\n", dtime()-t0);
return TRUE; return TRUE;
} }
/*
* Fill isolines' scale (an array)
* Input:
* f - filter for given method
* min - minimum value of intensity
* wd - max-min (dinamic range)
* Output:
* scale - a pointer to array (allocated in this function)
*/
int fillIsoScale(Filter *f, float **scale, float min, float wd){
int M = f->w, y;
float (*scalefn)(float in);
float step, Nsteps = (float)f->w; // amount of intervals
float Suniform(float in){
return step*in + min;
}
float Slog(float in){
return expf(in*step) + min - 1.;
}
float Sexp(float in){
return wd*logf(in*step) + min;
}
float Ssqrt(float in){
return in*in*step*step + min;
}
float Spow(float in){
return sqrtf(in*step) + min;
}
if(!scale) return FALSE;
*scale = calloc(M, sizeof(float));
if(!*scale) return FALSE;
switch(f->h){
case LOG:
scalefn = Slog; step = logf(wd+1.)/Nsteps;
break;
case EXP:
scalefn = Sexp; step = expf(1.)/Nsteps;
break;
case SQRT:
scalefn = Ssqrt; step = sqrtf(wd)/Nsteps;
break;
case POW:
scalefn = Spow; step = wd*wd/Nsteps;
break;
default:
scalefn = Suniform; step = wd/Nsteps;
}
for(y = 0; y < M; y++){
(*scale)[y] = scalefn(y+1);
DBG("level %d: I=%g", y, (*scale)[y]);
}
return TRUE;
}
/* /*
* Threshold filtering ("posterization") * Threshold filtering ("posterization")

View File

@ -19,6 +19,7 @@
#include "contours.h" #include "contours.h"
#include "opengl.h" #include "opengl.h"
#include "imtools.h"
// contours' minimum size limits // contours' minimum size limits
const int MIN_CONTOUR_SIZE = 4; const int MIN_CONTOUR_SIZE = 4;

Binary file not shown.

View File

@ -636,3 +636,58 @@ void filter_image( Window *window,
force_redraw(window->drawingArea); force_redraw(window->drawingArea);
} }
/*
* Fill isolines' scale (an array)
* Input:
* f - filter for given method
* min - minimum value of intensity
* wd - max-min (dinamic range)
* Output:
* scale - a pointer to array (allocated in this function)
*/
int fillIsoScale(Filter *f, float **scale, float min, float wd){
int M = f->w, y;
float (*scalefn)(float in);
float step, Nsteps = (float)f->w; // amount of intervals
float Suniform(float in){
return step*in + min;
}
float Slog(float in){
return expf(in*step) + min - 1.;
}
float Sexp(float in){
return wd*logf(in*step) + min;
}
float Ssqrt(float in){
return in*in*step*step + min;
}
float Spow(float in){
return sqrtf(in*step) + min;
}
if(!scale) return FALSE;
*scale = calloc(M, sizeof(float));
if(!*scale) return FALSE;
switch(f->h){
case LOG:
scalefn = Slog; step = logf(wd+1.)/Nsteps;
break;
case EXP:
scalefn = Sexp; step = expf(1.)/Nsteps;
break;
case SQRT:
scalefn = Ssqrt; step = sqrtf(wd)/Nsteps;
break;
case POW:
scalefn = Spow; step = wd*wd/Nsteps;
break;
default:
scalefn = Suniform; step = wd/Nsteps;
}
for(y = 0; y < M; y++){
(*scale)[y] = scalefn(y+1);
DBG("level %d: I=%g", y, (*scale)[y]);
}
return TRUE;
}

View File

@ -45,7 +45,6 @@ enum{
EXTERN int fill_hough_lines(float *ima, float min, float max, int imW, int imH, int Rmax, int angles, float *hough); EXTERN int fill_hough_lines(float *ima, float min, float max, int imW, int imH, int Rmax, int angles, float *hough);
EXTERN int DiffFilter(float *ima, float **result, Filter *f, int sizex, int sizey); EXTERN int DiffFilter(float *ima, float **result, Filter *f, int sizex, int sizey);
EXTERN int MedFilter(float *ima, float **result, Filter *f, int sizex, int sizey); EXTERN int MedFilter(float *ima, float **result, Filter *f, int sizex, int sizey);
EXTERN int fillIsoScale(Filter *f, float **scale, float min, float wd);
EXTERN int StepFilter(float *ima, float **result, Filter *f, int sizex, int sizey, float min, float max, float **scale); EXTERN int StepFilter(float *ima, float **result, Filter *f, int sizex, int sizey, float min, float max, float **scale);
EXTERN int GradFilterSimple(float *ima, float **result, Filter *f, int sizex, int sizey); EXTERN int GradFilterSimple(float *ima, float **result, Filter *f, int sizex, int sizey);
#endif // _CUTOOLS_H_ #endif // _CUTOOLS_H_

View File

@ -16,4 +16,5 @@ void get_circles_params(Window *window, IMAGE *ima);
void hough_lines(Window *window); void hough_lines(Window *window);
void get_houg_line(Window *window, double x, double y, double *phi_, double *R_); void get_houg_line(Window *window, double x, double y, double *phi_, double *R_);
void filter_image(Window *window, Filter *f); void filter_image(Window *window, Filter *f);
int fillIsoScale(Filter *f, float **scale, float min, float wd);
#endif // _IMTOOLS_H_ #endif // _IMTOOLS_H_