Skip to content
Commits on Source (7)
SNAPHU
Statistical-Cost, Netowrk-Flow Algorithm for Phase Unwrapping
Author: Curtis W. Chen
Version 1.4.2, January 2003
Version 2.0.0, March 2019
Contents
......@@ -19,7 +19,7 @@ Bugs And Bug Reporting
Not all parts of snaphu have been well tested, so your bug reports and
feedback are appreciated. Please email them to
curtis@nova.stanford.edu
snaphu@gmail.com
The man page included with the distribution lists known issues as
well. Thanks, and good luck with the unwrapping.
......@@ -45,6 +45,8 @@ The code was developed mainly with gcc, but has been tested with a
number of vendor C compilers. The latter tend to produce faster
executables.
I have not tried running snaphu under Cygwin.
I have not experimented with parallelizing compilers. The code is
written to use multiple processors in tile mode by forking copies of
itself to unwrap each tile. The structure of the solver does not lend
......@@ -69,7 +71,7 @@ accept.
Copyright
---------
Copyright 2002 Board of Trustees, Leland Stanford Jr. University
Copyright 2002-2019 Board of Trustees, Leland Stanford Jr. University
Except as noted below, permission to use, copy, modify, and
distribute, this software and its documentation for any purpose is
......
Notable changes in v2.0 since v1.4.2:
-------------------------------------
* The new -S option invokes behavior whereby snaphu will first run in
tile mode to produce an unwrapped solution then feed this unwrapped
solution back into the cost calculator and optimizer as if an
unwrapped phase file were read from the input. This option is
equivalent to running snaphu in tile mode, then running snaphu again
using the tile-mode output as an unwrapped input file using the -u
option. Tile parameters must be specified when using the -S option.
* Masking of input pixels is now supported. A typical usage of
masking would be in unwrapping repeat-pass interferograms where
water areas are expected to have zero correlation; a water mask can
be used to exclude such areas in order to reduce the execution time.
When computing costs, arcs through masked areas are assumed to have
zero cost, so nodes internal to masked areas can be ignored in the
solver, thereby reducing the total number of nodes and usually
decreasing the solution time. An unwrapped phase output value will
still be produced for each masked pixel, but the unwrapped value
will not generally be reliable; often it will be whatever value is
left from the initialization.
The user can indicate masking by setting the magnitude of a pixel to
zero in the input file or by specifying a separate binary mask via
the new -M option or the new BYTEMASKFILE keyword. See the comments
in the template configuration file for the BYTEMASKFILE keyword for
a full description of the file format. A fixed number of pixels at
each edge of the input file can also be masked via the EDGEMASKTOP,
EDGEMASKBOT, EDGEMASKLEFT, and EDGEMASKRIGHT keywords.
If masked pixels separate regions of unmasked pixels, the unwrapped
phase relationship between the disconnected regions will not
generally be reliable, though a solution for each region will still
produced (also see the NCONNNODEMIN keyword).
* The new -C command-line option takes a string argument that is
parsed as a configuration line like one that would be put into a
configuration file. The string argument to the -C option may need
to be protected from the shell by quotes to preserve whitespace.
* The integer types of several internal variables have changed now
that 64-bit systems have generally replaced 32-bit systems. The
memory footprint of snaphu v2.0 is approximately 20% smaller than
that of v1.4.2 when both are compiled as 64 bit binaries on an Intel
system. The memory footprint of snaphu v2.0 is similar to (about 2%
larger than) that of v1.4.2 when both are compiled as a 32-bit
binary, but v2.0 should be less constrained in terms of the input
interferogram size. The memory footprint of v2.0 when compiled as a
64-bit binary is about 30% larger than when the same code (v2.0) is
compiled as a 32-bit binary, although it is expected that most users
will compile snaphu as a 64-bit binary nonetheless given the
availability of memory on most systems.
* The syntax of the ASSEMBLEONLY keyword and the --assemble
command-line option have changed so that they are now boolean flags.
The name of the tile directory to assemble is specified through the
new keyword TILEDIR or the --tiledir command-line option.
Additionally, the new keyword DOTILEMASK allows the user to unwrap
only selected tiles for manual experimentation and assembly of
tiles.
* When unwrapping in tile mode, the default behavior is now to remove
temporary tile files rather than to keep them. Users can specify
the new -k option on the command line or set the RMTMPTILE keyword
to FALSE in a config file to keep temporary tile files.
* A warning is now displayed if running in tile mode and the tile
overlap is less than a semi-arbitrary constant warning threshold. A
suggestion is displayed about increasing overlap or tile size if
edge artifacts are present if the overlap is less than the tile size.
* Connected components are now supported in tile mode. The connected
components are assembled from the connected components of individual
tiles and renumbered to be unique, but they will break at tile
boundaries. It is possible that a component will not be fully
connected in the assembled output if the component was connected
only in the tile overlap area that was discarded while assembling
the full output.
* The connected components output file may be written as either 1-byte
unsigned integers or 4-byte (32-bit) unsigned integers via the
CONNCOMPOUTTYPE keyword. Using 4-byte values allows more than 255
connected components to be defined, although the default is still to
use 1-byte values for backward compatibility.
* Support for Lp-norm cost functions has been added. Note, however,
that congruence is still enforced, meaning that the unwrapped phase
will differ from the wrapped phase by only integer numbers cycles.
Therefore, the use of an L2-norm cost functions is not equivalent to
least-squares phase unwrapping approaches that do not enforce
congruence (as described by Ghiglia and Romero, 1996).
* Experimental code for tree pruning has been included. This behavior
is controlled by the new NMAJORPRUNE and PRUNECOSTTHRESH keywords.
This code has not been well tested and users are advised to use this
code with only the lowest of expectations.
* The SOURCEMODE keyword and associated functionality has been removed
due to changes in the source selection algorithm to allow the
unwrapping of multiple regions that are disconnected by masked
pixels.
* There have been many internal code cleanups that should be
transparent to the user.
* Several miscellaneous bugs have been fixed and several minor
enhancements have been added.
snaphu
snaphu.dSYM
snaphu_v*
......@@ -26,18 +26,27 @@
# Output file name
# OUTFILE snaphu.out
# Amplitude file name(s)
# Amplitude file name
# AMPFILE snaphu.amp.in # Single file containing amplitude images
# Correlation file name
# CORRFILE snaphu.corr.in
# Input file of signed binary byte (signed char) values.
# BYTEMASKFILE snaphu.bytemask
# Text file to which runtime parameters will be logged.
# LOGFILE snaph.logfile
# Statistical-cost mode (TOPO, DEFO, SMOOTH, or NOSTATCOSTS)
# STATCOSTMODE TOPO
# Initialize-only mode (TRUE or FALSE)
# INITONLY FALSE
# Unwrapped-input mode (TRUE or FALSE)
# UNWRAPPED_IN FALSE
# Algorithm used for initialization of wrapped phase values. Possible
# values are MST and MCF.
# INITMETHOD MST
......@@ -66,9 +75,9 @@
# and complex*8 in Fortran) in the native byte order (big vs. little
# endian) of the system.
# Input file format
# Allowable formats:
# If the data are not complex, the phase should be in radians from 0 to 2pi.
# COMPLEX_DATA (default)
# ALT_LINE_DATA (magnitude in channel 1, phase in radians in channel 2)
# ALT_SAMPLE_DATA (magnitude in channel 1, phase in radians in channel 2)
......@@ -78,9 +87,9 @@
# Output file format
# Allowable formats:
# ALT_LINE_DATA (interferogram magnitude in channel 1,
# ALT_LINE_DATA (masked interferogram magnitude in channel 1,
# unwrapped phase in radians in channel 2; default)
# ALT_SAMPLE_DATA (interferogram magnitude in channel 1,
# ALT_SAMPLE_DATA (masked interferogram magnitude in channel 1,
# unwrapped phase in radians in channel 2)
# FLOAT_DATA (unwrapped phase in radians)
#
......@@ -106,6 +115,16 @@
#
#CORRFILEFORMAT ALT_LINE_DATA
# Unwrapped input file format
# Allowable formats:
# ALT_LINE_DATA (interferogram magnitude in channel 1,
# unwrapped phase in radians in channel 2; default)
# ALT_SAMPLE_DATA (interferogram magnitude in channel 1,
# unwrapped phase in radians in channel 2)
# FLOAT_DATA (unwrapped phase in radians)
#
#UNWRAPPEDINFILEFORMAT ALT_LINE_DATA
###############################
# SAR and geometry parameters #
......@@ -288,6 +307,156 @@ MAXFLOW 4
# integer costs (double).
COSTSCALE 100.0
# Integer spacing that represents one unit of flow or one cycle of phase
# when storing costs as short integer types (long).
NSHORTCYCLE 200
# Gives the minimum number of connected nodes to consider for
# unwrapping. If masking separates the input data into disconnected
# sets of pixels, a source is selected for each connected set,
# provided that the number of nodes in the set is greater than
# NCONNNODEMIN. If NCONNNODEMIN is zero, all possible unmasked pixels
# will be uwnrapped. NCONNNODEMIN should be nonnegative.
NCONNNODEMIN 0
###########################
# Edge masking parameters #
###########################
# These parameters (long, dimensionless) are used to mask out pixels
# near the edges of the input array. EDGEMASKTOP, EDGEMASKBOT,
# EDGEMASKLEFT, and EDGEMASKRIGHT specify the numbers of pixels from the
# top, bottom, left, and right edges respectively that should be
# masked out. Masking is only applied during the nonlinear solver
# stage (not the initialization).
# EDGEMASKTOP 0
# EDGEMASKBOT 0
# EDGEMASKLEFT 0
# EDGEMASKRIGHT 0
###############################
# Piece extraction parameters #
###############################
# These parameters (long, dimensionless) allow only a subset of the
# input data files to be read and unwrapped. The upper left corner of
# the subset is at row PIECEFIRSTROW and column PIECEFIRSTCOL, with
# both indexed from 1 (that is, the upper left corner is pixel 1,1).
# The output will be PIECENROW rows x PIECENCOL columns in size.
# These parameters cannot be used in tile mode. If PIECENROW or
# PIECENCOL is zero, the full depth or width of the input is
# unwrapped.
# PIECEFIRSTROW 1
# PIECEFIRSTCOL 1
# PIECENROW 0
# PIECENCOL 0
################
# Tile control #
################
# Parameters in this section describe how the input files will be
# tiled. This is mainly used for tiling, in which different
# patches of the interferogram are unwrapped separately.
# Number of rows and columns of tiles into which the data files are
# to be broken up.
# NTILEROW 1
# NTILECOL 1
# Overlap, in pixels, between neighboring tiles.
# ROWOVRLP 0
# COLOVRLP 0
# Maximum number of child processes to start for parallel tile
# unwrapping.
# NPROC 1
# Cost threshold to use for determining boundaries of reliable regions
# (long, dimensionless; scaled according to other cost constants).
# Larger cost threshold implies smaller regions---safer, but
# more expensive computationally.
# TILECOSTTHRESH 500
# Minimum size (long, pixels) of a reliable region in tile mode.
# MINREGIONSIZE 100
# Extra weight applied to secondary arcs on tile edges.
# TILEEDGEWEIGHT 2.5
# Maximum flow magnitude (long) whose cost will be stored in the secondary
# cost lookup table. Secondary costs larger than this will be approximated
# by a quadratic function.
# SCNDRYARCFLOWMAX 8
# The program will remove temporary tile files if this is set.
# RMTMPTILE FALSE
# This is the name (string) of a file of signed character data types
# which serve as a mask for which tiles will be unwrapped. The file
# should be a raster array with NTILEROW rows and NTILECOL columns.
# Where the array element is nonzero, the corresponding tile will be
# unwrapped; where the array element is zero, the tile will not be
# unwrapped and no output for that tile will be written. This option
# is used for reprocessing only certain tiles of a run.
# DOTILEMASKFILE snaphu.dotilemaskfile.in
# This is the name of the tile directory. Tiles will be stored
# temporarily in the tile directory. If in assemble only mode,
# unwrapped tiles are assumed to reside in this directory. The
# directory is create if it does not exist.
# TILEDIR snaphu_tiledir
# If this is set to TRUE, the program will skip the unwrapping step
# and only assemble temporary tile files from a previous invocation
# saved in the directory whose name is given by the TILEDIR keyword.
# The tile size parameters and file names must be the same.
# ASSEMBLEONLY FALSE
# Repotimize as single tile after using tile mode for intialization if
# this is set to TRUE. This is equivalent to unwrapping with multiple
# tiles, then using the unwrapped output as the input to a new, single-tile run
# of snaphu with the -u option. The purpose is for speed.
#SINGLETILEREOPTIMIZE FALSE
###############################
# Connected component control #
###############################
# Grow connected components mask and write to the output file whose
# name is specified here as a string. The mask is a file of unsigned
# integer values with the same number of rows and columns as the
# unwrapped interferogram. The type of integer (1 byte vs. 4 byte) is
# specified by the CONNCOMPOUTTYPE keyword, with 1-byte integers being
# the default.
# CONNCOMPFILE snaphu.conncomp
# Type of integer that the connected-component output, if requested,
# will be written as (see the CONNCOMPFILE keyword). The value here
# may be either UCHAR or UINT, which specify unsigned character
# (1-byte integer) or unsigned integer (4-byte integer) values,
# respectively.
# CONNCOMPOUTTYPE UCHAR
# Grow connected components mask from unwrapped input then exit if TRUE.
# Output is written to the file specified by CONNCOMPFILE.
# REGROWCONNCOMPS FALSE
# Minimum size of a single connected component, as a fraction (double)
# of the total number of pixels in tile.
# MINCONNCOMPFRAC 0.01
# Cost threshold for connected components (long). Higher threshold will
# give smaller connected components.
# CONNCOMPTHRESH 300
# Maximum number of connected components per tile (long).
# MAXNCOMPS 32
# End of snaphu configuration file
......@@ -17,37 +17,48 @@
# See section below for file format configuration options.
# Input file name
# Input file name (see possible file formats below)
# INFILE snaphu.in
# Input file line length
# LINELENGTH 1000
# Output file name
# Output file name (see possible file formats below). The output
# array will have the same dimensions as the input unless the PIECE
# parameters are specified.
# OUTFILE snaphu.out
# Weight file name
# Weight file name. Weights are specified on arcs, not pixel values.
# WEIGHTFILE snaphu.weights.in
# Amplitude file name(s)
# Amplitude file name(s); (see possible file formats below). The
# array(s) should have the same dimensions as the input wrapped phase
# array. The values should be in linear units.
# AMPFILE snaphu.amp.in # Single file containing amplitude images
#
# AMPFILE1 snaphu.amp1.in # Pair of separate files for amplitude images
# AMPFILE2 snaphu.amp2.in
# Power file name(s)
# Power file name(s); (see possible file formats below) The array(s)
# should have the same dimensions as the input wrapped phase array.
# The values should be in linear units (not dB).
# PWRFILE snaphu.amp.in # Single file containing power images
#
# PWRFILE1 snaphu.amp1.in # Pair of separate files for power images
# PWRFILE2 snaphu.amp2.in
# Interferogram magnitude file
# Interferogram magnitude file (see possible file formats below). The
# array should have the same dimensions as the input wrapped phase
# array. The magnitude should be in linear units.
# MAGFILE snaphu.mag.in
# Correlation file name
# Correlation file name (see possible file formats below). The array
# should have the same dimensions as the input wrapped phase array.
# CORRFILE snaphu.corr.in
# Coarse unwrapped-phase estimate file name
# Coarse unwrapped-phase estimate file name (see possible file formats
# below). The array should have the same dimensions as the input
# wrapped phase array.
# ESTIMATEFILE snaphu.est.in
# Input cost file (for statistical costs). If costs are read from this
......@@ -58,6 +69,13 @@
# Costs are not dumped if no file is given.
# COSTOUTFILE snaphu.costoutfile
# Input file of signed binary byte (signed char) values. Values in
# the file should be either 0 or 1, with 0 denoting interferogram
# pixels that should be masked out and 1 denoting valid pixels. The
# array should have the same dimensions as the input wrapped phase
# array.
# BYTEMASKFILE snaphu.bytemask
# Text file to which runtime parameters will be logged. The format of
# that file will be suitable so that it can also be used as a
# configuration file.
......@@ -105,6 +123,7 @@
# Input file format
# Allowable formats:
# If the data are not complex, the phase should be in radians from 0 to 2pi.
# COMPLEX_DATA (default)
# ALT_LINE_DATA (magnitude in channel 1, phase in radians in channel 2)
# ALT_SAMPLE_DATA (magnitude in channel 1, phase in radians in channel 2)
......@@ -114,9 +133,9 @@
# Output file format
# Allowable formats:
# ALT_LINE_DATA (interferogram magnitude in channel 1,
# ALT_LINE_DATA (masked interferogram magnitude in channel 1,
# unwrapped phase in radians in channel 2; default)
# ALT_SAMPLE_DATA (interferogram magnitude in channel 1,
# ALT_SAMPLE_DATA (masked interferogram magnitude in channel 1,
# unwrapped phase in radians in channel 2)
# FLOAT_DATA (unwrapped phase in radians)
#
......@@ -520,19 +539,41 @@ MAXNEWNODECONST 0.0008
# is not given.
MAXCYCLEFRACTION 0.00001
# Determines how the source or root of the tree is chosen for the
# modified network-simplex solver. If SOURCEMODE is zero, the
# ground node is used as the root (usually fastest). Otherwise,
# SOURCEMODE should be 1 or -1, and the root is the endpoint of the
# longest chain of flow greater than or equal to the current flow
# increment, where the sign of SOURCEMODE determines which end of the
# chain is used.
SOURCEMODE 0
# Gives the minimum number of connected nodes to consider for
# unwrapping. If masking separates the input data into disconnected
# sets of pixels, a source is selected for each connected set,
# provided that the number of nodes in the set is greater than
# NCONNNODEMIN. If NCONNNODEMIN is zero, all possible unmasked pixels
# will be uwnrapped. NCONNNODEMIN should be nonnegative.
NCONNNODEMIN 0
# Scale factor (long) for cs2 MCF initializations. A larger number
# gives greater speed, but uses more memory.
CS2SCALEFACTOR 8
# Number of major iterations between tree pruning operations. A
# smaller number causes pruning operations to occur more frequently.
# This is experimental.
NMAJORPRUNE 2000000000
# Cost threshold for pruning tree. A lower threshold prunes more
# aggressively. This is experimental.
PRUNECOSTTHRESH 2000000000
# If this parameters is set, the cost functions are approximated by
# L^p cost functions with parameter p. That is, the cost functions
# are parameterized as (flow)^(PLPN), where p can be any nonnegative
# decimal. Statistical costs are generated in order to weight the Lp
# cost functions by default.
# PLPN 1
# If this parameter is set to TRUE, bidirectional Lp costs are assumed
# if PLPN is set. This implies that the scalar weight of an Lp arc
# may be different depending on the direction of net flow on the arc.
# If this parameter is FALSE, the weight is the same regardless of the
# arc direction.
# BIDIRLPN TRUE
##############################################
# File names for dumping intermediate arrays #
......@@ -574,6 +615,22 @@ CS2SCALEFACTOR 8
# CORRDUMPFILE snaphu.corr
###########################
# Edge masking parameters #
###########################
# These parameters (long, dimensionless) are used to mask out pixels
# near the edges of the input array. EDGEMASKTOP, EDGEMASKBOT,
# EDGEMASKLEFT, and EDGEMASKRIGHT specify the numbers of pixels from the
# top, bottom, left, and right edges respectively that should be
# masked out. Masking is only applied during the nonlinear solver
# stage (not the initialization).
# EDGEMASKTOP 0
# EDGEMASKBOT 0
# EDGEMASKLEFT 0
# EDGEMASKRIGHT 0
###############################
# Piece extraction parameters #
###############################
......@@ -633,20 +690,53 @@ CS2SCALEFACTOR 8
# The program will remove temporary tile files if this is set.
# RMTMPTILE FALSE
# If this is set to anything besides FALSE, the program will skip
# the unwrapping step and only assemble temporary tile files from a previous
# invocation saved in the directory whose name is given here. The tile size
# parameters and file names must be the same.
# ASSEMBLEONLY tiledir
# This is the name (string) of a file of signed character data types
# which serve as a mask for which tiles will be unwrapped. The file
# should be a raster array with NTILEROW rows and NTILECOL columns.
# Where the array element is nonzero, the corresponding tile will be
# unwrapped; where the array element is zero, the tile will not be
# unwrapped and no output for that tile will be written. This option
# is used for reprocessing only certain tiles of a run.
# DOTILEMASKFILE snaphu.dotilemaskfile.in
# This is the name of the tile directory. Tiles will be stored
# temporarily in the tile directory. If in assemble only mode,
# unwrapped tiles are assumed to reside in this directory. The
# directory is create if it does not exist.
# TILEDIR snaphu_tiledir
# If this is set to TRUE, the program will skip the unwrapping step
# and only assemble temporary tile files from a previous invocation
# saved in the directory whose name is given by the TILEDIR keyword.
# The tile size parameters and file names must be the same.
# ASSEMBLEONLY FALSE
# Repotimize as single tile after using tile mode for intialization if
# this is set to TRUE. This is equivalent to unwrapping with multiple
# tiles, then using the unwrapped output as the input to a new, single-tile run
# of snaphu with the -u option. The purpose is for speed.
#SINGLETILEREOPTIMIZE FALSE
###############################
# Connected component control #
###############################
# Grow connected components mask and write to output file specified.
# Grow connected components mask and write to the output file whose
# name is specified here as a string. The mask is a file of unsigned
# integer values with the same number of rows and columns as the
# unwrapped interferogram. The type of integer (1 byte vs. 4 byte) is
# specified by the CONNCOMPOUTTYPE keyword, with 1-byte integers being
# the default.
# CONNCOMPFILE snaphu.conncomp
# Type of integer that the connected-component output, if requested,
# will be written as (see the CONNCOMPFILE keyword). The value here
# may be either UCHAR or UINT, which specify unsigned character
# (1-byte integer) or unsigned integer (4-byte integer) values,
# respectively.
# CONNCOMPOUTTYPE UCHAR
# Grow connected components mask from unwrapped input then exit if TRUE.
# Output is written to the file specified by CONNCOMPFILE.
# REGROWCONNCOMPS FALSE
......@@ -662,6 +752,11 @@ CS2SCALEFACTOR 8
# Maximum number of connected components per tile (long).
# MAXNCOMPS 32
# Type to use for connected component output file. The value should
# either be UCHAR for unsigned character (8 bit) or UINT for unsigned
# integer (32 bit for common systems).
# CONNCOMPOUTTYPE UCHAR
# End of snaphu configuration file
snaphu (1.4.2-8) UNRELEASED; urgency=medium
snaphu (2.0.0-1) unstable; urgency=medium
* Team upload.
[ Bas Couwenberg ]
* Update gbp.conf to use --source-only-changes by default.
-- Bas Couwenberg <sebastic@debian.org> Sun, 07 Jul 2019 10:16:19 +0200
[ Antonio Valentino ]
* New upstream release.
* debian/copyright:
- update copyright date
* debian/rules:
- install changelog file
* debian/patches:
- drop 0001-fix-compilation-warnings.patch and
0002-man-page-hyphens.patch: no longer necessary
- refresh and renumber remaining patches
-- Antonio Valentino <antonio.valentino@tiscali.it> Sun, 07 Jul 2019 09:51:54 +0000
snaphu (1.4.2-7) unstable; urgency=medium
......
......@@ -5,7 +5,7 @@ Disclaimer: this package is in the non-free archive because parts of the
sources can be used only for noncommercial purposes
Files: *
Copyright: 2002 Board of Trustees, Leland Stanford Jr. University
Copyright: 2002-2019 Board of Trustees, Leland Stanford Jr. University
License: other
Except as noted below, permission to use, copy, modify, and
distribute, this software and its documentation for any purpose is
......
From: Debian GIS Project <pkg-grass-devel@lists.alioth.debian.org>
Date: Mon, 7 Aug 2017 21:34:46 +0000
Subject: fix-compilation-warnings
Fix a few compilation warning and also prevent a segfault when logging is enabled.
---
src/snaphu_cost.c | 8 ++++----
src/snaphu_cs2.c | 1 +
src/snaphu_io.c | 1 +
src/snaphu_solver.c | 4 ++--
src/snaphu_tile.c | 18 +++++++++---------
src/snaphu_util.c | 1 +
6 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/src/snaphu_cost.c b/src/snaphu_cost.c
index f7a14e1..339137b 100644
--- a/src/snaphu_cost.c
+++ b/src/snaphu_cost.c
@@ -40,11 +40,11 @@ void BuildCostArrays(void ***costsptr, short ***mstcostsptr,
outfileT *outfiles){
long row, col, maxcol, tempcost;
- long poscost, negcost, costtypesize;
+ long poscost, negcost, costtypesize=0;
float **pwr, **corr;
- short **weights, **rowweight, **colweight, **scalarcosts;
- void **costs, **rowcost, **colcost;
- void (*CalcStatCost)();
+ short **weights, **rowweight, **colweight, **scalarcosts=NULL;
+ void **costs, **rowcost=NULL, **colcost=NULL;
+ void (*CalcStatCost)()=NULL;
/* read weights */
weights=NULL;
diff --git a/src/snaphu_cs2.c b/src/snaphu_cs2.c
index 0c3f9b2..a9f4641 100644
--- a/src/snaphu_cs2.c
+++ b/src/snaphu_cs2.c
@@ -637,6 +637,7 @@ register double p_max, /* current maximal price */
i_price, /* price of node i */
dp; /* current arc partial residual cost */
+a_max = NULL;
p_max = price_min;
i_price = i -> price;
diff --git a/src/snaphu_io.c b/src/snaphu_io.c
index 812b79b..9f0beb1 100644
--- a/src/snaphu_io.c
+++ b/src/snaphu_io.c
@@ -19,6 +19,7 @@
#include <ctype.h>
#include <unistd.h>
#include <fcntl.h>
+#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
diff --git a/src/snaphu_solver.c b/src/snaphu_solver.c
index 09e284c..8c86c6f 100644
--- a/src/snaphu_solver.c
+++ b/src/snaphu_solver.c
@@ -53,7 +53,7 @@ long TreeSolve(nodeT **nodes, nodesuppT **nodesupp, nodeT *ground,
candidateT *candidatelist, *candidatebag, *tempcandidateptr;
nodeT *from, *to, *cycleapex, *node1, *node2, *leavingparent, *leavingchild;
nodeT *root, *mntpt, *oldmntpt, *skipthread, *tempnode1, *tempnode2;
- nodeT *firstfromnode, *firsttonode;
+ nodeT *firstfromnode=NULL, *firsttonode=NULL;
nodeT **apexlist;
float **unwrappedphase;
@@ -2203,7 +2203,7 @@ long DischargeTree(nodeT *source, short **mstcosts, short **flows,
signed char **residue, signed char **arcstatus,
nodeT **nodes, nodeT *ground, long nrow, long ncol){
- long row, col, todir, arcrow, arccol, arcdir;
+ long row, col=0, todir=0, arcrow, arccol, arcdir;
long arcnum, upperarcnum, ngroundarcs;
nodeT *from, *to, *nextnode;
nodesuppT **nodesupp;
diff --git a/src/snaphu_tile.c b/src/snaphu_tile.c
index 096040f..61719aa 100644
--- a/src/snaphu_tile.c
+++ b/src/snaphu_tile.c
@@ -172,9 +172,9 @@ void GrowRegions(void **costs, short **flows, long nrow, long ncol,
long i, row, col, maxcol;
long arcrow, arccol, arcnum, fromdist, arcdist;
long regioncounter, *regionsizes, regionsizeslen, *thisregionsize;
- long closestregiondist, closestregion, lastfromdist;
+ long closestregiondist, closestregion=0, lastfromdist;
long costthresh, minsize, maxcost;
- short **regions;
+ short **regions=NULL;
nodeT **nodes;
nodeT *source, *from, *to, *ground;
char regionfile[MAXSTRLEN];
@@ -887,8 +887,8 @@ void AssembleTiles(outfileT *outfiles, paramT *params,
long nlines, long linelen){
long tilerow, tilecol, ntilerow, ntilecol, ntiles, rowovrlp, colovrlp;
- long i, j, k, ni, nj, dummylong, costtypesize;
- long nrow, ncol, prevnrow, prevncol, nextnrow, nextncol;
+ long i, j, k, ni, nj, dummylong, costtypesize=0;
+ long nrow, ncol, prevnrow=0, prevncol, nextnrow, nextncol;
long n, ncycle, nflowdone, nflow, candidatelistsize, candidatebagsize;
long nnodes, maxnflowcycles, arclen, narcs, sourcetilenum, flowmax;
long *totarclens;
@@ -1195,7 +1195,7 @@ void ReadNextRegion(long tilerow, long tilecol, long nlines, long linelen,
void ***nextcostsptr,
long *nextnrowptr, long *nextncolptr){
- long nexttilelinelen, nexttilenlines, costtypesize;
+ long nexttilelinelen, nexttilenlines, costtypesize=0;
tileparamT nexttileparams[1];
outfileT nexttileoutfiles[1];
char nextfile[MAXSTRLEN], tempstring[MAXTMPSTRLEN];
@@ -1315,7 +1315,7 @@ void ReadEdgesAboveAndBelow(long tilerow, long tilecol, long nlines,
float *unwphaseabove, float *unwphasebelow,
void *costsabove, void *costsbelow){
- long ni, nj, readtilelinelen, readtilenlines, costtypesize;
+ long ni, nj, readtilelinelen, readtilenlines, costtypesize=0;
long ntilerow, ntilecol, rowovrlp, colovrlp;
tileparamT tileparams[1];
outfileT outfilesabove[1], outfilesbelow[1];
@@ -1487,7 +1487,7 @@ void TraceRegions(short **regions, short **nextregions, short **lastregions,
short *nscndryarcs, long *totarclens, short **bulkoffsets,
paramT *params){
- long i, j, row, col, nnrow, nncol, tilenum, costtypesize;
+ long i, j, row, col, nnrow, nncol, tilenum, costtypesize=0;
long nnewnodes, nnewarcs, npathsout, flowmax, totarclen;
long nupdatednontilenodes, updatednontilenodesize, ntilecol;
short **flows;
@@ -2383,7 +2383,7 @@ void TraceSecondaryArc(nodeT *primaryhead, nodeT **scndrynodes,
long mincost, mincostflow;
long *scndrycostarr;
long double templongdouble;
- double sigsq, sumsigsqinv, tempdouble, tileedgearcweight;
+ double sigsq=0, sumsigsqinv, tempdouble, tileedgearcweight;
short **flows;
void **costs;
nodeT *tempnode, *primarytail, *scndrytail, *scndryhead;
@@ -2922,7 +2922,7 @@ void IntegrateSecondaryFlows(long linelen, long nlines, nodeT **scndrynodes,
FILE *outfp;
float **unwphase, **tileunwphase, **mag, **tilemag;
float *outline;
- long row, col, colstart, nrow, ncol, nnrow, nncol, maxcol;
+ long row, col, colstart, nrow=0, ncol, nnrow, nncol, maxcol;
long readtilelinelen, readtilenlines, nextcoloffset, nextrowoffset;
long tilerow, tilecol, ntilerow, ntilecol, rowovrlp, colovrlp;
long ni, nj, tilenum;
diff --git a/src/snaphu_util.c b/src/snaphu_util.c
index bb1422d..e66189b 100644
--- a/src/snaphu_util.c
+++ b/src/snaphu_util.c
@@ -18,6 +18,7 @@
#include <ctype.h>
#include <unistd.h>
#include <fcntl.h>
+#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
......@@ -6,29 +6,57 @@ CFLAGS setup has been modified to extent the settings of the external
environment.
CPPFLAGS and LDFLAGS are now used during the build phase.
---
src/Makefile | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
src/Makefile | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/Makefile b/src/Makefile
index d008a0b..93b3762 100644
index 2e20b76..c5fc6f2 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -13,8 +13,8 @@
@@ -1,4 +1,4 @@
-# Makefile for statistical-cost network-flow algorithm for phase unwrapping
+# Makefile for statistical-cost network-flow algorithm for phase unwrapping
# Curtis W. Chen
# Copyright 2002,2017 Board of Trustees, Leland Stanford Jr. University
@@ -6,18 +6,18 @@
# need, and the directory (BINDIR) in which the produced binary should
# be written.
#
-# If you want to copy the man page and executable to a system directory,
-# specify the appropriate directories in the INSTALLDIR and MANDIR
+# If you want to copy the man page and executable to a system directory,
+# specify the appropriate directories in the INSTALLDIR and MANDIR
# variables and do 'make install' (you will probably need to be root).
#
# If you specify -D NO_CS2, the program will be compiled without the
# CS2 MCF solver module.
-CC = cc
-CFLAGS = -O3 # -D NO_CS2
+#CC = cc
+CFLAGS += -O3 # -D NO_CS2
LIBS = -lm
OPTIMFLAGS = -O3
DEBUGFLAGS = -ggdb
-CFLAGS = $(OPTIMFLAGS) -Wall # -Wuninitialized -m64 -D NO_CS2
-LIBS = -lm
+CFLAGS += $(OPTIMFLAGS) -Wall # -Wuninitialized -m64 -D NO_CS2
+LIBS = -lm
BINDIR = ../bin
INSTALLDIR = /usr/local/bin
@@ -32,7 +32,7 @@ OBJS = snaphu_tile.o \
MANDIR = /usr/local/man
@@ -28,14 +28,14 @@ OBJS = snaphu_tile.o \
snaphu_io.o \
snaphu_util.o \
snaphu_cost.o \
- snaphu_cs2.o
+ snaphu_cs2.o
.PHONY: all
all: $(SNAPHU)
$(SNAPHU): snaphu.c $(OBJS) snaphu.h Makefile
-$(SNAPHU): snaphu.c $(OBJS) snaphu.h Makefile
- $(CC) $(CFLAGS) \
+$(SNAPHU): snaphu.c $(OBJS) snaphu.h Makefile
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) \
snaphu.c \
$(OBJS) \
......
......@@ -3,14 +3,28 @@ Date: Sat, 23 Feb 2019 15:42:54 +0000
Subject: Spelling
---
man/man1/snaphu.1 | 2 +-
src/snaphu.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/man/man1/snaphu.1 b/man/man1/snaphu.1
index 161cc25..a4ed3c9 100644
--- a/man/man1/snaphu.1
+++ b/man/man1/snaphu.1
@@ -464,7 +464,7 @@ initialization to the modified network-simplex solver:
.fi
.PP
Note that in the previous two examples, the output file name in the
-configuration file is overrided by the one given on the command line.
+configuration file is overridden by the one given on the command line.
The previous two commands together are in principle equivalent to the
preceding one, although round-off errors in flow-to-phase conversions
may cause minor differences
diff --git a/src/snaphu.h b/src/snaphu.h
index 99fc3f9..571a617 100644
index 3a9ab8d..6ec5974 100644
--- a/src/snaphu.h
+++ b/src/snaphu.h
@@ -364,7 +364,7 @@
@@ -406,7 +406,7 @@
"The parts of this software derived from the CS2 minimum cost flow\n"\
"solver written by A. V. Goldberg and B. Cherkassky are governed by the\n"\
"terms of the copyright holder of that software. Permission has been\n"\
......
From: Debian GIS Project <pkg-grass-devel@lists.alioth.debian.org>
Date: Mon, 7 Aug 2017 21:34:46 +0000
Subject: man-page-hyphens
Escape hyphens in the manpage.
---
man/man1/snaphu.1 | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/man/man1/snaphu.1 b/man/man1/snaphu.1
index 8cf83f1..f1befef 100644
--- a/man/man1/snaphu.1
+++ b/man/man1/snaphu.1
@@ -348,15 +348,15 @@ file whose name is compiled into the program):
.fi
Unwrap the same file as above, but use brightness information from the
-file ``ampfile,'' set the perpendicular baseline to -165 m at
+file ``ampfile,'' set the perpendicular baseline to \-165 m at
midswath, and place the output in a file called ``unwrappedfile''
(coherence data are generated automatically if ``wrappedfile''
contains complex data and ``ampfile'' contains amplitude data from
both SAR images):
.nf
- snaphu wrappedfile 1024 -a ampfile \\\
- -b -165 -o unwrappedfile
+ snaphu wrappedfile 1024 \-a ampfile \\\
+ \-b \-165 \-o unwrappedfile
.fi
Unwrap the interferogram as above, but read correlation
@@ -364,8 +364,8 @@ information from the file ``corrfile'' instead of generating it from
the interferogram and amplitude data:
.nf
- snaphu wrappedfile 1024 -a ampfile -c corrfile \\\
- -b -165 -o unwrappedfile
+ snaphu wrappedfile 1024 \-a ampfile \-c corrfile \\\
+ \-b \-165 \-o unwrappedfile
.fi
The following is equivalent to the previous example, but input
@@ -377,29 +377,29 @@ displayed:
# This is a comment line which will be ignored
AMPFILE ampfile
CORRFILE corrfile
- BPERP -165
+ BPERP \-165
OUTFILE unwrappedfile
<Ctrl-D>
- snaphu -v -f configfile wrappedfile 1024
+ snaphu \-v \-f configfile wrappedfile 1024
.fi
Unwrap the same interferogram, but use only the MST initialization
(with scalar statistical weights) and write the output to ``mstfile'':
.nf
- snaphu -f configfile -i wrappedfile 1024 -o mstfile
+ snaphu \-f configfile \-i wrappedfile 1024 \-o mstfile
.fi
Read the unwrapped data in ``mstfile'' and use that as the
initialization to the modified network-simplex solver:
.nf
- snaphu -f configfile -u mstfile 1024 -o unwrappedfile
+ snaphu \-f configfile \-u mstfile 1024 \-o unwrappedfile
.fi
Note that in the previous two examples, the output file name in the
-configuration file is overrided by the one given on the command line.
+configuration file is overridden by the one given on the command line.
The previous two commands together are in principle equivalent to the
preceding one, although round-off errors in flow-to-phase conversions
may cause minor differences
@@ -408,7 +408,7 @@ Unwrap the interferogram as above, but use the MCF algorithm for
initialization:
.nf
- snaphu -f configfile wrappedfile 1024 --mcf
+ snaphu \-f configfile wrappedfile 1024 \--mcf
.fi
Unwrap the interferogram once again, but first flatten it with the
@@ -416,7 +416,7 @@ unwrapped data in ``estfile,'' then reinsert the subtracted phase
after unwrapping:
.nf
- snaphu -f configfile wrappedfile 1024 -e estfile
+ snaphu \-f configfile wrappedfile 1024 \-e estfile
.fi
The following assumes that the wrapped input interferogram measures
@@ -424,14 +424,14 @@ deformation, not topography. Unwrap the interferogram with the given
correlation data:
.nf
- snaphu -d wrappedfile 1024 -c corrfile
+ snaphu \-d wrappedfile 1024 \-c corrfile
.fi
Unwrap the input interferogram by minimizing the unweighted congruent
L2 norm:
.nf
- snaphu -p 2 -n wrappedfile 1024
+ snaphu \-p 2 \-n wrappedfile 1024
.fi
Unwrap the interferogram as a three-by-four set of tiles that overlap
@@ -439,8 +439,8 @@ by 30 pixels, with the specified configuration file, using two
processors:
.nf
- snaphu wrappedfile 1024 -f configfile \\\
- --tile 3 4 30 30 --nproc 2
+ snaphu wrappedfile 1024 \-f configfile \\\
+ \--tile 3 4 30 30 \--nproc 2
.fi
.SH "HINTS AND TIPS"
0001-fix-compilation-warnings.patch
0002-man-page-hyphens.patch
0003-hardening.patch
0004-Spelling.patch
0001-hardening.patch
0002-Spelling.patch
......@@ -20,6 +20,9 @@ override_dh_auto_build:
override_dh_auto_install:
dh_auto_install --sourcedirectory=src -- INSTALLDIR=../debian/snaphu/usr/bin/ MANDIR=../debian/snaphu/usr/share/man
override_dh_installchangelogs:
dh_installchangelogs -k README_releasenotes.txt
override_dh_auto_clean:
dh_auto_clean --sourcedirectory=src
$(MAKE) -C src clobber
......
......@@ -18,10 +18,10 @@ solver routine is based on network optimization. By default,
(SAR) interferogram measuring surface topography. Deformation
measurements are assumed if the \fB\-d\fR option is given. Smooth,
generic data are assumed if the \fB\-s\fR option is given.
This man page documents only \fBsnaphu\fR's syntax and usage. Its
.PP
This man page documents only the syntax and usage of \fBsnaphu\fR. Its
theoretical foundations are discussed in the references cited below.
.PP
The most common input parameters may be given on the command line,
while many other twiddle parameters are handled via the \fB\-f\fR
option and configuration files. At the very least, the name of a
......@@ -30,7 +30,7 @@ should increase towards the right in the interferogram, and the
flat-earth phase ramp should be removed from the input interferogram
before \fBsnaphu\fR is run. For deformation interferograms, phase
variations due to topography should be removed as well.
.PP
Except for the input file name and the line length, all input
parameters take default values if not specified. However, these
parameters should be customized whenever possible since the accuracy
......@@ -40,15 +40,15 @@ strongly encouraged to provide their best estimates of the relevant
problem parameters. Parameters are set in the order in which they are
given on the command line, so multiple configuration files or options
may be given, with later values overriding earlier ones.
.PP
Allowable file formats are detailed below. The default format for the
input file is COMPLEX_DATA, but any of the described formats may be
used. If either of the ALT_LINE_DATA or ALT_SAMPLE_DATA formats are
used, the magnitude and phase (in radians) of the interferogram should
be in the first and second channels of the file, respectively. If the
FLOAT_DATA format is used, the input file should contain only the
phase of the interferogram (in radians); the magnitude may be passed
with the \fB\-m\fR option.
used, the magnitude and phase (in radians from 0 to 2pi) of the
interferogram should be in the first and second channels of the file,
respectively. If the FLOAT_DATA format is used, the input file should
contain only the phase of the interferogram (in radians from 0 to
2pi); the magnitude may be passed with the \fB\-m\fR option.
.SH OPTIONS
.TP
\fB\-a\fP \fIampfile\fP
......@@ -95,6 +95,21 @@ correlation data should be in the second data channel of the file; the
first channel is ignored. The FLOAT_DATA format may also be used.
The correlation values should be between zero and one, inclusive.
.TP
\fB\-C\fP \fIconfigstr\fP
Parse the string \fIconfigstr\fP as if it were a line from a
configuration file containing a keyword-value pair (see the \fB-f\fP
option). Configuration lines generally have whitespace between the
keyword and the value, so \fIconfigstr\fP will usually need to be
surrounded by quotation marks on a command line so that the shell does
not split it into separate arguments (\fBsnaphu\fR itself does not
require or allow quotation marks, however). The syntax for how
quotation marks are handled is defined by the shell. Multiple
instances of the \fB-C\fP option may be used in order to specify
multiple configuration inputs. Later instances of the \fB-C\fP option
take precedence over both earlier instances of the \fB-C\fP option and
the configurations specified by earlier instances of the \fB-f\fP
option.
.TP
.B \-d
Run in deformation mode. The problem statistics and resulting cost
functions are based on the assumption that the true unwrapped phase
......@@ -132,7 +147,7 @@ unwrapped in a relative, internally self-consistent manner according
to the statistical costs used. Regions that are smaller than a
preselected threshold are masked out. Parameters for this option can
be set in the configuration file. The connected component file is
composed of unsigned characters, with all pixels of the same value
composed of unsigned characters by default, with all pixels of the same value
belonging to the same connected component and zero corresponding to
masked pixels.
.TP
......@@ -143,7 +158,7 @@ mask to the file \fImaskfile\fP. Statistical cost functions are
computed for forming the mask, but a new unwrapped solution is not
computed.
.TP
.B \-h
.B \-h, \-\-help
Print a help message summarizing command-line options and exit.
.TP
.B \-i
......@@ -154,6 +169,13 @@ iterative, modified network-simplex solver. If \fB\-i\fP is given,
the initialization is written to the output and the program exits
without running the iterative solver.
.TP
.B \-k
Keep temporary tile outputs. If this option is specified when
\fBsnaphu\fP runs in tile mode, the temporary directory where tile
outputs are stored will be left in place rather than deleted. The
tile-mode initialization of the \fB-S\fP option will also be left in
place rather than deleted.
.TP
\fB\-l\fP \fIlogfile\fP
Log all runtime parameters and some other environment information into
the specified file. The log file is a text file in the same format as
......@@ -168,7 +190,21 @@ appropriate amplitude data are given as well. The default file format
is FLOAT_DATA. If the formats ALT_LINE_DATA or ALT_SAMPLE_DATA are
used, the magnitude should be in the first data channel of the file;
the second channel is ignored. If the COMPLEX_DATA format is used,
the phase information is ignored.
the phase information is ignored. Areas where the magnitude is zero
are treated as masked areas (see the \fB\-M\fP option).
.TP
\fB\-M\fP \fIbytemaskfile\fP
Read a byte mask from the specified file. The mask file should be the
same size as the input array to be unwrapped. The mask should have
the binary (not ASCII) value 0 where pixels of the input array are to
be ignored during the primary optimization stage of the program.
Values elsewhere should be binary 1. Masking is not applied until
after the initialization stage of \fBsnaphu\fP. Masked areas are
treated as areas in which the solution phase value is irrelevant to
the solution cost. The magnitude of the interferogram is set to zero
in masked areas in the output file. Areas with zero magnitude in the
input data are treated as masked areas as well. Areas near the edges
of the input may also be masked via options in a configuration file.
.TP
.B \-n
Run in no-statistical-costs mode. If the \fB\-i\fP or \fB\-p\fP
......@@ -177,8 +213,8 @@ Information from a weight file (\fB\-w\fP option) will still be used
if given.
.TP
\fB\-o\fP \fIoutfile\fP
Write the unwrapped output to file called \fIoutfile\fP. If the file
formats ALT_LINE_DATA (default) or ALT_SAMPLE_DATA are used, the
Write the unwrapped output to a file called \fIoutfile\fP. If the
file formats ALT_LINE_DATA (default) or ALT_SAMPLE_DATA are used, the
unwrapped phase is written into the second data channel, while the
interferogram magnitude is written into the first channel. The format
FLOAT_DATA may also be used.
......@@ -207,6 +243,21 @@ cost functions are based on the assumption that the true unwrapped
phase represents a generic surface with no discontinuities. This is
the same as deformation mode with the DEFOMAX parameter set to zero.
.TP
.B \-S
Do single-tile re-optimization after tile-mode initialization. If
this option is specified, \fBsnaphu\fP will run in tile mode to
generate an unwrapped solution, which is then used as the
initialization to a single-tile optimization that produces the final
unwrapped output. The tile-mode initialization may itself be
initialized by the MST or MCF algorithms (or an input unwrapped phase
file) as normal. This option is equivalent to running an instance of
\fBsnaphu\fP in tile mode, then running another instance of
\fBsnaphu\fP taking the tile-mode output as an unwrapped input via the
\fB-u\fP option. Tile parameters must be specified when using this
option. This approach is often faster than unwrapping an
interferogram as a single tile from an MST initialization, especially
if multiple processors are used.
.TP
.B \-t
Run in topography mode. The problem statistics and resulting cost
functions are based on the assumption that the true unwrapped phase
......@@ -246,12 +297,18 @@ the \fB\-a\fP option.
Similar to the \fB\-\-aa\fP option, but power data are read from the
specified files.
.TP
\fB\-\-assemble \fIdirname\fP
Assemble the tile-mode temporary files in the specified directory.
Most configuration options (from the command line and any
configuration files) must be specified. This option is useful
if the user wishes to modify tile-assembly parameters without
unwrapping the individual tiles over again.
\fB\-\-assemble
Assemble the tile-mode temporary files from a previous tile-mode run
of \fBsnaphu\fP, possibly with different secondary optimization
parameters, to produce a new unwrapped solution. The tile directory
name must be specified with the \fB\-\-tiledir\fP option. Most
configuration options (from the command line and any configuration
files) must be specified similar to the previous run, including the
output file name from which the names of temporary tile files are
derived. The previous output file may hence be overwritten by the new
output file. This option is useful if the user wishes to modify
tile-assembly parameters without unwrapping the individual tiles over
again.
.TP
.B \-\-copyright, \-\-info
Print the software copyright notice and bug report info, then exit.
......@@ -286,7 +343,7 @@ cs2 solver, though in principle both should be L1 optimal.
Use \fIn\fP parallel processes when in tile mode. The program forks a
new process for each tile so that tiles can be unwrapped in parallel;
at most \fIn\fP processes will run concurrently. Forking is done
before data is read. The standard output streams of child processes
before data are read. The standard output streams of child processes
are directed to log files in the temporary tile directory.
.TP
.B \-\-piece \fIfirstrow firstcol nrow ncol\fP
......@@ -304,18 +361,26 @@ is unwrapped independently. Tiles overlap by \fIrowovrlp\fP and
\fIcolovrlp\fP pixels in the row and column directions. The tiles are
then segmented into reliable regions based on the cost functions, and
the regions are reassembled. The program creates a subdirectory for
temporary files in the directory of the eventual output file. This
option is currently enabled only for statistical cost functions.
temporary files in the directory of the eventual output file (see the
\fB\-\-tiledir\fP and \fB-k\fP options). Tiles can be unwrapped in
parallel (see the \fB\-\-nproc\fP option).
.TP
.B \-\-tiledir \fIdirname\fP
Use \fIdirname\fP as the name of the directory in which temporary
tile-model outputs are written and/or read. The directory is created
if it does not exist, and it is removed at the end of the run unless
the \fB-k\fP or \fB\-\-assemble\fP options are specified.
.SH FILE FORMATS
The formats of input files may be specified in a configuration file.
All of these formats are composed of raster, single-precision (float,
real*4, or complex*8) floating-point data types in the platform's
native byte order. Data are read line by line (across then down).
Regardless of the file format, all input data arrays should have the
same number of samples in width and depth and should be coregistered
to one another. Note that weight files and cost files have their own
formats. The allowable formats for other data files are described
below.
native byte order. Data are read line by line in row-major order
(across then down, with the column index varying faster than the row
index). Regardless of the file format, all input data arrays should
have the same number of samples in width and depth and should be
coregistered to one another. Note that weight files and cost files
have their own formats. The allowable formats for other data files
are described below.
.TP
COMPLEX_DATA
Alternating floats correspond to the real (in-phase) and imaginary
......@@ -327,8 +392,8 @@ ALT_LINE_DATA
Alternating lines (rows) of data correspond to lines of purely real
data from two separate arrays. The first array is often the magnitude
of the interferogram, and the second may be unwrapped phase,
coherence, etc. This is also sometimes called \fBhgt\fP or
line-interleaved format.
coherence, etc. This is also sometimes called \fBhgt\fP, \fBrmg\fP,
or line-interleaved format.
.TP
ALT_SAMPLE_DATA
Alternating samples correspond to purely real samples from two
......@@ -342,36 +407,36 @@ purely real.
Unwrap a wrapped topographic interferogram called ``wrappedfile''
whose line length is 1024 complex samples (output will be written to a
file whose name is compiled into the program):
.PP
.nf
snaphu wrappedfile 1024
.fi
.PP
Unwrap the same file as above, but use brightness information from the
file ``ampfile,'' set the perpendicular baseline to -165 m at
midswath, and place the output in a file called ``unwrappedfile''
(coherence data are generated automatically if ``wrappedfile''
contains complex data and ``ampfile'' contains amplitude data from
both SAR images):
.PP
.nf
snaphu wrappedfile 1024 -a ampfile \\\
snaphu wrappedfile 1024 -a ampfile \e
-b -165 -o unwrappedfile
.fi
.PP
Unwrap the interferogram as above, but read correlation
information from the file ``corrfile'' instead of generating it from
the interferogram and amplitude data:
.PP
.nf
snaphu wrappedfile 1024 -a ampfile -c corrfile \\\
snaphu wrappedfile 1024 -a ampfile -c corrfile \e
-b -165 -o unwrappedfile
.fi
.PP
The following is equivalent to the previous example, but input
parameters are read from a configuration file, and verbose output is
displayed:
.PP
.nf
cat > configfile
# This is a comment line which will be ignored
......@@ -379,70 +444,70 @@ displayed:
CORRFILE corrfile
BPERP -165
OUTFILE unwrappedfile
<Ctrl-D>
EOF (ie, Ctrl-D)
snaphu -v -f configfile wrappedfile 1024
.fi
.PP
Unwrap the same interferogram, but use only the MST initialization
(with scalar statistical weights) and write the output to ``mstfile'':
.PP
.nf
snaphu -f configfile -i wrappedfile 1024 -o mstfile
.fi
.PP
Read the unwrapped data in ``mstfile'' and use that as the
initialization to the modified network-simplex solver:
.PP
.nf
snaphu -f configfile -u mstfile 1024 -o unwrappedfile
.fi
.PP
Note that in the previous two examples, the output file name in the
configuration file is overrided by the one given on the command line.
The previous two commands together are in principle equivalent to the
preceding one, although round-off errors in flow-to-phase conversions
may cause minor differences
.PP
Unwrap the interferogram as above, but use the MCF algorithm for
initialization:
.PP
.nf
snaphu -f configfile wrappedfile 1024 --mcf
.fi
.PP
Unwrap the interferogram once again, but first flatten it with the
unwrapped data in ``estfile,'' then reinsert the subtracted phase
after unwrapping:
.PP
.nf
snaphu -f configfile wrappedfile 1024 -e estfile
.fi
.PP
The following assumes that the wrapped input interferogram measures
deformation, not topography. Unwrap the interferogram with the given
correlation data:
.PP
.nf
snaphu -d wrappedfile 1024 -c corrfile
.fi
.PP
Unwrap the input interferogram by minimizing the unweighted congruent
L2 norm:
.PP
.nf
snaphu -p 2 -n wrappedfile 1024
.fi
.PP
Unwrap the interferogram as a three-by-four set of tiles that overlap
by 30 pixels, with the specified configuration file, using two
processors:
.PP
.nf
snaphu wrappedfile 1024 -f configfile \\\
snaphu wrappedfile 1024 -f configfile \e
--tile 3 4 30 30 --nproc 2
.fi
.PP
.SH "HINTS AND TIPS"
The program may print a warning message about costs being clipped to
avoid overflow. If too many costs are clipped, the value of COSTSCALE
......@@ -451,7 +516,7 @@ option). If the program prints a warning message about an unexpected
increase in the total solution cost, this is an indication that too
many costs are clipped. It is usually okay if just a few costs are
clipped.
.PP
In topography mode, if the unwrapped result contains too many
discontinuities, try increasing the value of LAYMINEI or decreasing
the value of LAYCONST. The former determines the normalized intensity
......@@ -462,7 +527,7 @@ ratio of azimuth to range costs. If the baseline is not known, take a
guess at it and be sure its sign is correct. Specify the SAR imaging
geometry parameters as well as possible. The defaults assume ERS data
with five looks taken in azimuth.
.PP
In deformation mode, if the unwrapped result contains too many
discontinuities, try increasing the value of DEFOTHRESHFACTOR or
decreasing the value of DEFOCONST. If the surface displacement varies
......@@ -472,7 +537,7 @@ option. The resulting cost functions will be similar to
correlation-weighted L2 cost functions, though the former are not
necessarily centered on the wrapped gradients. Congruence is still
enforced during rather than after optimization.
.PP
The program can be run in initialize-only (\fB\-i\fR) mode for quick
down-and-dirty MST or MCF solutions.
.SH SIGNALS
......@@ -506,41 +571,45 @@ configuration file if such a file is named when the program is
compiled.
.SH BUGS
The \fB\-w\fR option has not been tested exhaustively.
.PP
Extreme shadow discontinuities (i.e., abrupt elevation drops in
increasing range due to cliffs facing away from the radar) are not
modeled that well in the cost functions for topography mode.
.PP
Abrupt changes in surface reflectivity, such as those of coastlines
between bright land and dark water, might be misinterpreted as layover
and assigned inappropriate costs.
.PP
The algorithm's behavior may be unpredictable if the costs are badly
scaled and excessively clipped to fit into their short-integer data
types.
.PP
There is no error checking that ensures that the network node
potentials (incost and outcost) do not overflow their long-integer
potentials (incost and outcost) do not overflow their integer
data types.
.PP
Automatic flow clipping is built into the MST initialization, but it
can give erratic results and may loop infinitely for certain input
data sets. It is consequently turned off by default.
.PP
Dedicated programs for specific Lp objective functions may work better
than \fBsnaphu\fR in Lp mode. Note that snaphu enforces congruence as
part of the problem formulation, however, not as a post-optimization
processing step.
than \fBsnaphu\fR in Lp mode. Note that \fBsnaphu\fR enforces
congruence as part of the problem formulation, however, not as a
post-optimization processing step.
.PP
A tree pruning capability is built into the code and can be enabled
from a configuration file, but this functionality is experimental and
not well tested.
.SH REFERENCES
C. W. Chen and H. A. Zebker, ``Two-dimensional phase unwrapping with
use of statistical models for cost functions in nonlinear
optimization,'' \fIJournal of the Optical Society of America A\fP,
\fB18\fP, 338-351 (2001).
.PP
C. W. Chen and H. A. Zebker, ``Network approaches to two-dimensional
phase unwrapping: intractability and two new algorithms,'' \fIJournal
of the Optical Society of America A\fP, \fB17\fP, 401-414 (2000).
.PP
C. W. Chen and H. A. Zebker, ``Phase unwrapping for large SAR
interferograms: Statistical segmentation and generalized network
models,'' \fIIEEE Transactions on Geoscience and Remote Sensing\fP,
......
This diff is collapsed.
This diff is collapsed.
*.o
old
q
qq
qqq
temp
temp.c
*~
# Makefile for statistical-cost network-flow algorithm for phase unwrapping
# Curtis W. Chen
# Copyright 2002 Board of Trustees, Leland Stanford Jr. University
# Copyright 2002,2017 Board of Trustees, Leland Stanford Jr. University
# Specify your compiler (CC), whatever compiler flags (CFLAGS) you
# need, and the directory (BINDIR) in which the produced binary should
......@@ -14,7 +14,9 @@
# CS2 MCF solver module.
CC = cc
CFLAGS = -O3 # -D NO_CS2
OPTIMFLAGS = -O3
DEBUGFLAGS = -ggdb
CFLAGS = $(OPTIMFLAGS) -Wall # -Wuninitialized -m64 -D NO_CS2
LIBS = -lm
BINDIR = ../bin
INSTALLDIR = /usr/local/bin
......@@ -29,6 +31,7 @@ OBJS = snaphu_tile.o \
snaphu_cs2.o
.PHONY: all
all: $(SNAPHU)
$(SNAPHU): snaphu.c $(OBJS) snaphu.h Makefile
......@@ -38,6 +41,10 @@ $(SNAPHU): snaphu.c $(OBJS) snaphu.h Makefile
-o $(SNAPHU) \
$(LIBS)
.PHONY: gdebug
gdebug: snaphu.c snaphu_tile.c snaphu_solver.c snaphu_io.c snaphu_util.c snaphu_cost.c snaphu_cs2.c snaphu.h
$(CC) $(DEBUGFLAGS) snaphu.c snaphu_tile.c snaphu_solver.c snaphu_io.c snaphu_util.c snaphu_cost.c snaphu_cs2.c -o $(SNAPHU) $(LIBS)
install: $(SNAPHU)
cp $(SNAPHU) $(INSTALLDIR);
cp $(SNAPHUMAN) $(MANDIR)/man1/
......
This diff is collapsed.
This diff is collapsed.