1i.segment(1)                GRASS GIS User's Manual               i.segment(1)
2
3
4

NAME

6       i.segment  - Identifies segments (objects) from imagery data.
7

KEYWORDS

9       imagery, segmentation, classification, object recognition
10

SYNOPSIS

12       i.segment
13       i.segment --help
14       i.segment [-dwap] group=name[,name,...] output=name  [band_suffix=name]
15       threshold=float  [radius=float]   [hr=float]   [method=string]   [simi‐
16       larity=string]    [minsize=integer]    [memory=memory  in MB]   [itera‐
17       tions=integer]     [seeds=name]      [bounds=name]      [goodness=name]
18       [--overwrite]  [--help]  [--verbose]  [--quiet]  [--ui]
19
20   Flags:
21       -d
22           Use  8 neighbors (3x3 neighborhood) instead of the default 4 neigh‐
23           bors for each pixel
24
25       -w
26           Weighted input, do not perform the default scaling of input  raster
27           maps
28
29       -a
30           Use adaptive bandwidth for mean shift
31           Range (spectral) bandwidth is adapted for each moving window
32
33       -p
34           Use progressive bandwidth for mean shift
35           Spatial  bandwidth  is increased, range (spectral) bandwidth is de‐
36           creased in each iteration
37
38       --overwrite
39           Allow output files to overwrite existing files
40
41       --help
42           Print usage summary
43
44       --verbose
45           Verbose module output
46
47       --quiet
48           Quiet module output
49
50       --ui
51           Force launching GUI dialog
52
53   Parameters:
54       group=name[,name,...] [required]
55           Name of input imagery group or raster maps
56
57       output=name [required]
58           Name for output raster map
59
60       band_suffix=name
61           Suffix for output bands with modified band values
62           Name for output raster map
63
64       threshold=float [required]
65           Difference threshold between 0 and 1
66           Threshold = 0 merges only identical segments; threshold = 1  merges
67           all
68
69       radius=float
70           Spatial radius in number of cells
71           Must  be  >=  1, only cells within spatial bandwidth are considered
72           for mean shift
73           Default: 1.5
74
75       hr=float
76           Range (spectral) bandwidth [0, 1]
77           Only cells within range (spectral)  bandwidth  are  considered  for
78           mean  shift.  Range  bandwidth is used as conductance parameter for
79           adaptive bandwidth
80
81       method=string
82           Segmentation method
83           Options: region_growing, mean_shift
84           Default: region_growing
85
86       similarity=string
87           Similarity calculation method
88           Options: euclidean, manhattan
89           Default: euclidean
90
91       minsize=integer
92           Minimum number of cells in a segment
93           The final step will merge small segments with their best neighbor
94           Options: 1-100000
95           Default: 1
96
97       memory=memory in MB
98           Maximum memory to be used (in MB)
99           Cache size for raster rows
100           Default: 300
101
102       iterations=integer
103           Maximum number of iterations
104
105       seeds=name
106           Name for input raster map with starting seeds
107
108       bounds=name
109           Name of input bounding/constraining raster map
110           Must be integer values, each area will be segmented independent  of
111           the others
112
113       goodness=name
114           Name for output goodness of fit estimate map
115

DESCRIPTION

117       Image  segmentation  or  object  recognition is the process of grouping
118       similar pixels into unique  segments,  also  referred  to  as  objects.
119       Boundary  and  region based algorithms are described in the literature,
120       currently a region growing and merging algorithm is  implemented.  Each
121       object  found  during the segmentation process is given a unique ID and
122       is a collection of contiguous pixels meeting some  criteria.  Note  the
123       contrast  with  image  classification  where all pixels similar to each
124       other are assigned to the same class and do not need to be  contiguous.
125       The image segmentation results can be useful on their own, or used as a
126       preprocessing step for image classification. The  segmentation  prepro‐
127       cessing step can reduce noise and speed up the classification.
128

NOTES

130   Region Growing and Merging
131       This  segmentation algorithm sequentially examines all current segments
132       in the raster map. The similarity between the current segment and  each
133       of its neighbors is calculated according to the given distance formula.
134       Segments will be merged if they meet a number of criteria, including:
135
136       1      The pair is mutually most similar to each other (the  similarity
137              distance will be smaller than to any other neighbor), and
138
139       2      The  similarity  must  be  lower  than  the input threshold. The
140              process is repeated until no merges are made during  a  complete
141              pass.
142
143   Similarity and Threshold
144       The  similarity between segments and unmerged objects is used to deter‐
145       mine which objects are  merged.  Smaller  distance  values  indicate  a
146       closer match, with a similarity score of zero for identical pixels.
147
148       During  normal  processing, merges are only allowed when the similarity
149       between two segments is lower than the given  threshold  value.  During
150       the  final  pass,  however, if a minimum segment size of 2 or larger is
151       given with the minsize parameter, segments with a smaller  pixel  count
152       will  be merged with their most similar neighbor even if the similarity
153       is greater than the threshold.
154
155       The threshold must be larger than 0.0 and smaller than 1.0. A threshold
156       of  0  would  allow  only identical valued pixels to be merged, while a
157       threshold of 1 would allow everything to be merged.  The  threshold  is
158       scaled to the data range of the entire input data, not the current com‐
159       putational region.  This allows the application of the  same  threshold
160       to  different  computational  regions when working on the same dataset,
161       ensuring that this threshold has the same meaning in all subregions.
162
163       Initial empirical tests indicate threshold values of 0.01 to  0.05  are
164       reasonable  values  to  start.  It  is  recommended to start with a low
165       value, e.g. 0.01, and then perform hierarchical segmentation  by  using
166       the output of the last run as seeds for the next run.
167
168   Calculation Formulas
169       Both  Euclidean and Manhattan distances use the normal definition, con‐
170       sidering each raster in the image group as a dimension.  In future, the
171       distance calculation will also take into account the shape characteris‐
172       tics of the segments. The normal distances are then multiplied  by  the
173       input  radiometric  weight.  Next  an additional contribution is added:
174       (1-radioweight) * {smoothness  *  smoothness  weight  +  compactness  *
175       (1-smoothness  weight)},  where  compactness = Perimeter Length / sqrt(
176       Area ) and smoothness = Perimeter Length / Bounding Box. The  perimeter
177       length is estimated as the number of pixel sides the segment has.
178
179   Seeds
180       The  seeds map can be used to provide either seed pixels (random or se‐
181       lected points from which to start the  segmentation  process)  or  seed
182       segments.  If the seeds are the results of a previous segmentation with
183       lower threshold, hierarchical segmentation can be performed.  The  dif‐
184       ferent approaches are automatically detected by the program: any pixels
185       that have identical seed values and are contiguous will be  assigned  a
186       unique segment ID.
187
188   Maximum number of segments
189       The  current  limit with CELL storage used for segment IDs is 2 billion
190       starting segment IDs. Segment IDs are assigned whenever  a  yet  unpro‐
191       cessed  pixel is merged with another segment. Integer overflow can hap‐
192       pen for computational regions with more than 2 billion cells  and  very
193       low  threshold  values, resulting in many segments. If integer overflow
194       occurs durin region growing, starting segments can be used (created  by
195       initial classification or other methods).
196
197   Goodness of Fit
198       The goodness of fit for each pixel is calculated as 1 - distance of the
199       pixel to the object it belongs to. The distance is calculated with  the
200       selected  similarity  method. A value of 1 means identical values, per‐
201       fect fit, and a value of 0 means maximum possible distance, worst  pos‐
202       sible fit.
203
204   Mean shift
205       Mean shift image segmentation consists of 2 steps: anisotrophic filter‐
206       ing and 2. clustering. For anisotrophic filtering new cell  values  are
207       calculated  from  all  pixels  not farther than hs pixels away from the
208       current pixel and with a spectral difference not larger than  hr.  That
209       means that pixels that are too different from the current pixel are not
210       considered in the calculation of new pixel values.  hs and hr  are  the
211       spatial  and  spectral  (range)  bandwidths for anisotrophic filtering.
212       Cell values are iteratively  recalculated  (shifted  to  the  segment’s
213       mean)  until  the  maximum number of iterations is reached or until the
214       largest shift is smaller than threshold.
215
216       If input bands have been reprojected, they should  not  be  reprojected
217       with  bilinear resampling because that method causes smooth transitions
218       between objects. More appropriate methods are bicubic or lanczos resam‐
219       pling.
220
221   Boundary Constraints
222       Boundary  constraints limit the adjacency of pixels and segments.  Each
223       unique value present in the bounds raster are  considered  as  a  MASK.
224       Thus  no  segments  in the final segmentated map will cross a boundary,
225       even if their spectral data is very similar.
226
227   Minimum Segment Size
228       To reduce the salt and pepper effect, a minsize greater than 1 will add
229       one  additional  pass  to  the  processing.  During the final pass, the
230       threshold is ignored for any segments smaller then the set  size,  thus
231       forcing  very small segments to merge with their most similar neighbor.
232       A minimum segment size larger than 1 is recommended when using adaptive
233       bandwidth selected with the -a flag.
234

EXAMPLES

236   Segmentation of RGB orthophoto
237       This  example  uses  the  ortho  photograph  included  in the NC Sample
238       Dataset. Set up an imagery group:
239       i.group group=ortho_group input=ortho_2001_t792_1m@PERMANENT
240
241       Set the region to a smaller test region (resolution  taken  from  input
242       ortho photograph).
243       g.region -p raster=ortho_2001_t792_1m n=220446 s=220075 e=639151 w=638592
244       Try out a low threshold and check the results.
245       i.segment group=ortho_group output=ortho_segs_l1 threshold=0.02
246
247       From  a  visual inspection, it seems this results in too many segments.
248       Increasing the threshold, using the previous results as seeds, and set‐
249       ting a minimum size of 2:
250       i.segment group=ortho_group output=ortho_segs_l2 threshold=0.05 seeds=ortho_segs_l1 min=2
251       i.segment group=ortho_group output=ortho_segs_l3 threshold=0.1 seeds=ortho_segs_l2
252       i.segment group=ortho_group output=ortho_segs_l4 threshold=0.2 seeds=ortho_segs_l3
253       i.segment group=ortho_group output=ortho_segs_l5 threshold=0.3 seeds=ortho_segs_l4
254
255       The  output  ortho_segs_l4  with  threshold=0.2 still has too many seg‐
256       ments, but the output  with  threshold=0.3  has  too  few  segments.  A
257       threshold  value  of 0.25 seems to be a good choice. There is also some
258       noise in the image, lets next force all segments smaller than 10 pixels
259       to  be  merged  into their most similar neighbor (even if they are less
260       similar than required by our threshold):
261
262       Set the region to match the entire map(s) in the group.
263       g.region -p raster=ortho_2001_t792_1m@PERMANENT
264
265       Run i.segment on the full map:
266       i.segment group=ortho_group output=ortho_segs_final threshold=0.25 min=10
267
268       Processing the entire ortho image with nearly 10  million  pixels  took
269       about 450 times more then for the final run.
270
271   Segmentation of panchromatic channel
272       This  example  uses  the panchromatic channel of the Landsat7 scene in‐
273       cluded in the North Carolina sample dataset:
274       # create group with single channel
275       i.group group=singleband input=lsat7_2002_80
276       # set computational region to Landsat7 PAN band
277       g.region raster=lsat7_2002_80 -p
278       # perform segmentation with minsize=5
279       i.segment group=singleband threshold=0.05 minsize=5 \
280         output=lsat7_2002_80_segmented_min5 goodness=lsat7_2002_80_goodness_min5
281       # perform segmentation with minsize=100
282       i.segment group=singleband threshold=0.05 minsize=100
283         output=lsat7_2002_80_segmented_min100 goodness=lsat7_2002_80_goodness_min100
284
285       Original panchromatic channel of the Landsat7 scene
286
287       Segmented panchromatic channel, minsize=5
288
289       Segmented panchromatic channel, minsize=100
290

TODO

292   Functionality
293           •   Further testing of the shape characteristics (smoothness,  com‐
294               pactness), if it looks good it should be added.  (in progress)
295
296           •   Malahanobis distance for the similarity calculation.
297
298   Use of Segmentation Results
299           •   Improve  the  optional  output from this module, or better yet,
300               add a module for i.segment.metrics.
301
302           •   Providing updates to i.maxlik to ensure the segmentation output
303               can  be used as input for the existing classification function‐
304               ality.
305
306           •   Integration/workflow for r.fuzzy (Addon).
307
308   Speed
309           •   See create_isegs.c
310

REFERENCES

312       This project was first developed during GSoC 2012.  Project  documenta‐
313       tion,  Image  Segmentation  references, and other information is at the
314       project wiki.
315
316       Information about classification in GRASS is at available on the wiki.
317

SEE ALSO

319        g.gui.iclass, i.group, i.maxlik, i.smap, r.kappa
320

AUTHORS

322       Eric Momsen - North Dakota State University
323       Markus Metz (GSoC Mentor)
324

SOURCE CODE

326       Available at: i.segment source code (history)
327
328       Accessed: Saturday Jan 21 21:16:50 2023
329
330       Main index | Imagery index | Topics index | Keywords index |  Graphical
331       index | Full index
332
333       © 2003-2023 GRASS Development Team, GRASS GIS 8.2.1 Reference Manual
334
335
336
337GRASS 8.2.1                                                       i.segment(1)
Impressum