|r.seg - manual|
NAMEr.seg - Generates a smooth approximation of the input raster and a discontinuity map
KEYWORDSimage segmentation, edge detection, smooth
r.seg [-k] in_g=string out_u=string out_z=string [lambda=float] [alpha=float] [mxi=integer] [tol=float] [kepsilon=float] [beta=float] [--overwrite] [--verbose] [--quiet]
DESCRIPTIONr.seg generates a piece-wise smooth approximation of the input raster map and a raster map of the discontinuities of the output approximation.
The discontinuities of the output approximation are preserved from being smoothed. The values of the discontinuity map are close to one where the output approximation is "homogeneous", where the output approximation has discontinuities (edges) the values are close to zero.
The module makes use of the varseg library which implements the Mumford-Shah  variational model for image segmentation. The Mumford-Shah variational model with curvature term  is also implemented in the library. The curvature term prevents the discontinuities from being shortened too much when the parameter alpha is set to very high values, (this happens very rarely).
Some examples of use of the module can be found here and in this presentation [FOSS4G 2009 - pdf].
For details on the numerical implementation see .
NOTESRemove any MASK before the execution of the module. If a MASK is present, the module stops after just one iteration.
Replace (r.null) any null data with the map average value (get with r.univar).
The segmentation depends on the parameters alpha and lambda:
The module stops either when the number of iterations reaches the maximum number of iterations [mxi] or when the maximum difference between the solutions of two successive iterations is less than the convergence tolerance [tol].
To stop the iteration procedure, it is easier to act on the maximum number of iterations parameter [mxi] than on the convergence tolerance parameter [tol].
The number of iterations needed to reach the convergence tolerance increases for high values of the parameter lambda. The larger the total number of pixels of the input raster map the larger the number of iterations will be.
The data type of the output raster maps is DOUBLE PRECISION.
The module works on one raster map at a time, imagery groups are not supported.
To avoid to inappropriately re-sampled the input raster map, the settings for the current region should be set so that:
The actual need to use the MSK model should be very rare, see . Due to a different implementation of the MSK model with respect to MS one, the values of the parameters lambda and alpha in MSK have to be set independently from the values used in MS.
EXAMPLEThis example is based the North Carolina GRASS sample data set, [complete GRASS location].
# set the region to match the ortho_2001_t792_1m raster map: g.region rast=ortho_2001_t792_1m # select a smaller region: g.region n=221725 s=220225 w=638350 e=639550 # run r.seg: r.seg in_g=ortho_2001_t792_1m@PERMANENT out_u=u_OF out_z=z_OF lambda=10 alpha=200 mxi=250 # for a better visualization of the output raster map u_OF, set its color table to: r.colors u_OF rast=ortho_2001_t792_1m # compute the difference between the input raster map and the output raster map u_OF: r.mapcalc "diff = abs(ortho_2001_t792_1m@PERMANENT - u_OF)" # for a better visualization of the differences, compute the natural logarithm of the diff map: r.mapcalc "log_diff = log(1 + diff)" # and set its color table to the "differences" style: r.colors log_diff color=differences # for a better visualization of the output raster map u_OF, set its color table to: r.colors z_OF color=bgyr # run r.seg with different parameter values: r.seg in_g=ortho_2001_t792_1m@PERMANENT out_u=u1_OF out_z=z1_OF lambda=10 alpha=65 mxi=250 r.seg in_g=ortho_2001_t792_1m@PERMANENT out_u=u2_OF out_z=z2_OF lambda=10 alpha=600 mxi=250 r.seg in_g=ortho_2001_t792_1m@PERMANENT out_u=u3_OF out_z=z3_OF lambda=0.1 alpha=200 mxi=250 r.seg in_g=ortho_2001_t792_1m@PERMANENT out_u=u4_OF out_z=z4_OF lambda=1 alpha=200 mxi=250 # visualize and compare the different results
SEE ALSOi.smap, i.zc, r.mfilter
Dept. Civil and Environmental Engineering
University of Trento - Italy
alfonso.vitti [at] ing.unitn.it
Last changed: $Date: 2010-08-10 12:00:00 +0200 (Tue, 10 Aug 2010)$
© 2003-2010 GRASS Development Team
|Home | SW page|
..: 2009 :: Alfonso Vitti :..