Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
4a08c318
Commit
4a08c318
authored
Jan 21, 2015
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made max_point_interpolated() do interpolation for row and column
vectors and also generally cleaned up the code a bit.
parent
d884d8e7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
8 deletions
+37
-8
matrix_la.h
dlib/matrix/matrix_la.h
+37
-8
No files found.
dlib/matrix/matrix_la.h
View file @
4a08c318
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include "matrix_la_abstract.h"
#include "matrix_la_abstract.h"
#include "matrix_utilities.h"
#include "matrix_utilities.h"
#include "../sparse_vector.h"
#include "../sparse_vector.h"
#include "../optimization/optimization_line_search.h"
// The 4 decomposition objects described in the matrix_la_abstract.h file are
// The 4 decomposition objects described in the matrix_la_abstract.h file are
// actually implemented in the following 4 files.
// actually implemented in the following 4 files.
...
@@ -1850,11 +1851,39 @@ convergence:
...
@@ -1850,11 +1851,39 @@ convergence:
<<
"
\n\t
m.nr(): "
<<
m
.
nr
()
<<
"
\n\t
m.nr(): "
<<
m
.
nr
()
<<
"
\n\t
m.nc(): "
<<
m
.
nc
()
<<
"
\n\t
m.nc(): "
<<
m
.
nc
()
);
);
const
dlib
::
vector
<
double
,
2
>
p
=
max_point
(
m
);
const
point
p
=
max_point
(
m
);
// If it's on the border then just find the regular max point and return that.
// If this is a column vector then just do interpolation along a line.
if
(
m
.
nc
()
==
1
)
{
const
long
pos
=
p
.
y
();
if
(
0
<
pos
&&
pos
+
1
<
m
.
nr
())
{
double
v1
=
dlib
::
impl
::
magnitude
(
m
(
pos
-
1
));
double
v2
=
dlib
::
impl
::
magnitude
(
m
(
pos
));
double
v3
=
dlib
::
impl
::
magnitude
(
m
(
pos
+
1
));
double
y
=
lagrange_poly_min_extrap
(
pos
-
1
,
pos
,
pos
+
1
,
-
v1
,
-
v2
,
-
v3
);
return
vector
<
double
,
2
>
(
0
,
y
);
}
}
// If this is a row vector then just do interpolation along a line.
if
(
m
.
nr
()
==
1
)
{
const
long
pos
=
p
.
x
();
if
(
0
<
pos
&&
pos
+
1
<
m
.
nc
())
{
double
v1
=
dlib
::
impl
::
magnitude
(
m
(
pos
-
1
));
double
v2
=
dlib
::
impl
::
magnitude
(
m
(
pos
));
double
v3
=
dlib
::
impl
::
magnitude
(
m
(
pos
+
1
));
double
x
=
lagrange_poly_min_extrap
(
pos
-
1
,
pos
,
pos
+
1
,
-
v1
,
-
v2
,
-
v3
);
return
vector
<
double
,
2
>
(
x
,
0
);
}
}
// If it's on the border then just return the regular max point.
if
(
shrink_rect
(
get_rect
(
m
),
1
).
contains
(
p
)
==
false
)
if
(
shrink_rect
(
get_rect
(
m
),
1
).
contains
(
p
)
==
false
)
return
max_point
(
subm
(
mat
(
m
),
centered_rect
(
p
,
3
,
3
).
intersect
(
get_rect
(
m
))))
;
return
p
;
matrix
<
double
,
9
,
1
>
pix
;
matrix
<
double
,
9
,
1
>
pix
;
...
@@ -1863,7 +1892,7 @@ convergence:
...
@@ -1863,7 +1892,7 @@ convergence:
{
{
for
(
long
c
=
-
1
;
c
<=
+
1
;
++
c
)
for
(
long
c
=
-
1
;
c
<=
+
1
;
++
c
)
{
{
pix
(
i
)
=
get_pixel_intensity
(
m
(
p
.
y
()
+
r
,
p
.
y
()
+
c
));
pix
(
i
)
=
dlib
::
impl
::
magnitude
(
m
(
p
.
y
()
+
r
,
p
.
y
()
+
c
));
++
i
;
++
i
;
}
}
}
}
...
@@ -1877,9 +1906,9 @@ convergence:
...
@@ -1877,9 +1906,9 @@ convergence:
12
,
12
,
12
,
-
24
,
-
24
,
-
24
,
12
,
12
,
12
,
12
,
12
,
12
,
-
24
,
-
24
,
-
24
,
12
,
12
,
12
,
-
12
,
0
,
12
,
-
12
,
0
,
12
,
-
12
,
0
,
12
,
-
12
,
0
,
12
,
-
12
,
0
,
12
,
-
12
,
0
,
12
,
-
12
,
-
12
,
-
12
,
0
,
0
,
0
,
12
,
12
,
12
};
-
12
,
-
12
,
-
12
,
0
,
0
,
0
,
12
,
12
,
12
};
matrix
<
double
,
5
,
9
>
mag
(
magic
);
const
matrix
<
double
,
5
,
9
>
mag
(
magic
);
// Now w contains the parameters of the quadratic surface
// Now w contains the parameters of the quadratic surface
matrix
<
double
,
5
,
1
>
w
=
mag
*
pix
/
72
;
const
matrix
<
double
,
5
,
1
>
w
=
mag
*
pix
/
72
;
// Now newton step to the max point on the surface
// Now newton step to the max point on the surface
...
@@ -1889,13 +1918,13 @@ convergence:
...
@@ -1889,13 +1918,13 @@ convergence:
w
(
1
),
2
*
w
(
2
);
w
(
1
),
2
*
w
(
2
);
g
=
w
(
3
),
g
=
w
(
3
),
w
(
4
);
w
(
4
);
dlib
::
vector
<
double
,
2
>
delta
=
-
inv
(
H
)
*
g
;
const
dlib
::
vector
<
double
,
2
>
delta
=
-
inv
(
H
)
*
g
;
// if delta isn't in an ascent direction then just use the normal max point.
// if delta isn't in an ascent direction then just use the normal max point.
if
(
dot
(
delta
,
g
)
<
0
)
if
(
dot
(
delta
,
g
)
<
0
)
return
p
;
return
p
;
else
else
return
p
+
clamp
(
delta
,
-
1
,
1
);
return
vector
<
double
,
2
>
(
p
)
+
clamp
(
delta
,
-
1
,
1
);
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment