~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to imagery/i.segment/iseg.h

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/****************************************************************************
 
3
 *
 
4
 * MODULE:       i.segment
 
5
 * AUTHOR(S):    Eric Momsen <eric.momsen at gmail com>
 
6
 * PURPOSE:      structure definition and function listing
 
7
 * COPYRIGHT:    (C) 2012 by Eric Momsen, and the GRASS Development Team
 
8
 *
 
9
 *               This program is free software under the GNU General Public
 
10
 *               License (>=v2). Read the COPYING file that comes with GRASS
 
11
 *               for details.
 
12
 *
 
13
 *****************************************************************************/
 
14
 
 
15
#include <grass/segment.h>
 
16
#include "flag.h"
 
17
#include "regtree.h"
 
18
#include "ngbrtree.h"
 
19
 
 
20
/* #def _OR_SHAPE_ */
 
21
 
 
22
 
 
23
/* row/col list */
 
24
struct rc
 
25
{
 
26
    struct rc *next;
 
27
    int row;
 
28
    int col;
 
29
};
 
30
 
 
31
struct rclist
 
32
{
 
33
    struct rc *tail, *head;
 
34
};
 
35
 
 
36
/* input and output files, as well as some other processing info */
 
37
struct globals
 
38
{
 
39
    /* user parameters */
 
40
    char *image_group;
 
41
    int weighted;               /* 0 if false/not selected, so we should scale input.
 
42
                                 * 1 if the scaling should be skipped */
 
43
    int method;                 /* Segmentation method */
 
44
    int nn;                     /* number of neighbors, 4 or 8 */
 
45
    double max_diff;            /* max possible difference */
 
46
    double alpha;               /* similarity threshold */
 
47
    int min_segment_size;       /* smallest number of pixels/cells allowed in a final segment */
 
48
 
 
49
    double radio_weight;        /* weighing factor radiometric - shape */
 
50
    double smooth_weight;       /* weighing factor smoothness - compactness */
 
51
 
 
52
    int end_t;                  /* maximum number of iterations */
 
53
    int mb;
 
54
 
 
55
    /* region info */
 
56
    int nrows, ncols;
 
57
    int row_min, row_max, col_min, col_max; /* region constraints */
 
58
    long ncells, notnullcells;
 
59
 
 
60
    char *out_name;             /* name of output raster map */
 
61
    char *seeds, *bounds_map;   /* optional segment seeds and polygon constraints/boundaries */
 
62
    CELL lower_bound, upper_bound;
 
63
    const char *bounds_mapset;
 
64
    char *out_band;             /* indicator for segment heterogeneity */
 
65
 
 
66
    /* file processing */
 
67
    int nbands;                 /* number of rasters in the image group */
 
68
    SEGMENT bands_seg,          /* input group with one or more bands */
 
69
            bounds_seg,
 
70
            rid_seg;
 
71
    DCELL *bands_min, *bands_max;
 
72
    DCELL *bands_val;           /* array to hold all input values for one cell */
 
73
    DCELL *second_val;          /* array to hold all input values for another cell */
 
74
 
 
75
    /* results */
 
76
    struct RG_TREE *reg_tree;   /* search tree with region stats */
 
77
    int min_reg_size;           /* minimum region size */
 
78
    struct reg_stats rs, rs_i, rs_k;
 
79
    struct ngbr_stats ns;
 
80
    size_t datasize;            /* nbands * sizeof(double) */
 
81
    int n_regions;
 
82
 
 
83
    /* processing flags */
 
84
    FLAG *candidate_flag, *null_flag;   /*TODO, need some way to remember MASK/NULL values.  Was using -1, 0, 1 in int array.  Better to use 2 FLAG structures, better readibility? */
 
85
 
 
86
    /* number of remaining cells to check */
 
87
    long candidate_count;
 
88
 
 
89
    /* functions */
 
90
        
 
91
    void (*find_neighbors) (int, int, int[8][2]);       /*parameters: row, col, neighbors */
 
92
    double (*calculate_similarity) (struct ngbr_stats *,
 
93
                                    struct ngbr_stats *,
 
94
                                    struct globals *);  /*parameters: two regions to compare */
 
95
};
 
96
 
 
97
 
 
98
/* parse_args.c */
 
99
/* gets input from user, validates, and sets up functions */
 
100
int parse_args(int, char *[], struct globals *);
 
101
 
 
102
/* open_files.c */
 
103
int open_files(struct globals *);
 
104
 
 
105
/* create_isegs.c */
 
106
int create_isegs(struct globals *);
 
107
int region_growing(struct globals *);
 
108
void find_four_neighbors(int, int, int[][2]);
 
109
void find_eight_neighbors(int, int, int[8][2]);
 
110
double calculate_euclidean_similarity(struct ngbr_stats *, 
 
111
                                      struct ngbr_stats *,
 
112
                                      struct globals *);
 
113
double calculate_manhattan_similarity(struct ngbr_stats *, 
 
114
                                      struct ngbr_stats *,
 
115
                                      struct globals *);
 
116
double calculate_shape(struct reg_stats *, struct reg_stats *,
 
117
                       int, struct globals *);
 
118
int fetch_reg_stats(int , int , struct reg_stats *, 
 
119
                           struct globals *);
 
120
int update_band_vals(int, int, struct reg_stats *, struct globals *);
 
121
 
 
122
/* void calculate_reg_stats(int, int, struct reg_stats *, 
 
123
                         struct globals *); */
 
124
 
 
125
 
 
126
/* rclist.c */
 
127
void rclist_init(struct rclist *);
 
128
void rclist_add(struct rclist *, int, int);
 
129
int rclist_drop(struct rclist *, struct rc *);
 
130
void rclist_destroy(struct rclist *);
 
131
 
 
132
 
 
133
/* write_output.c */
 
134
int write_output(struct globals *);
 
135
int close_files(struct globals *);