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
7e8d893e
Commit
7e8d893e
authored
Jan 21, 2015
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added max_point_interpolated()
parent
92c9c717
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
+79
-0
matrix_la.h
dlib/matrix/matrix_la.h
+64
-0
matrix_utilities_abstract.h
dlib/matrix/matrix_utilities_abstract.h
+15
-0
No files found.
dlib/matrix/matrix_la.h
View file @
7e8d893e
...
...
@@ -1834,6 +1834,70 @@ convergence:
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
EXP
>
dlib
::
vector
<
double
,
2
>
max_point_interpolated
(
const
matrix_exp
<
EXP
>&
m
)
{
DLIB_ASSERT
(
m
.
size
()
>
0
,
"
\t
dlib::vector<double,2> point max_point_interpolated(const matrix_exp& m)"
<<
"
\n\t
m can't be empty"
<<
"
\n\t
m.size(): "
<<
m
.
size
()
<<
"
\n\t
m.nr(): "
<<
m
.
nr
()
<<
"
\n\t
m.nc(): "
<<
m
.
nc
()
);
const
dlib
::
vector
<
double
,
2
>
p
=
max_point
(
m
);
// If it's on the border then just find the regular max point and return that.
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
))));
matrix
<
double
,
9
,
1
>
pix
;
long
i
=
0
;
for
(
long
r
=
-
1
;
r
<=
+
1
;
++
r
)
{
for
(
long
c
=
-
1
;
c
<=
+
1
;
++
c
)
{
pix
(
i
)
=
get_pixel_intensity
(
m
(
p
.
y
()
+
r
,
p
.
y
()
+
c
));
++
i
;
}
}
// So this magic finds the parameters of the quadratic surface that best fits
// the 3x3 region around p. Then we find the maximizer of that surface within that
// small region and return that as the maximum location.
const
double
magic
[]
=
{
12
,
-
24
,
12
,
12
,
-
24
,
12
,
12
,
-
24
,
12
,
9
,
0
,
-
9
,
0
,
0
,
0
,
-
9
,
0
,
9
,
12
,
12
,
12
,
-
24
,
-
24
,
-
24
,
12
,
12
,
12
,
-
12
,
0
,
12
,
-
12
,
0
,
12
,
-
12
,
0
,
12
,
-
12
,
-
12
,
-
12
,
0
,
0
,
0
,
12
,
12
,
12
};
matrix
<
double
,
5
,
9
>
mag
(
magic
);
// Now w contains the parameters of the quadratic surface
matrix
<
double
,
5
,
1
>
w
=
mag
*
pix
/
72
;
// Now newton step to the max point on the surface
matrix
<
double
,
2
,
2
>
H
;
matrix
<
double
,
2
,
1
>
g
;
H
=
2
*
w
(
0
),
w
(
1
),
w
(
1
),
2
*
w
(
2
);
g
=
w
(
3
),
w
(
4
);
dlib
::
vector
<
double
,
2
>
delta
=
-
inv
(
H
)
*
g
;
// if delta isn't in an ascent direction then just use the normal max point.
if
(
dot
(
delta
,
g
)
<
0
)
return
p
;
else
return
p
+
clamp
(
delta
,
-
1
,
1
);
}
// ----------------------------------------------------------------------------------------
}
...
...
dlib/matrix/matrix_utilities_abstract.h
View file @
7e8d893e
...
...
@@ -1422,6 +1422,21 @@ namespace dlib
returned point is P then it will be the case that: m(P.y(),P.x()) == max(m).
!*/
// ----------------------------------------------------------------------------------------
dlib
::
vector
<
double
,
2
>
max_point_interpolated
(
const
matrix_exp
&
m
);
/*!
requires
- m.size() > 9
ensures
- Like max_point(), this function finds the location in m with the largest
value. However, we additionally use some quadratic interpolation to find the
location of the maximum point with sub-pixel accuracy. Therefore, the
returned point is equal to max_point(m) + some small sub-pixel delta.
!*/
// ----------------------------------------------------------------------------------------
point
min_point
(
...
...
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