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 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);
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")

View File

@ -1,17 +1,17 @@
// contours.c - find isophotos
//
//
// Copyright 2011 Edward V. Emelianoff <eddy@sao.ru>
//
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
@ -19,6 +19,7 @@
#include "contours.h"
#include "opengl.h"
#include "imtools.h"
// contours' minimum size limits
const int MIN_CONTOUR_SIZE = 4;
@ -174,7 +175,7 @@ int directions[16] = {
int dxdy[9][2] = {
{0 , 0}, // 0
{1 , 0}, // D_RIGHT
{-1, 0}, // D_LEFT
{-1, 0}, // D_LEFT
{0 , 0},
{0 , 1}, // D_DOWN
{0 , 0},
@ -186,7 +187,7 @@ int dxdy[9][2] = {
int newdirs[16][2] = {
{0, 0}, // 0
{D_RIGHT,D_RIGHT},// D_RIGHT
{D_LEFT, D_LEFT}, // D_LEFT
{D_LEFT, D_LEFT}, // D_LEFT
{D_RIGHT, D_LEFT},// D_RIGHT | D_LEFT
{D_DOWN, D_DOWN}, // D_DOWN
{D_RIGHT, D_DOWN},// D_DOWN | D_RIGHT
@ -194,7 +195,7 @@ int newdirs[16][2] = {
{D_RIGHT, D_LEFT},// D_DOWN | D_RIGHT | D_LEFT
{D_UP, D_UP}, // D_UP
{D_RIGHT, D_UP}, // D_UP | D_RIGHT
{D_LEFT, D_UP}, // D_UP | D_LEFT
{D_LEFT, D_UP}, // D_UP | D_LEFT
{D_RIGHT, D_UP}, // D_UP | D_RIGHT | D_LEFT
{D_DOWN, D_UP}, // D_UP | D_DOWN
{D_RIGHT, D_UP}, // D_UP | D_DOWN | D_RIGHT
@ -387,7 +388,7 @@ int process_it_(int x, int y, int lvl, float *imdata, unsigned char *mask){
Contour *cCur;
unsigned char pt0 = mask[y*w1+x];
if(pt0 == 0 || pt0 > 14) return TRUE;;
do{
do{
if(!contours[lvl]){ // countour wasn't created - create it
contours[lvl] = new_clist(lvl);
if(!contours[lvl]){

Binary file not shown.

View File

@ -636,3 +636,58 @@ void filter_image( Window *window,
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 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 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 GradFilterSimple(float *ima, float **result, Filter *f, int sizex, int sizey);
#endif // _CUTOOLS_H_

View File

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