[GRASS-SVN] r34872 - grass/trunk/imagery/i.smap
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Dec 14 09:40:10 EST 2008
Author: martinl
Date: 2008-12-14 09:40:10 -0500 (Sun, 14 Dec 2008)
New Revision: 34872
Modified:
grass/trunk/imagery/i.smap/bouman.h
grass/trunk/imagery/i.smap/decimate.c
grass/trunk/imagery/i.smap/interp.c
grass/trunk/imagery/i.smap/parse.c
grass/trunk/imagery/i.smap/region.h
grass/trunk/imagery/i.smap/segment.c
Log:
i.smap: remove quiet flag, use G_debug()
Modified: grass/trunk/imagery/i.smap/bouman.h
===================================================================
--- grass/trunk/imagery/i.smap/bouman.h 2008-12-14 14:29:09 UTC (rev 34871)
+++ grass/trunk/imagery/i.smap/bouman.h 2008-12-14 14:40:10 UTC (rev 34872)
@@ -24,7 +24,6 @@
char *subgroup;
char *sigfile;
int blocksize;
- int quiet;
int ml;
};
Modified: grass/trunk/imagery/i.smap/decimate.c
===================================================================
--- grass/trunk/imagery/i.smap/decimate.c 2008-12-14 14:29:09 UTC (rev 34871)
+++ grass/trunk/imagery/i.smap/decimate.c 2008-12-14 14:40:10 UTC (rev 34872)
@@ -11,8 +11,7 @@
void make_pyramid(LIKELIHOOD **** ll_pym, /* log likelihood pyramid, ll_pym[scale][i][j][class] */
struct Region *region, /* specifies image subregion */
int M, /* number of classes */
- double *alpha, /* decimation parameters */
- int vlevel /* verbose operation */
+ double *alpha /* decimation parameters */
)
{
int D;
@@ -25,9 +24,8 @@
D = 0;
reg_to_wdht(region, &wd, &ht);
while ((wd > 2) && (ht > 2)) {
- if (vlevel >= 2)
- G_debug(1, "D = %d alpha = %f; 1-alpha = %f", D, alpha[D],
- 1 - alpha[D]);
+ G_debug(1, "D = %d alpha = %f; 1-alpha = %f", D, alpha[D],
+ 1 - alpha[D]);
decimate(ll_pym[D], region, M, ll_pym[D + 1], alpha[D]);
dec_reg(region);
reg_to_wdht(region, &wd, &ht);
Modified: grass/trunk/imagery/i.smap/interp.c
===================================================================
--- grass/trunk/imagery/i.smap/interp.c 2008-12-14 14:29:09 UTC (rev 34871)
+++ grass/trunk/imagery/i.smap/interp.c 2008-12-14 14:40:10 UTC (rev 34872)
@@ -9,7 +9,7 @@
#define ML_PRECISION 1e-6
static void seq_MAP_routine(unsigned char ***, struct Region *,
- LIKELIHOOD ****, int, double *, int);
+ LIKELIHOOD ****, int, double *);
static double alpha_dec_max(double ***);
static void print_N(double ***);
static void print_alpha(double *);
@@ -24,8 +24,7 @@
struct Region *region, /* specifies image subregion */
LIKELIHOOD **** ll_pym, /* pyramid of class statistics */
int M, /* number of classes */
- double *alpha_dec, /* decimation parameters returned by seq_MAP */
- int vlevel /* verbose output */
+ double *alpha_dec /* decimation parameters returned by seq_MAP */
)
{
int repeat;
@@ -33,12 +32,11 @@
/* Repeat segmentation to get values for alpha_dec */
for (repeat = 0; repeat < 2; repeat++) {
/* Construct image log likelihood pyramid */
- make_pyramid(ll_pym, region, M, alpha_dec, vlevel);
- if (vlevel >= 2)
- G_message(_("pyramid constructed."));
+ make_pyramid(ll_pym, region, M, alpha_dec);
+ G_debug(1, "Pyramid constructed");
/* Perform sequential MAP segmentation using EM algorithm */
- seq_MAP_routine(sf_pym, region, ll_pym, M, alpha_dec, vlevel);
+ seq_MAP_routine(sf_pym, region, ll_pym, M, alpha_dec);
}
}
@@ -46,8 +44,7 @@
struct Region *region, /* specifies image subregion */
LIKELIHOOD **** ll_pym, /* pyramid of class statistics */
int M, /* number of classes */
- double *alpha_dec, /* decimation parameters returned by seq_MAP */
- int vlevel /* verbose output */
+ double *alpha_dec /* decimation parameters returned by seq_MAP */
)
{
int j, k; /* loop index */
@@ -99,30 +96,24 @@
/* Interpolate the classification at each resolution */
for (D--; D >= 0; D--) {
- if (vlevel >= 2)
- G_debug(1, "Resolution = %d; period = %d", D, period[D]);
+ G_debug(1, "Resolution = %d; period = %d", D, period[D]);
for (j = 0; j < 3; j++)
alpha[j] *= (1 - EM_PRECISION * 10);
- if (vlevel >= 4)
- print_alpha(alpha);
+ print_alpha(alpha);
/* Apply EM algorithm to estimate alpha. Continue for *
* fixed number of iterations or until convergence. */
do {
interp(sf_pym[D], &(regionary[D]), sf_pym[D + 1], ll_pym[D], M,
alpha, period[D], N, 1);
- if (vlevel >= 4)
- print_N(N);
- if (vlevel >= 4)
- G_debug(1, "log likelihood = %f", log_like(N, alpha, M));
+ print_N(N);
+ G_debug(4, "log likelihood = %f", log_like(N, alpha, M));
for (j = 0; j < 3; j++)
tmp[j] = alpha[j];
alpha_max(N, alpha, M, ML_PRECISION);
- if (vlevel >= 2)
- print_alpha(alpha);
- if (vlevel >= 4)
- G_debug(1, "log likelihood = %f", log_like(N, alpha, M));
+ print_alpha(alpha);
+ G_debug(4, "log likelihood = %f", log_like(N, alpha, M));
for (diff1 = j = 0; j < 3; j++)
diff1 += fabs(tmp[j] - alpha[j]);
@@ -132,12 +123,9 @@
1, N, 0);
alpha_dec[D] = alpha_dec_max(N);
- if (vlevel >= 4)
- print_N(N);
- if (vlevel >= 2) {
- alpha_max(N, alpha, M, ML_PRECISION);
- print_alpha(alpha);
- }
+ print_N(N);
+ alpha_max(N, alpha, M, ML_PRECISION);
+ print_alpha(alpha);
}
/* free up N */
@@ -188,7 +176,7 @@
/* prints out transition parameters. */
double *alpha)
{
- G_debug(1, "Transition probabilities: %f %f %f; %f",
+ G_debug(2, "Transition probabilities: %f %f %f; %f",
alpha[0], alpha[1], alpha[2],
1.0 - alpha[0] - 2 * alpha[1] - alpha[2]);
}
Modified: grass/trunk/imagery/i.smap/parse.c
===================================================================
--- grass/trunk/imagery/i.smap/parse.c 2008-12-14 14:29:09 UTC (rev 34871)
+++ grass/trunk/imagery/i.smap/parse.c 2008-12-14 14:40:10 UTC (rev 34872)
@@ -9,7 +9,6 @@
{
struct Option *group, *subgroup, *sigfile, *output;
struct Option *blocksize;
- struct Flag *quiet;
struct Flag *ml;
group = G_define_standard_option(G_OPT_I_GROUP);
@@ -38,14 +37,9 @@
ml->description =
_("Use maximum likelihood estimation (instead of smap)");
- quiet = G_define_flag();
- quiet->key = 'q';
- quiet->description = _("Run quietly");
-
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
- parms->quiet = quiet->answer;
parms->ml = ml->answer;
parms->output_map = output->answer;
Modified: grass/trunk/imagery/i.smap/region.h
===================================================================
--- grass/trunk/imagery/i.smap/region.h 2008-12-14 14:29:09 UTC (rev 34871)
+++ grass/trunk/imagery/i.smap/region.h 2008-12-14 14:40:10 UTC (rev 34872)
@@ -12,7 +12,7 @@
};
/* decimate.c */
-void make_pyramid(LIKELIHOOD ****, struct Region *, int, double *, int);
+void make_pyramid(LIKELIHOOD ****, struct Region *, int, double *);
char ***get_pyramid(int, int, size_t);
void free_pyramid(char *, int, int);
char ****get_cubic_pyramid(int, int, int, size_t);
@@ -21,7 +21,7 @@
/* interp.c */
void seq_MAP(unsigned char ***, struct Region *, LIKELIHOOD ****, int,
- double *, int);
+ double *);
void MLE(unsigned char **, LIKELIHOOD ***, struct Region *, int);
/* reg_util.c */
Modified: grass/trunk/imagery/i.smap/segment.c
===================================================================
--- grass/trunk/imagery/i.smap/segment.c 2008-12-14 14:29:09 UTC (rev 34871)
+++ grass/trunk/imagery/i.smap/segment.c 2008-12-14 14:40:10 UTC (rev 34872)
@@ -31,8 +31,7 @@
{
int block_size; /* size of subregion blocks */
int ml; /* max likelihood? */
- int quiet; /* be quiet when running? */
-
+
DCELL ***img; /* multispectral image, img[band][i][j] */
int last_row;
int wd, ht; /* image width and height */
@@ -43,14 +42,11 @@
unsigned char ***sf_pym; /* pyramid of segmentations */
int D; /* number of levels in pyramid */
double *alpha_dec; /* class transition probabilities */
- int vlevel; /* level of verbose output */
int i;
- quiet = parms->quiet; /* run quietly? */
ml = parms->ml; /* use maxl? */
block_size = parms->blocksize;
- vlevel = quiet ? 0 : 1;
wd = G_window_cols(); /* get width from GRASS */
ht = G_window_rows(); /* get height from GRASS */
@@ -91,7 +87,7 @@
extract_init(S);
last_row = -1;
do {
- if (vlevel >= 1 && last_row != region.ymin)
+ if (last_row != region.ymin)
G_message(_("Processing rows %d-%d (of %d)..."),
region.ymin + 1, region.ymax, ht);
last_row = region.ymin;
@@ -107,7 +103,7 @@
else {
for (i = 0; i < D; i++)
alpha_dec[i] = 1.0;
- seq_MAP(sf_pym, ®ion, ll_pym, nclasses, alpha_dec, vlevel);
+ seq_MAP(sf_pym, ®ion, ll_pym, nclasses, alpha_dec);
}
More information about the grass-commit
mailing list