-
Notifications
You must be signed in to change notification settings - Fork 4
/
getResidues.m
63 lines (55 loc) · 2.15 KB
/
getResidues.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
% =========================================================================
% Copyright: WZP
% Filename: getResidues.m
% Description: If you use this code, please cite:
% Wu, Zhipeng, et al. "Deep-learning based phase discontinuity prediction for two-dimensional phase unwrapping of SAR interferograms." IEEE Transactions on Geoscience and Remote Sensing (2021).
% Wu, Zhipeng, et al. "Deep Learning for the Detection and Phase Unwrapping of Mining-Induced Deformation in Large-Scale Interferograms." IEEE Transactions on Geoscience and Remote Sensing 60 (2021): 1-18.
%
% @author: wuzhipeng
% @email: 763008300@qq.com
% @website: https://wwzp.weebly.com/
% @create on: 14-Feb-2020 11:09:05
% @version: Matlab 9.4.0.813654 (R2018a)
% =========================================================================
%getResidues Calculate residual points
% [a,b] = getResidues(w, plotFlag)
% Returns the [row, column, value] of negative (a) and positive (b) residual points
%
% residues = getResidues(w, plotFlag)
% Returns the residual points in a matrix, which size is the same as w
function [a,b] = getResidues(w, plotFlag)
if nargin<1
help getResidues
return
end
if nargin<2
plotFlag = 0;
end
Infinitesimal = 1e-9;
[M,N]=size(w);
m=M-1;n=N-1;
tmp11 = w(1:m,1:n);
tmp12 = w(1:m,2:N);
tmp21 = w(2:M,1:n);
tmp22 = w(2:M,2:N);
errorP=wrapToPi(tmp12-tmp11)+...
wrapToPi(tmp22-tmp12)+...
wrapToPi(tmp21-tmp22)+...
wrapToPi(tmp11-tmp21);
a = [[errorP zeros(m,1)]; zeros(1,N)];
if nargout==2
[x,y] = find(errorP<-Infinitesimal);
a = [x+0.5,y+0.5,errorP(sub2ind(size(errorP),x,y))];
[x,y] = find(errorP>Infinitesimal);
b = [x+0.5,y+0.5,errorP(sub2ind(size(errorP),x,y))];
end
if plotFlag
if ~exist('b','var')
[x,y] = find(errorP<-Infinitesimal);
a = [x+0.5,y+0.5,errorP(sub2ind(size(errorP),x,y))];
[x,y] = find(errorP>Infinitesimal);
b = [x+0.5,y+0.5,errorP(sub2ind(size(errorP),x,y))];
end
hold on;scatter(a(:,2),a(:,1),20,'b','filled','Marker','o','MarkerEdgeColor','k');
hold on;scatter(b(:,2),b(:,1),20,'r','filled','Marker','o','MarkerEdgeColor','k');
end