Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LightFieldCodingLibrary
SR
Commits
d8c39e9f
Commit
d8c39e9f
authored
6 years ago
by
DIB Elian
Browse files
Options
Downloads
Patches
Plain Diff
Small fixes for llra
parent
1618a6fb
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
pinvUpdate.m
+0
-7
0 additions, 7 deletions
pinvUpdate.m
warp.m
+8
-6
8 additions, 6 deletions
warp.m
warpLRA.m
+4
-71
4 additions, 71 deletions
warpLRA.m
warpLRASet.m
+3
-3
3 additions, 3 deletions
warpLRASet.m
warpLRAUpdate.m
+6
-4
6 additions, 4 deletions
warpLRAUpdate.m
with
21 additions
and
91 deletions
pinvUpdate.m
+
0
−
7
View file @
d8c39e9f
...
...
@@ -4,11 +4,9 @@ function [dX,dY] = pinvUpdate(Value,Mask,Value_,varargin)
p
=
inputParser
;
p
.
KeepUnmatched
=
true
;
p
.
StructExpand
=
true
;
p
.
addParameter
(
'constrained'
,
false
,
@
islogical
);
p
.
addParameter
(
'relative'
,
true
,
@
islogical
);
p
.
parse
(
varargin
{:});
constrained
=
p
.
Results
.
constrained
;
relative
=
p
.
Results
.
relative
;
%% Constants
projSize
=
size
(
Value
);
...
...
@@ -54,11 +52,6 @@ if constrained
dX
=
dXdY
(
1
);
dY
=
dXdY
(
2
);
if
relative
dX
=
dX
*
u
;
dY
=
dY
*
v
;
end
else
%% Compute jacobian
LFxMat
=
LF
.
LFToMat
(
LFx
);
...
...
This diff is collapsed.
Click to expand it.
warp.m
+
8
−
6
View file @
d8c39e9f
function
[
Value
,
Mask
,
Pos
,
dX
,
dY
]
=
warp
(
Value
,
Mask
,
Pos
,
dX
,
dY
,
varargin
)
function
[
Value
,
Mask
,
Pos
,
dX
,
dY
,
initMask
]
=
warp
(
Value
,
Mask
,
Pos
,
dX
,
dY
,
varargin
)
%WARP Summary of this function goes here
% Detailed explanation goes here
...
...
@@ -18,7 +18,7 @@ backproject = p.Results.backproject;
%% Compute reference grid
% Reference size
Size
=
size
(
Value
);
End
=
size
(
Value
);
% Mask bounding box
gv
=
subarrayIdx
(
Mask
);
...
...
@@ -52,8 +52,8 @@ if backproject
minSRX
=
floor
(
min
(
SRX
(
tempMask
)));
maxSRX
=
ceil
(
max
(
SRX
(
tempMask
)));
minSRY
=
floor
(
min
(
SRY
(
tempMask
)));
maxSRY
=
ceil
(
max
(
SRY
(
tempMask
)));
minSRX
=
max
(
minSRX
,
1
);
maxSRX
=
min
(
maxSRX
,
Size
(
3
));
minSRY
=
max
(
minSRY
,
1
);
maxSRY
=
min
(
maxSRY
,
Size
(
4
));
minSRX
=
max
(
minSRX
,
1
);
maxSRX
=
min
(
maxSRX
,
End
(
3
));
minSRY
=
max
(
minSRY
,
1
);
maxSRY
=
min
(
maxSRY
,
End
(
4
));
% Reference grid vectors
xgv
=
minSRX
:
maxSRX
;
...
...
@@ -69,6 +69,7 @@ end
%% Crop reference
Value
=
Value
(
gv
{:});
Mask
=
Mask
(
gv
{:});
Pos_
=
cellfun
(
@
(
x
)
x
(
1
),
gv
)
-
1
;
End_
=
cellfun
(
@
(
x
)
x
(
end
),
gv
);
...
...
@@ -148,8 +149,9 @@ MaskInt = griddedInterpolant(gv,Mask ,'nearest' ,'nearest');
Value
=
ValueInt
(
Uq
,
Vq
,
Xq
,
Yq
);
Mask
=
MaskInt
(
Uq
,
Vq
,
Xq_Mask
,
Yq_Mask
);
Mask
=
logical
(
Mask
);
% Mask of query coordinates inside reference boundary
refMask
=
Xq_Mask
>
Pos_
(
3
)
&
Xq_Mask
<
End_
(
3
)
+
1
&
Yq_Mask
>
Pos_
(
4
)
&
Yq_Mask
<
End_
(
4
)
+
1
;
% Mask of query coordinates inside initial and reference boundary
initMask
=
Xq_Mask
>
0
&
Xq_Mask
<
End
(
3
)
+
1
&
Yq_Mask
>
0
&
Yq_Mask
<
End
(
4
)
+
1
;
refMask
=
Xq_Mask
>
Pos_
(
3
)
&
Xq_Mask
<
End_
(
3
)
+
1
&
Yq_Mask
>
Pos_
(
4
)
&
Yq_Mask
<
End_
(
4
)
+
1
;
% New mask
Mask
=
Mask
&
refMask
;
...
...
This diff is collapsed.
Click to expand it.
warp
H
LRA.m
→
warpLRA.m
+
4
−
71
View file @
d8c39e9f
function
[
PSNRin
,
PSNRout
,
M
,
MMask
,
MPos
,
MDispX
,
MDispY
,
...
projM
,
projValue
,
projMask
,
projPos
,
projDispX
,
projDispY
]
...
=
warp
H
LRA
(
Value
,
Mask
,
Pos
,
DispX
,
DispY
,
k
,
varargin
)
%WARP
H
LRA
Disparity Low-Rank update
=
warpLRA
(
Value
,
Mask
,
Pos
,
DispX
,
DispY
,
k
,
varargin
)
%WARPLRA
Warping low rank approximation
% Compute disparity update that best matches low-rank approximation
%% Parse input
...
...
@@ -15,12 +15,13 @@ keepCompleted = p.Results.keepCompleted;
minMethod
=
p
.
Results
.
minMethod
;
%% Forward transform of original values
[
projValue
,
projMask
,
projPos
,
projDispX
,
projDispY
]
=
SR
.
warp
(
...
[
projValue
,
projMask
,
projPos
,
projDispX
,
projDispY
,
initMask
]
=
SR
.
warp
(
...
Value
,
Mask
,
Pos
,
DispX
,
DispY
,
varargin
{:},
'direction'
,
'forward'
);
%%
switch
minMethod
case
'original'
projValue
(
~
initMask
)
=
nan
;
case
'rank'
projValue
(
~
projMask
)
=
nan
;
%Allow rank completion of unknown pixels
end
...
...
@@ -34,13 +35,9 @@ projSize = size(projValue);
%% Remove unknown entries
projValue
(
~
projMask
)
=
nan
;
projDispX
(
~
projMask
)
=
nan
;
projDispY
(
~
projMask
)
=
nan
;
%% Complete before low-rank approximation
projValue
=
SR
.
complete
(
projValue
,
'rank'
);
projDispX
=
fill_nan
(
projDispX
,[
1
,
1
,
0
,
0
],
'both'
);
projDispY
=
fill_nan
(
projDispY
,[
1
,
1
,
0
,
0
],
'both'
);
%% Compute low-rank approximation
[
B
,
C
]
=
SR
.
factorize
(
projValue
);
...
...
@@ -52,8 +49,6 @@ projM = LF.MatToLF(MMat,projSize);
%% Remove unknown entries after low-rank approximation
projValue
(
~
projMask
)
=
nan
;
projM
(
~
projMask
)
=
nan
;
projDispX
(
~
projMask
)
=
nan
;
projDispY
(
~
projMask
)
=
nan
;
%% Compute inner PSNR
PSNRin
=
psnr
(
projM
(
projMask
),
projValue
(
projMask
));
...
...
@@ -102,65 +97,3 @@ end
[
ValPos
,
MaskPos
]
=
deal
(
minPos
);
end
function
Value
=
fill_nan
(
Value
,
dims
,
direction
)
ndimsval
=
ndims
(
Value
);
dimsval
=
1
:
ndimsval
;
dims
=
dims
(
dimsval
);
dims
=
find
(
dims
);
sz
=
size
(
Value
);
GV
=
cell
(
1
,
ndimsval
);
gv
=
arrayfun
(
@
(
dim
)
1
:
dim
,
sz
,
'UniformOutput'
,
false
);
[
GV
{:}]
=
ndgrid
(
gv
{:});
for
dim
=
dims
curdim
=
dim
==
dimsval
;
repdims
=
sz
;
repdims
(
~
curdim
)
=
1
;
curGV
=
GV
{
dim
};
if
islogical
(
Value
)
Mask
=
Value
;
else
Mask
=
~
isnan
(
Value
);
end
curGV
(
~
Mask
)
=
nan
;
if
any
(
strcmp
(
direction
,{
'pre'
,
'both'
}))
GVmin
=
repmat
(
min
(
curGV
,[],
dim
),
repdims
);
GV_
=
GV
;
M
=
GV
{
dim
}
<
GVmin
;
for
d
=
dimsval
GV_
{
d
}
=
GV
{
d
}(
M
);
end
GV_m
=
GV_
;
GV_m
{
dim
}
=
GVmin
(
M
);
ind
=
sub2ind
(
sz
,
GV_
{:});
ind_m
=
sub2ind
(
sz
,
GV_m
{:});
Value
(
ind
)
=
Value
(
ind_m
);
end
if
any
(
strcmp
(
direction
,{
'post'
,
'both'
}))
GVmax
=
repmat
(
max
(
curGV
,[],
dim
),
repdims
);
GV_
=
GV
;
M
=
GV
{
dim
}
>
GVmax
;
for
d
=
dimsval
GV_
{
d
}
=
GV
{
d
}(
M
);
end
GV_m
=
GV_
;
GV_m
{
dim
}
=
GVmax
(
M
);
ind
=
sub2ind
(
sz
,
GV_
{:});
ind_m
=
sub2ind
(
sz
,
GV_m
{:});
Value
(
ind
)
=
Value
(
ind_m
);
end
end
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
warp
H
LRASet.m
→
warpLRASet.m
+
3
−
3
View file @
d8c39e9f
function
SRSet
=
warp
H
LRASet
(
SRSet
,
varargin
)
%WARP
H
LRASET Summary of this function goes here
function
SRSet
=
warpLRASet
(
SRSet
,
varargin
)
%WARPLRASET Summary of this function goes here
% Detailed explanation goes here
[
Val
,
Lab
,
Pos
,
DispX
,
DispY
]
=
SR
.
SetToFields
(
SRSet
);
...
...
@@ -11,7 +11,7 @@ for it = 1:numel(Lab)
end
for
it
=
1
:
numel
(
Val
)
[
Val
{
it
},
Mask
{
it
},
Pos
{
it
},
DispX
{
it
},
DispY
{
it
}]
=
SR
.
warp
H
LRA
(
...
[
Val
{
it
},
Mask
{
it
},
Pos
{
it
},
DispX
{
it
},
DispY
{
it
}]
=
SR
.
warpLRA
(
...
Val
{
it
},
Mask
{
it
},
Pos
{
it
},
DispX
{
it
},
DispY
{
it
},
varargin
{:});
end
...
...
This diff is collapsed.
Click to expand it.
warp
H
LRAUpdate.m
→
warpLRAUpdate.m
+
6
−
4
View file @
d8c39e9f
function
[
dX
,
dY
,
PSNRin
,
PSNRout
,
M
,
MMask
,
MPos
,
MDispX
,
MDispY
,
...
projM
,
projValue
,
projMask
,
projPos
,
projDispX
,
projDispY
]
=
...
warp
H
LRAUpdate
(
Value
,
Mask
,
Pos
,
DispX
,
DispY
,
k
,
varargin
)
%WARP
H
LRAUPDATE
Homography Low-R
ank
A
pproximation + update
% Compute
warping
that best matches low-rank approximation
warpLRAUpdate
(
Value
,
Mask
,
Pos
,
DispX
,
DispY
,
k
,
varargin
)
%WARPLRAUPDATE
warping + low r
ank
a
pproximation + update
% Compute
update
that best matches low-rank approximation
[
PSNRin
,
PSNRout
,
M
,
MMask
,
MPos
,
MDispX
,
MDispY
,
...
projM
,
projValue
,
projMask
,
projPos
,
projDispX
,
projDispY
]
...
=
SR
.
warp
H
LRA
(
Value
,
Mask
,
Pos
,
DispX
,
DispY
,
k
,
varargin
{:});
=
SR
.
warpLRA
(
Value
,
Mask
,
Pos
,
DispX
,
DispY
,
k
,
varargin
{:});
[
dX
,
dY
]
=
SR
.
pinvUpdate
(
projValue
,
projMask
,
projM
,
varargin
{:});
fprintf
(
'PSNRin: %2.5f, PSNRout: %2.5f\n'
,
PSNRin
,
PSNRout
);
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment