[GRASS-SVN] r34870 - in grass/trunk: imagery/i.cluster
imagery/i.gensig imagery/i.gensigset imagery/i.maxlik
imagery/i.smap/bouman imagery/i.smap/shapiro raster/r.composite
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Dec 14 09:20:47 EST 2008
Author: martinl
Date: 2008-12-14 09:20:47 -0500 (Sun, 14 Dec 2008)
New Revision: 34870
Modified:
grass/trunk/imagery/i.cluster/main.c
grass/trunk/imagery/i.gensig/check.c
grass/trunk/imagery/i.gensig/covariance.c
grass/trunk/imagery/i.gensig/get_train.c
grass/trunk/imagery/i.gensig/main.c
grass/trunk/imagery/i.gensig/means.c
grass/trunk/imagery/i.gensig/openfiles.c
grass/trunk/imagery/i.gensig/parse.c
grass/trunk/imagery/i.gensig/read_train.c
grass/trunk/imagery/i.gensig/write_sig.c
grass/trunk/imagery/i.gensigset/get_train.c
grass/trunk/imagery/i.gensigset/main.c
grass/trunk/imagery/i.gensigset/openfiles.c
grass/trunk/imagery/i.gensigset/parse.c
grass/trunk/imagery/i.gensigset/read_data.c
grass/trunk/imagery/i.gensigset/read_train.c
grass/trunk/imagery/i.gensigset/subcluster.c
grass/trunk/imagery/i.gensigset/write_sig.c
grass/trunk/imagery/i.maxlik/main.c
grass/trunk/imagery/i.smap/bouman/decimate.c
grass/trunk/imagery/i.smap/bouman/interp.c
grass/trunk/imagery/i.smap/bouman/model.c
grass/trunk/imagery/i.smap/bouman/multialloc.c
grass/trunk/imagery/i.smap/bouman/read_block.c
grass/trunk/imagery/i.smap/bouman/segment.c
grass/trunk/imagery/i.smap/shapiro/closefiles.c
grass/trunk/imagery/i.smap/shapiro/main.c
grass/trunk/imagery/i.smap/shapiro/openfiles.c
grass/trunk/imagery/i.smap/shapiro/parse.c
grass/trunk/imagery/i.smap/shapiro/read_sig.c
grass/trunk/imagery/i.smap/shapiro/write_img.c
grass/trunk/raster/r.composite/main.c
Log:
imagery modules: message/paramaters standardization
(merge from devbr6, r34868)
Modified: grass/trunk/imagery/i.cluster/main.c
===================================================================
--- grass/trunk/imagery/i.cluster/main.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.cluster/main.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -81,14 +81,12 @@
parm.group_name = G_define_standard_option(G_OPT_I_GROUP);
- parm.subgroup_name = G_define_option();
- parm.subgroup_name->key = "subgroup";
- parm.subgroup_name->type = TYPE_STRING;
- parm.subgroup_name->required = YES;
- parm.subgroup_name->description = _("Name of subgroup in the above group");
-
- parm.out_sig = G_define_standard_option(G_OPT_F_OUTPUT);
+ parm.subgroup_name = G_define_standard_option(G_OPT_I_SUBGROUP);
+
+ parm.out_sig = G_define_option();
parm.out_sig->key = "signaturefile";
+ parm.out_sig->type = TYPE_STRING;
+ parm.out_sig->key_desc = "name";
parm.out_sig->required = YES;
parm.out_sig->description = _("Name for output file containing result signatures");
@@ -100,9 +98,11 @@
parm.class->description = _("Initial number of classes");
parm.class->guisection = _("Settings");
- parm.seed_sig = G_define_standard_option(G_OPT_F_INPUT);
+ parm.seed_sig = G_define_option();
parm.seed_sig->key = "seed";
parm.seed_sig->required = NO;
+ parm.seed_sig->type = TYPE_STRING;
+ parm.seed_sig->key_desc = "name";
parm.seed_sig->description = _("Name of file containing initial signatures");
parm.sample_interval = G_define_option();
Modified: grass/trunk/imagery/i.gensig/check.c
===================================================================
--- grass/trunk/imagery/i.gensig/check.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensig/check.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -18,19 +18,19 @@
copy_covariances(temp.sig[0].var, S->sig[i].var, S->nbands);
if (!can_invert(temp.sig[0].var, S->nbands)) {
S->sig[i].status = -1;
- G_message(_("Signature [%d] not invertible."), i + 1);
+ G_important_message(_("Signature %d not invertible"), i + 1);
continue;
}
copy_covariances(temp.sig[0].var, S->sig[i].var, S->nbands);
if (!eigen(temp.sig[0].var, lambda, S->nbands)) {
S->sig[i].status = -1;
- G_message(_("Signature [%d] can't get eigen values."), i + 1);
+ G_important_message(_("Signature %d unable to get eigen values"), i + 1);
continue;
}
for (j = 0; j < S->nbands; j++) {
if (lambda[j] <= 0.0) {
S->sig[i].status = -1;
- G_message(_("Signature [%d] not positive definite."), i + 1);
+ G_important_message(_("Signature %d not positive definite"), i + 1);
break;
}
}
Modified: grass/trunk/imagery/i.gensig/covariance.c
===================================================================
--- grass/trunk/imagery/i.gensig/covariance.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensig/covariance.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -24,10 +24,7 @@
ncols = G_window_cols();
class = (CELL *) G_calloc(ncols, sizeof(CELL));
- if (S->nsigs == 1)
- G_message(_("Calculating class covariance matrix..."));
- else
- G_message(_("Calculating class covariance matrices..."));
+ G_message(_("Calculating class covariance matrices..."));
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
@@ -35,7 +32,8 @@
for (b = 0; b < files->nbands; b++) /* NOTE: files->nbands == S->nbands */
if (G_get_d_raster_row
(files->band_fd[b], files->band_cell[b], row) < 0)
- exit(1);
+ G_fatal_error(_("Unable to read raster map row %d"),
+ row);
for (b1 = 0; b1 < files->nbands; b1++) {
cell1 = files->band_cell[b1];
for (b2 = 0; b2 <= b1; b2++) { /* only need to calculate the lower half */
@@ -52,7 +50,8 @@
}
}
}
- G_percent(row, nrows, 2);
+ G_percent(nrows, nrows, 2);
+
for (n = 0; n < S->nsigs; n++) /* for each signature (aka class) */
for (b1 = 0; b1 < S->nbands; b1++)
for (b2 = 0; b2 <= b1; b2++) {
Modified: grass/trunk/imagery/i.gensig/get_train.c
===================================================================
--- grass/trunk/imagery/i.gensig/get_train.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensig/get_train.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -26,7 +26,7 @@
/* determine the categories in the map */
I_init_signatures(S, files->nbands);
G_init_cell_stats(&cell_stats);
- G_message(_("Finding training classes ..."));
+ G_message(_("Finding training classes..."));
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
if (G_get_c_raster_row(fd, cell, row) < 0)
@@ -34,7 +34,7 @@
row);
G_update_cell_stats(cell, ncols, &cell_stats);
}
- G_percent(row, nrows, 2);
+ G_percent(nrows, nrows, 2);
/* convert this to an array */
G_rewind_cell_stats(&cell_stats);
@@ -51,12 +51,12 @@
n++;
}
else
- G_warning(_("Training class [%d] only has one cell - this class will be ignored."),
+ G_warning(_("Training class %d only has one cell - this class will be ignored"),
cat);
}
if (n == 0)
- G_fatal_error(_("Training map has no classes."));
+ G_fatal_error(_("Training map has no classes"));
list = (CELL *) G_calloc(n, sizeof(CELL));
n = 0;
@@ -71,9 +71,9 @@
files->training_cats = list;
if (files->ncats == 1)
- G_message(_("1 class."));
+ G_message(_("1 class found"));
else
- G_message(_("%d classes."), files->ncats);
+ G_message(_("%d classes found"), files->ncats);
return 0;
}
Modified: grass/trunk/imagery/i.gensig/main.c
===================================================================
--- grass/trunk/imagery/i.gensig/main.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensig/main.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -36,9 +36,9 @@
G_gisinit(argv[0]);
module = G_define_module();
- module->keywords = _("imagery");
+ module->keywords = _("imagery, classification, supervised, MLC");
module->description =
- _("Generates statistics for i.maxlik " "from raster map layer.");
+ _("Generates statistics for i.maxlik from raster map.");
parse(argc, argv, &parms);
openfiles(&parms, &files);
@@ -50,5 +50,7 @@
check_signatures(&S);
write_sigfile(&parms, &S);
- exit(0);
+ G_done_msg(" ");
+
+ exit(EXIT_SUCCESS);
}
Modified: grass/trunk/imagery/i.gensig/means.c
===================================================================
--- grass/trunk/imagery/i.gensig/means.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensig/means.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -22,10 +22,7 @@
ncols = G_window_cols();
class = (CELL *) G_calloc(ncols, sizeof(CELL));
- if (S->nsigs == 1)
- G_message(_("Calculating class mean ..."));
- else
- G_message(_("Calculating class means ..."));
+ G_message(_("Calculating class means..."));
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
@@ -46,7 +43,8 @@
}
}
}
- G_percent(row, nrows, 2);
+ G_percent(nrows, nrows, 2);
+
for (n = 0; n < S->nsigs; n++) /* for each signature (aka class) */
for (b = 0; b < S->nbands; b++) /* for each band file */
S->sig[n].mean[b] /= S->sig[n].npoints;
Modified: grass/trunk/imagery/i.gensig/openfiles.c
===================================================================
--- grass/trunk/imagery/i.gensig/openfiles.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensig/openfiles.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -13,11 +13,11 @@
if (!I_get_subgroup_ref(parms->group, parms->subgroup, &Ref))
- G_fatal_error(_("Unable to read REF file for subgroup [%s] in group [%s]."),
+ G_fatal_error(_("Unable to read REF file for subgroup <%s> in group <%s>"),
parms->subgroup, parms->group);
if (Ref.nfiles <= 0)
- G_fatal_error(_("Subgroup [%s] in group [%s] contains no files."),
+ G_fatal_error(_("Subgroup <%s> in group <%s> contains no raster maps."),
parms->subgroup, parms->group);
/* allocate file descriptors, and array of io buffers */
Modified: grass/trunk/imagery/i.gensig/parse.c
===================================================================
--- grass/trunk/imagery/i.gensig/parse.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensig/parse.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -9,34 +9,22 @@
{
struct Option *group, *subgroup, *sigfile, *trainingmap;
- trainingmap = G_define_option();
+ trainingmap = G_define_standard_option(G_OPT_R_MAP);
trainingmap->key = "trainingmap";
trainingmap->description = _("Ground truth training map");
- trainingmap->required = YES;
- trainingmap->type = TYPE_STRING;
- trainingmap->gisprompt = "old,cell,raster";
- group = G_define_option();
- group->key = "group";
- group->description = _("Imagery group");
- group->required = YES;
- group->type = TYPE_STRING;
- group->gisprompt = "old,group,group";
+ group = G_define_standard_option(G_OPT_I_GROUP);
- subgroup = G_define_option();
- subgroup->key = "subgroup";
- subgroup->description = _("Subgroup containing image files");
- subgroup->required = YES;
- subgroup->type = TYPE_STRING;
+ subgroup = G_define_standard_option(G_OPT_I_SUBGROUP);
sigfile = G_define_option();
sigfile->key = "signaturefile";
- sigfile->description = _("Resultant signature file");
+ sigfile->description = _("Name for output file containing result signatures");
sigfile->required = YES;
sigfile->type = TYPE_STRING;
if (G_parser(argc, argv))
- exit(1);
+ exit(EXIT_FAILURE);
parms->training_map = trainingmap->answer;
parms->group = group->answer;
Modified: grass/trunk/imagery/i.gensig/read_train.c
===================================================================
--- grass/trunk/imagery/i.gensig/read_train.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensig/read_train.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -1,12 +1,14 @@
#include <stdlib.h>
#include <grass/imagery.h>
+#include <grass/glocale.h>
#include "files.h"
#include "local_proto.h"
int read_training_map(CELL * class, int row, int ncols, struct files *files)
{
if (G_get_c_raster_row(files->train_fd, files->train_cell, row) < 0)
- exit(1);
+ G_fatal_error(_("Unable to read raster map row %d"),
+ row);
lookup_class(files->train_cell, ncols, files->training_cats, files->ncats,
class);
Modified: grass/trunk/imagery/i.gensig/write_sig.c
===================================================================
--- grass/trunk/imagery/i.gensig/write_sig.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensig/write_sig.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -12,13 +12,11 @@
fd = I_fopen_signature_file_new(parms->group, parms->subgroup,
parms->sigfile);
if (fd == NULL)
- G_fatal_error(_("Unable to create signature file [%s] for "
- "subgroup [%s] in group [%s]."),
- parms->sigfile, parms->subgroup, parms->group);
-
- G_message(_("Writing signature file [%s] ..."), parms->sigfile);
+ G_fatal_error(_("Unable to create signature file <%s>"),
+ parms->sigfile);
+
+ G_verbose_message(_("Writing signatures..."));
I_write_signatures(fd, S);
- G_message(_("Done."));
return 0;
}
Modified: grass/trunk/imagery/i.gensigset/get_train.c
===================================================================
--- grass/trunk/imagery/i.gensigset/get_train.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensigset/get_train.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/imagery.h>
+#include <grass/glocale.h>
#include "files.h"
#include "parms.h"
@@ -28,14 +29,15 @@
I_SetSigTitle(S, G_get_cats_title(&files->training_labels));
G_init_cell_stats(&cell_stats);
- fprintf(stderr, "Finding training classes ...");
+ G_message(_("Finding training classes..."));
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
if (G_get_c_raster_row(fd, cell, row) < 0)
- exit(1);
+ G_fatal_error(_("Unable to read raster map <%s> row %d"), cell,
+ row);
G_update_cell_stats(cell, ncols, &cell_stats);
}
- G_percent(row, nrows, 2);
+ G_percent(nrows, nrows, 2);
/* convert this to an array */
G_rewind_cell_stats(&cell_stats);
@@ -52,14 +54,12 @@
n++;
}
else
- fprintf(stderr,
- "WARNING: Training class [%d] only has one cell - this class will be ignored\n",
- cat);
+ G_warning(_("Training class %d only has one cell - this class will be ignored"),
+ cat);
}
if (n == 0) {
- fprintf(stderr, "ERROR: training map has no classes\n");
- exit(1);
+ G_fatal_error(_("Training map has no classes"));
}
list = (CELL *) G_calloc(n, sizeof(CELL));
@@ -73,8 +73,11 @@
files->ncats = n;
files->training_cats = list;
- fprintf(stderr, "%d class%s\n", files->ncats,
- files->ncats == 1 ? "" : "es");
+ if (files->ncats == 1)
+ G_message(_("1 class found"));
+ else
+ G_message(_("%d classes found"), files->ncats);
+
return 0;
}
Modified: grass/trunk/imagery/i.gensigset/main.c
===================================================================
--- grass/trunk/imagery/i.gensigset/main.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensigset/main.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -37,9 +37,9 @@
G_gisinit(argv[0]);
module = G_define_module();
- module->keywords = _("imagery");
+ module->keywords = _("imagery, classification, supervised, SMAP");
module->description =
- "Generate statistics for i.smap from raster map layer.";
+ _("Generates statistics for i.smap from raster map.");
parse(argc, argv, &parms);
openfiles(&parms, &files);
@@ -49,12 +49,15 @@
read_data(&files, &S);
for (i = 0; i < S.nclasses; i++) {
- fprintf(stderr, "Clustering class %d, with %d pixels\n",
- i + 1, S.ClassSig[i].ClassData.npixels);
+ G_message(_("Clustering class %d (%d pixels)..."),
+ i + 1, S.ClassSig[i].ClassData.npixels);
subcluster(&S, i, &junk, parms.maxsubclasses);
- fprintf(stderr, " Solution: Number of subclasses is %d\n",
- S.ClassSig[i].nsubclasses);
+ G_message(_("Number of subclasses is %d"),
+ S.ClassSig[i].nsubclasses);
}
write_sigfile(&parms, &S);
- exit(0);
+
+ G_done_msg(" ");
+
+ exit(EXIT_SUCCESS);
}
Modified: grass/trunk/imagery/i.gensigset/openfiles.c
===================================================================
--- grass/trunk/imagery/i.gensigset/openfiles.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensigset/openfiles.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -12,16 +12,12 @@
if (!I_get_subgroup_ref(parms->group, parms->subgroup, &Ref)) {
- fprintf(stderr,
- "ERROR: unable to read REF file for subgroup [%s] in group [%s]\n",
- parms->subgroup, parms->group);
- exit(1);
+ G_fatal_error(_("Unable to read REF file for subgroup <%s> in group <%s>"),
+ parms->subgroup, parms->group);
}
if (Ref.nfiles <= 0) {
- fprintf(stderr,
- "ERROR: subgroup [%s] in group [%s] contains no files\n",
- parms->subgroup, parms->group);
- exit(1);
+ G_fatal_error(_("Subgroup <%s> in group <%s> contains no raster maps."),
+ parms->subgroup, parms->group);
}
/* allocate file descriptors, and array of io buffers */
Modified: grass/trunk/imagery/i.gensigset/parse.c
===================================================================
--- grass/trunk/imagery/i.gensigset/parse.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensigset/parse.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -1,47 +1,36 @@
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/imagery.h>
+#include <grass/glocale.h>
#include "parms.h"
int parse(int argc, char *argv[], struct parms *parms)
{
struct Option *group, *subgroup, *sigfile, *trainingmap, *maxsig;
- trainingmap = G_define_option();
+ trainingmap = G_define_standard_option(G_OPT_R_MAP);
trainingmap->key = "trainingmap";
- trainingmap->description = "ground truth training map";
- trainingmap->required = YES;
- trainingmap->type = TYPE_STRING;
- trainingmap->gisprompt = "old,cell,raster";
+ trainingmap->description = _("Ground truth training map");
+
+ group = G_define_standard_option(G_OPT_I_GROUP);
- group = G_define_option();
- group->key = "group";
- group->description = "imagery group";
- group->required = YES;
- group->type = TYPE_STRING;
- group->gisprompt = "old,group,group";
+ subgroup = G_define_standard_option(G_OPT_I_SUBGROUP);
- subgroup = G_define_option();
- subgroup->key = "subgroup";
- subgroup->description = "subgroup containing image files";
- subgroup->required = YES;
- subgroup->type = TYPE_STRING;
-
sigfile = G_define_option();
sigfile->key = "signaturefile";
- sigfile->description = "resultant signature file";
+ sigfile->description = _("Name for output file containing result signatures");
sigfile->required = YES;
sigfile->type = TYPE_STRING;
maxsig = G_define_option();
maxsig->key = "maxsig";
- maxsig->description = "maximum number of sub-signatures in any class";
+ maxsig->description = _("Maximum number of sub-signatures in any class");
maxsig->required = NO;
maxsig->type = TYPE_INTEGER;
maxsig->answer = "10";
if (G_parser(argc, argv))
- exit(1);
+ exit(EXIT_FAILURE);
parms->training_map = trainingmap->answer;
parms->group = group->answer;
@@ -50,23 +39,18 @@
/* check all the inputs */
if (G_find_cell(parms->training_map, "") == NULL) {
- fprintf(stderr, "ERROR: training map [%s] not found\n",
- parms->training_map);
- exit(1);
+ G_fatal_error(_("Raster map <%s> not found"), parms->training_map);
}
if (!I_find_group(parms->group)) {
- fprintf(stderr, "ERROR: group [%s] not found\n", parms->group);
- exit(1);
+ G_fatal_error(_("Group <%s> not found"), parms->group);
}
if (!I_find_subgroup(parms->group, parms->subgroup)) {
- fprintf(stderr, "ERROR: subgroup [%s] not found\n", parms->subgroup);
- exit(1);
+ G_fatal_error(_("Subgroup <%s> not found"), parms->subgroup);
}
if (sscanf(maxsig->answer, "%d", &parms->maxsubclasses) != 1 ||
parms->maxsubclasses <= 0) {
- fprintf(stderr, "ERROR: illegal number of sub-signatures [%s]\n",
- maxsig->answer);
- exit(1);
+ G_fatal_error(_("Illegal number of sub-signatures (%s)"),
+ maxsig->answer);
}
return 0;
Modified: grass/trunk/imagery/i.gensigset/read_data.c
===================================================================
--- grass/trunk/imagery/i.gensigset/read_data.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensigset/read_data.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/imagery.h>
+#include <grass/glocale.h>
#include "files.h"
/* #include "local_proto.h" */
@@ -15,7 +16,7 @@
ncols = G_window_cols();
class = (CELL *) G_calloc(ncols, sizeof(CELL));
- fprintf(stderr, "Reading image data ...");
+ G_message(_("Reading raster maps..."));
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
@@ -23,7 +24,8 @@
for (b = 0; b < files->nbands; b++)
if (G_get_d_raster_row
(files->band_fd[b], files->band_cell[b], row) < 0)
- exit(1);
+ G_fatal_error(_("Unable to read raster map row %d"),
+ row);
for (col = 0; col < ncols; col++) {
n = class[col];
@@ -39,7 +41,7 @@
Data->count++;
}
}
- G_percent(row, nrows, 2);
+ G_percent(nrows, nrows, 2);
G_free(class);
return 0;
Modified: grass/trunk/imagery/i.gensigset/read_train.c
===================================================================
--- grass/trunk/imagery/i.gensigset/read_train.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensigset/read_train.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -1,12 +1,14 @@
#include <stdlib.h>
#include <grass/imagery.h>
+#include <grass/glocale.h>
#include "files.h"
#include "local_proto.h"
int read_training_map(CELL * class, int row, int ncols, struct files *files)
{
if (G_get_c_raster_row(files->train_fd, files->train_cell, row) < 0)
- exit(1);
+ G_fatal_error(_("Unable to read raster map row %d"),
+ row);
lookup_class(files->train_cell, ncols, files->training_cats, files->ncats,
class);
Modified: grass/trunk/imagery/i.gensigset/subcluster.c
===================================================================
--- grass/trunk/imagery/i.gensigset/subcluster.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensigset/subcluster.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -2,9 +2,9 @@
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/imagery.h>
+#include <grass/glocale.h>
#include "local_proto.h"
-#define PI M_PI
#define ZERO 1e-10
#define SMALLEST_SUBCLUST 1
@@ -19,8 +19,6 @@
static void add_SubSigs();
static void copy_ClassSig();
static void copy_SubSig();
-static void list_Sig();
-static void print_class();
static int total_nulls, *n_nulls;
@@ -66,15 +64,15 @@
/* compute number of data points */
ndata_points = Sig->ClassData.npixels * nbands - total_nulls;
if (ndata_points <= 1)
- G_fatal_error("Not enough data points!");
+ G_fatal_error("Not enough data points");
/* Check for too few pixels */
*Max_num = (ndata_points + 1) / nparams_clust - 1;
if (maxsubclasses > *Max_num / 2)
maxsubclasses = *Max_num / 2;
if (maxsubclasses < 1) {
- fprintf(stderr, "\nWarning: Not enough pixels in class %d\n",
- Class_Index + 1);
+ G_warning(_("Not enough pixels in class %d"),
+ Class_Index + 1);
Sig->nsubclasses = 0;
Sig->used = 0;
return;
@@ -83,10 +81,10 @@
/* check for too many subclasses */
if (Sig->nsubclasses > maxsubclasses) {
Sig->nsubclasses = maxsubclasses;
- fprintf(stderr, "\nWarning: Too many subclasses for class index %d\n",
- Class_Index + 1);
- fprintf(stderr, " number of subclasses set to %d\n\n",
- Sig->nsubclasses);
+ G_warning(_("Too many subclasses for class index %d"),
+ Class_Index + 1);
+ G_message(_("Number of subclasses set to %d"),
+ Sig->nsubclasses);
}
@@ -95,16 +93,16 @@
/* EM algorithm */
min_riss = refine_clusters(Sig, nbands);
- fprintf(stderr, "Subclasses = %d; Rissanen = %f; ", Sig->nsubclasses,
- min_riss);
+ G_debug(1, "Subclasses = %d Rissanen = %f", Sig->nsubclasses,
+ min_riss);
copy_ClassSig(Sig, min_Sig, nbands);
while (Sig->nsubclasses > 1) {
reduce_order(Sig, nbands, &min_i, &min_j);
- fprintf(stderr, "Combining Subclasses (%d,%d)\n", min_i + 1,
- min_j + 1);
-
+ G_verbose_message(_("Combining subclasses (%d,%d)..."), min_i + 1,
+ min_j + 1);
+
rissanen = refine_clusters(Sig, nbands);
- fprintf(stderr, "Subclasses = %d; Rissanen = %f; ", Sig->nsubclasses,
+ G_debug(1, "Subclasses = %d; Rissanen = %f", Sig->nsubclasses,
rissanen);
if (rissanen < min_riss) {
min_riss = rissanen;
@@ -310,9 +308,9 @@
}
/* For small subclusters */
else {
- fprintf(stderr, "Warning: subsignature %d only contains ", i);
- fprintf(stderr, " %f pixels\n", Sig->SubSig[i].N);
-
+ G_warning(_("Subsignature %d only contains %f pixels"),
+ i, Sig->SubSig[i].N);
+
Sig->SubSig[i].pi = 0;
for (b1 = 0; b1 < nbands; b1++)
@@ -545,8 +543,8 @@
if (Sig->nsubclasses == 1) {
Sig->nsubclasses--;
singular = 2;
- fprintf(stderr, "\nError: unreliable clustering\n");
- fprintf(stderr, "try a smaller initial number of clusters\n");
+ G_warning(_("Unreliable clustering. "
+ "Try a smaller initial number of clusters"));
}
else {
for (j = i; j < Sig->nsubclasses - 1; j++)
@@ -554,17 +552,15 @@
nbands);
Sig->nsubclasses--;
singular = 1;
- fprintf(stderr,
- "Warning: Removed a singular subsignature; number %d;",
- i + 1);
- fprintf(stderr, " %d remain\n", Sig->nsubclasses);
+ G_warning(_("Removed a singular subsignature number %d (%d remain)"),
+ i + 1, Sig->nsubclasses);
if (Sig->nsubclasses < 0) /* MN added 12/2001: to avoid endless loop */
Sig->nsubclasses = 1;
}
}
else {
Sig->SubSig[i].cnst =
- (-nbands / 2.0) * log(2 * PI) - 0.5 * log(det);
+ (-nbands / 2.0) * log(2 * M_PI) - 0.5 * log(det);
i++;
}
} while (i < Sig->nsubclasses);
@@ -654,42 +650,3 @@
}
}
-static void list_Sig(struct ClassSig *Sig, int nbands)
-{
- int i, j, k;
-
- for (i = 0; i < Sig->nsubclasses; i++) {
- fprintf(stderr, "Subclass %d: pi = %f, ", i + 1, Sig->SubSig[i].pi);
- fprintf(stderr, "cnst = %f\n", Sig->SubSig[i].cnst);
- for (j = 0; j < nbands; j++) {
- fprintf(stderr, "%f; ", Sig->SubSig[i].means[j]);
- for (k = 0; k < nbands; k++)
- fprintf(stderr, "%f ", Sig->SubSig[i].R[j][k]);
- fprintf(stderr, "\n");
- }
- fprintf(stderr, "\n");
- }
-}
-
-
-static void print_class(struct ClassSig *Sig, char *fname)
-{
- FILE *fp;
- int s, i;
-
-
- if ((fp = fopen(fname, "w")) == NULL) {
- fprintf(stderr, "can't open data file\n");
- exit(1);
- }
-
- for (s = 0; s < Sig->ClassData.npixels; s++) {
- /* fprintf(fp,"Pixel number %d: ", s); */
- for (i = 0; i < Sig->nsubclasses; i++)
- fprintf(fp, "%f ", Sig->ClassData.p[s][i]);
- fprintf(fp, "\n");
- }
-
- fclose(fp);
-
-}
Modified: grass/trunk/imagery/i.gensigset/write_sig.c
===================================================================
--- grass/trunk/imagery/i.gensigset/write_sig.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.gensigset/write_sig.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/imagery.h>
+#include <grass/glocale.h>
#include "parms.h"
int write_sigfile(struct parms *parms, struct SigSet *S)
@@ -9,17 +10,12 @@
fd = I_fopen_sigset_file_new(parms->group, parms->subgroup,
parms->sigfile);
if (fd == NULL) {
- fprintf(stderr, "ERROR: unable to create signature file [%s] ",
- parms->sigfile);
- fprintf(stderr, "for subgroup [%s] in group [%s]\n", parms->subgroup,
- parms->group);
- exit(1);
- }
- fprintf(stderr, "Writing signature file [%s] ...", parms->sigfile);
- fflush(stderr);
+ G_fatal_error(_("Unable to create signature file <%s>"),
+ parms->sigfile);
+ }
+ G_verbose_message(_("Writing signatures..."));
I_WriteSigSet(fd, S);
fclose(fd);
- fprintf(stderr, "\n");
return 0;
}
Modified: grass/trunk/imagery/i.maxlik/main.c
===================================================================
--- grass/trunk/imagery/i.maxlik/main.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.maxlik/main.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -56,7 +56,7 @@
G_gisinit(argv[0]);
module = G_define_module();
- module->keywords = _("imagery, classification");
+ module->keywords = _("imagery, classification, MLC");
module->label =
_("Classifies the cell spectral reflectances in imagery data.");
module->description =
@@ -65,15 +65,13 @@
parm.group = G_define_standard_option(G_OPT_I_GROUP);
- parm.subgroup = G_define_option();
- parm.subgroup->key = "subgroup";
- parm.subgroup->type = TYPE_STRING;
- parm.subgroup->required = YES;
- parm.subgroup->description = _("Name of subgroup in the above group");
+ parm.subgroup = G_define_standard_option(G_OPT_I_SUBGROUP);
- parm.sigfile = G_define_standard_option(G_OPT_F_INPUT);
+ parm.sigfile = G_define_option();
parm.sigfile->key = "sigfile";
parm.sigfile->required = YES;
+ parm.sigfile->type = TYPE_STRING;
+ parm.sigfile->key_desc = "name";
parm.sigfile->label = _("Name of file containing signatures");
parm.sigfile->description = _("Generated by either i.cluster, i.class, or i.gensig");
@@ -104,7 +102,7 @@
ncols = G_window_cols();
for (row = 0; row < nrows; row++) {
- G_percent(row+1, nrows, 2);
+ G_percent(row, nrows, 2);
for (band = 0; band < Ref.nfiles; band++)
if (G_get_d_raster_row(cellfd[band], cell[band], row) < 0)
@@ -116,7 +114,8 @@
if (reject_fd > 0)
G_put_raster_row(reject_fd, reject_cell, CELL_TYPE);
}
-
+ G_percent(nrows, nrows, 2);
+
G_close_cell(class_fd);
if (reject_fd > 0)
G_close_cell(reject_fd);
Modified: grass/trunk/imagery/i.smap/bouman/decimate.c
===================================================================
--- grass/trunk/imagery/i.smap/bouman/decimate.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.smap/bouman/decimate.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -26,8 +26,8 @@
reg_to_wdht(region, &wd, &ht);
while ((wd > 2) && (ht > 2)) {
if (vlevel >= 2)
- G_message("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/bouman/interp.c
===================================================================
--- grass/trunk/imagery/i.smap/bouman/interp.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.smap/bouman/interp.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -100,7 +100,7 @@
/* Interpolate the classification at each resolution */
for (D--; D >= 0; D--) {
if (vlevel >= 2)
- G_message(_("\nResolution = %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);
@@ -114,7 +114,7 @@
if (vlevel >= 4)
print_N(N);
if (vlevel >= 4)
- G_message("log likelihood = %f\n", log_like(N, alpha, M));
+ G_debug(1, "log likelihood = %f", log_like(N, alpha, M));
for (j = 0; j < 3; j++)
tmp[j] = alpha[j];
@@ -122,7 +122,7 @@
if (vlevel >= 2)
print_alpha(alpha);
if (vlevel >= 4)
- G_message("log likelihood = %f\n", log_like(N, alpha, M));
+ G_debug(1, "log likelihood = %f", log_like(N, alpha, M));
for (diff1 = j = 0; j < 3; j++)
diff1 += fabs(tmp[j] - alpha[j]);
@@ -174,14 +174,12 @@
{
int n0, n1, n2;
- G_message(_("Class transition statistics."));
+ G_debug(2, "Class transition statistics");
for (n0 = 0; n0 < 2; n0++) {
for (n1 = 0; n1 < 3; n1++) {
for (n2 = 0; n2 < 2; n2++)
- fprintf(stderr, "%f ", N[n0][n1][n2]);
- fprintf(stderr, "\n");
+ G_debug(3, " %f", N[n0][n1][n2]);
}
- fprintf(stderr, "\n");
}
}
@@ -190,9 +188,9 @@
/* prints out transition parameters. */
double *alpha)
{
- G_message(_("Transition probabilities: %f %f %f; %f"),
- alpha[0], alpha[1], alpha[2],
- 1.0 - alpha[0] - 2 * alpha[1] - alpha[2]);
+ G_debug(1, "Transition probabilities: %f %f %f; %f",
+ alpha[0], alpha[1], alpha[2],
+ 1.0 - alpha[0] - 2 * alpha[1] - alpha[2]);
}
@@ -236,7 +234,7 @@
alpha2 = alpha[2];
Constant = (1 - alpha0 - 2 * alpha1 - alpha2) / M;
if (Constant < 0)
- G_fatal_error(_("interp: invalid parameter values."));
+ G_fatal_error(_("Invalid parameter values"));
/* precompute logs and zero static vector */
for (nn0 = 0; nn0 < 2; nn0++)
Modified: grass/trunk/imagery/i.smap/bouman/model.c
===================================================================
--- grass/trunk/imagery/i.smap/bouman/model.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.smap/bouman/model.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -35,7 +35,7 @@
for (b1 = 0; b1 < nbands; b1++)
for (b2 = 0; b2 < nbands; b2++) {
if (SubS->R[b1][b2] != SubS->R[b2][b1])
- G_warning(_("\nNonsymetric covariance for class [%d] subclass [%d]."),
+ G_warning(_("Nonsymetric covariance for class %d subclass %d"),
m + 1, i + 1);
SubS->Rinv[b1][b2] = SubS->R[b1][b2];
@@ -45,7 +45,7 @@
eigen(SubS->Rinv, lambda, nbands);
for (b1 = 0; b1 < nbands; b1++) {
if (lambda[b1] <= 0.0)
- G_warning(_("Nonpositive eigenvalues for class [%d] subclass [%d]."),
+ G_warning(_("Nonpositive eigenvalues for class %d subclass %d"),
m + 1, i + 1);
}
Modified: grass/trunk/imagery/i.smap/bouman/multialloc.c
===================================================================
--- grass/trunk/imagery/i.smap/bouman/multialloc.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.smap/bouman/multialloc.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -112,7 +112,7 @@
char *pt;
if ((pt = multialloc(size, 2, ht, wd)) == NULL)
- G_fatal_error(_("get_img: out of memory."));
+ G_fatal_error(_("Out of memory"));
return ((unsigned char **)pt);
}
Modified: grass/trunk/imagery/i.smap/bouman/read_block.c
===================================================================
--- grass/trunk/imagery/i.smap/bouman/read_block.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.smap/bouman/read_block.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <grass/imagery.h>
+#include <grass/glocale.h>
#include "bouman.h"
#include "region.h"
@@ -12,7 +13,8 @@
for (row = region->ymin; row < region->ymax; row++) {
if (G_get_d_raster_row(files->band_fd[band], files->cellbuf, row)
< 0)
- exit(1);
+ G_fatal_error(_("Unable to read raster map row %d"),
+ row);
for (col = region->xmin; col < region->xmax; col++)
img[band][row][col] = files->cellbuf[col];
}
Modified: grass/trunk/imagery/i.smap/bouman/segment.c
===================================================================
--- grass/trunk/imagery/i.smap/bouman/segment.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.smap/bouman/segment.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -34,6 +34,7 @@
int quiet; /* be quiet when running? */
DCELL ***img; /* multispectral image, img[band][i][j] */
+ int last_row;
int wd, ht; /* image width and height */
struct Region region; /* specifies image subregion */
int nbands; /* number of bands */
@@ -66,7 +67,7 @@
/* Check for too many classes */
if (nclasses > 256)
- G_fatal_error(_("Number of classes must be < 256!"));
+ G_fatal_error(_("Number of classes must be < 256"));
/* allocate alpha_dec parameters */
D = levels(block_size, block_size);
@@ -88,11 +89,12 @@
/* tiled segmentation */
init_reg(®ion, wd, ht, block_size);
extract_init(S);
+ last_row = -1;
do {
- if (vlevel >= 1)
- G_message(_("Processing rows %d-%d (of %d), cols=%d-%d (of %d)"),
- region.ymin + 1, region.ymax, ht,
- region.xmin + 1, region.xmax, wd);
+ if (vlevel >= 1 && last_row != region.ymin)
+ G_message(_("Processing rows %d-%d (of %d)..."),
+ region.ymin + 1, region.ymax, ht);
+ last_row = region.ymin;
shift_img(img, nbands, ®ion, block_size);
/* this reads grass images into the block defined in region */
read_block(img, ®ion, files);
Modified: grass/trunk/imagery/i.smap/shapiro/closefiles.c
===================================================================
--- grass/trunk/imagery/i.smap/shapiro/closefiles.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.smap/shapiro/closefiles.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -10,8 +10,7 @@
{
int n;
- if (parms->quiet)
- G_message(_("Creating support files for <%s>..."), parms->output_map);
+ G_debug(1, "Creating support files for <%s>...", parms->output_map);
for (n = 0; n < files->nbands; n++)
G_close_cell(files->band_fd[n]);
Modified: grass/trunk/imagery/i.smap/shapiro/main.c
===================================================================
--- grass/trunk/imagery/i.smap/shapiro/main.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.smap/shapiro/main.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -11,7 +11,7 @@
* Jan-Oliver Wagner <jan intevation.de>
* PURPOSE: segment multispectral images using a spectral class model
* known as a Gaussian mixture distribution
- * COPYRIGHT: (C) 1999-2006 by the GRASS Development Team
+ * COPYRIGHT: (C) 1999-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -35,7 +35,7 @@
G_gisinit(argv[0]);
module = G_define_module();
- module->keywords = _("imagery");
+ module->keywords = _("imagery, classification, supervised, SMAP");
module->description =
_("Performs contextual image classification "
"using sequential maximum a posteriori (SMAP) estimation.");
@@ -48,5 +48,8 @@
segment(&S, &parms, &files);
closefiles(&parms, &files);
+
+ G_done_msg(" ");
+
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/imagery/i.smap/shapiro/openfiles.c
===================================================================
--- grass/trunk/imagery/i.smap/shapiro/openfiles.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.smap/shapiro/openfiles.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -12,11 +12,11 @@
if (!I_get_subgroup_ref(parms->group, parms->subgroup, &Ref))
- G_fatal_error(_("Unable to read REF file for subgroup [%s] in group [%s]."),
+ G_fatal_error(_("Unable to read REF file for subgroup <%s> in group <%s>"),
parms->subgroup, parms->group);
if (Ref.nfiles <= 0)
- G_fatal_error(_("Subgroup [%s] in group [%s] contains no files."),
+ G_fatal_error(_("Subgroup <%s> in group <%s> contains no raster maps"),
parms->subgroup, parms->group);
/* allocate file descriptors, and io buffer */
Modified: grass/trunk/imagery/i.smap/shapiro/parse.c
===================================================================
--- grass/trunk/imagery/i.smap/shapiro/parse.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.smap/shapiro/parse.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -18,11 +18,14 @@
sigfile = G_define_option();
sigfile->key = "signaturefile";
- sigfile->description = _("Name of imagery signaturefile");
+ sigfile->label = _("Name of file containing signatures");
+ sigfile->description = _("Generated by i.gensigset");
sigfile->key_desc = "name";
sigfile->required = YES;
sigfile->type = TYPE_STRING;
+ output = G_define_standard_option(G_OPT_R_OUTPUT);
+
blocksize = G_define_option();
blocksize->key = "blocksize";
blocksize->description = _("Size of submatrix to process at one time");
@@ -30,8 +33,6 @@
blocksize->type = TYPE_INTEGER;
blocksize->answer = "128";
- output = G_define_standard_option(G_OPT_R_OUTPUT);
-
ml = G_define_flag();
ml->key = 'm';
ml->description =
@@ -54,10 +55,10 @@
/* check all the inputs */
if (!I_find_group(parms->group))
- G_fatal_error(_("Group [%s] not found."), parms->group);
+ G_fatal_error(_("Group <%s> not found"), parms->group);
if (!I_find_subgroup(parms->group, parms->subgroup))
- G_fatal_error(_("Subgroup [%s] not found."), parms->subgroup);
+ G_fatal_error(_("Subgroup <%s> not found"), parms->subgroup);
if (sscanf(blocksize->answer, "%d", &parms->blocksize) != 1
|| parms->blocksize <= 8)
Modified: grass/trunk/imagery/i.smap/shapiro/read_sig.c
===================================================================
--- grass/trunk/imagery/i.smap/shapiro/read_sig.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.smap/shapiro/read_sig.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -10,21 +10,21 @@
struct Ref Ref;
if (!I_get_subgroup_ref(parms->group, parms->subgroup, &Ref))
- G_fatal_error(_("Unable to read REF file for subgroup [%s] in group [%s]."),
+ G_fatal_error(_("Unable to read REF file for subgroup <%s> in group <%s>"),
parms->subgroup, parms->group);
if (Ref.nfiles <= 0)
- G_fatal_error(_("Subgroup [%s] in group [%s] contains no files."),
+ G_fatal_error(_("Subgroup <%s> in group <%s> contains no raster maps"),
parms->subgroup, parms->group);
fd = I_fopen_sigset_file_old(parms->group, parms->subgroup,
parms->sigfile);
if (fd == NULL)
- G_fatal_error(_("Signature file [%s] is missing or not readable."),
+ G_fatal_error(_("Unable to read signature file <%s>"),
parms->sigfile);
-
+
if (I_ReadSigSet(fd, S) < 0 || Ref.nfiles != S->nbands)
- G_fatal_error(_("Signature file [%s] is invalid."), parms->sigfile);
+ G_fatal_error(_("Signature file <%s> is invalid"), parms->sigfile);
fclose(fd);
Modified: grass/trunk/imagery/i.smap/shapiro/write_img.c
===================================================================
--- grass/trunk/imagery/i.smap/shapiro/write_img.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/imagery/i.smap/shapiro/write_img.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -9,22 +9,19 @@
{ /* files: contains file to output */
int row, col;
- if (!parms->quiet)
- G_message(_("Writing [%s] ..."), parms->output_map);
+ G_message(_("Writing raster map <%s>..."), parms->output_map);
for (row = 0; row < nrows; row++) {
- if (!parms->quiet)
- G_percent(row, nrows, 2);
+ G_percent(row, nrows, 2);
for (col = 0; col < ncols; col++) {
int class = (int)img[row][col];
-
+
G_debug(3, "class: [%d] row/col: [%d][%d]", class, row, col);
files->outbuf[col] = (CELL) S->ClassSig[class].classnum;
}
G_put_raster_row(files->output_fd, files->outbuf, CELL_TYPE);
}
- if (!parms->quiet)
- G_percent(row, nrows, 2);
+ G_percent(nrows, nrows, 2);
return 0;
}
Modified: grass/trunk/raster/r.composite/main.c
===================================================================
--- grass/trunk/raster/r.composite/main.c 2008-12-14 14:19:36 UTC (rev 34869)
+++ grass/trunk/raster/r.composite/main.c 2008-12-14 14:20:47 UTC (rev 34870)
@@ -7,7 +7,7 @@
* layer using a quantisation of the RGB color space.
* Using Floyd-Steinberg dithering
*
- * COPYRIGHT: (C) 2001 by the GRASS Development Team
+ * COPYRIGHT: (C) 2001-2008 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -70,24 +70,21 @@
module = G_define_module();
module->keywords = _("raster, composite");
module->description =
- _("Combines red, green and blue map layers into "
+ _("Combines red, green and blue raster maps into "
"a single composite raster map.");
for (i = 0; i < 3; i++) {
struct Option *opt;
char buff[80];
- B[i].opt_name = opt = G_define_option();
+ B[i].opt_name = opt = G_define_standard_option(G_OPT_R_INPUT);
sprintf(buff, "%s", color_names[i]);
opt->key = G_store(buff);
- opt->type = TYPE_STRING;
opt->answer = NULL;
- opt->required = YES;
- opt->gisprompt = "old,cell,raster";
- sprintf(buff, _("Name of raster map layer to be used for <%s>"),
+ sprintf(buff, _("Name of raster map to be used for <%s>"),
color_names[i]);
opt->description = G_store(buff);
}
@@ -100,6 +97,7 @@
opt_lev->answer = "32";
opt_lev->description =
_("Number of levels to be used for each component");
+ opt_lev->guisection = _("Levels");
for (i = 0; i < 3; i++) {
struct Option *opt;
@@ -117,10 +115,10 @@
sprintf(buff, _("Number of levels to be used for <%s>"),
color_names[i]);
opt->description = G_store(buff);
+ opt->guisection = _("Levels");
}
opt_out = G_define_standard_option(G_OPT_R_OUTPUT);
- opt_out->description = _("Name of raster map to contain results");
flg_d = G_define_flag();
flg_d->key = 'd';
@@ -161,7 +159,7 @@
/* Reading color lookup table */
if (G_read_colors(b->name, "", &b->colors) == -1)
- G_fatal_error(_("Color file for <%s> not available"), b->name);
+ G_fatal_error(_("Unable to read color file of raster map <%s>"), b->name);
for (j = 0; j < 3; j++)
b->array[j] = (i == j)
@@ -250,9 +248,8 @@
if (G_put_raster_row(out_file, out_array, CELL_TYPE) < 0)
G_fatal_error(_("Failed writing raster map <%s>"), out_name);
}
+ G_percent(window.rows, window.rows, 1);
- G_percent(window.rows, window.rows, 5);
-
/* Close the input files */
for (i = 0; i < 3; i++)
G_close_cell(B[i].file);
@@ -264,7 +261,7 @@
G_command_history(&history);
G_write_history(out_name, &history);
- G_done_msg(" ");
+ G_done_msg(_("Raster map <%s> created."), out_name);
exit(EXIT_SUCCESS);
}
@@ -305,6 +302,5 @@
i += nr;
}
}
-
- G_percent(nb, nb, 5);
+ G_percent(nb, nb, 1);
}
More information about the grass-commit
mailing list