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
b34c46a5
Commit
b34c46a5
authored
Oct 25, 2015
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added subm_clipped()
parent
fc9f3026
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
0 deletions
+77
-0
matrix_subexp.h
dlib/matrix/matrix_subexp.h
+35
-0
matrix_subexp_abstract.h
dlib/matrix/matrix_subexp_abstract.h
+40
-0
matrix.cpp
dlib/test/matrix.cpp
+2
-0
No files found.
dlib/matrix/matrix_subexp.h
View file @
b34c46a5
...
@@ -121,6 +121,25 @@ namespace dlib
...
@@ -121,6 +121,25 @@ namespace dlib
return
matrix_op
<
op
>
(
op
(
m
.
ref
(),
r
,
c
,
nr
,
nc
));
return
matrix_op
<
op
>
(
op
(
m
.
ref
(),
r
,
c
,
nr
,
nc
));
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
EXP
>
const
matrix_op
<
op_subm
<
EXP
>
>
subm_clipped
(
const
matrix_exp
<
EXP
>&
m
,
long
r
,
long
c
,
long
nr
,
long
nc
)
{
rectangle
box
(
c
,
r
,
c
+
nc
-
1
,
r
+
nr
-
1
);
box
=
box
.
intersect
(
get_rect
(
m
));
typedef
op_subm
<
EXP
>
op
;
return
matrix_op
<
op
>
(
op
(
m
.
ref
(),
box
.
top
(),
box
.
left
(),
box
.
height
(),
box
.
width
()));
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
...
@@ -146,6 +165,22 @@ namespace dlib
...
@@ -146,6 +165,22 @@ namespace dlib
return
matrix_op
<
op
>
(
op
(
m
.
ref
(),
rect
.
top
(),
rect
.
left
(),
rect
.
height
(),
rect
.
width
()));
return
matrix_op
<
op
>
(
op
(
m
.
ref
(),
rect
.
top
(),
rect
.
left
(),
rect
.
height
(),
rect
.
width
()));
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
EXP
>
const
matrix_op
<
op_subm
<
EXP
>
>
subm_clipped
(
const
matrix_exp
<
EXP
>&
m
,
rectangle
rect
)
{
rect
=
rect
.
intersect
(
get_rect
(
m
));
typedef
op_subm
<
EXP
>
op
;
return
matrix_op
<
op
>
(
op
(
m
.
ref
(),
rect
.
top
(),
rect
.
left
(),
rect
.
height
(),
rect
.
width
()));
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
M1
,
typename
M2
,
typename
M3
>
template
<
typename
M1
,
typename
M2
,
typename
M3
>
...
...
dlib/matrix/matrix_subexp_abstract.h
View file @
b34c46a5
...
@@ -105,6 +105,30 @@ namespace dlib
...
@@ -105,6 +105,30 @@ namespace dlib
R(r, c) == m(r+row,c+col)
R(r, c) == m(r+row,c+col)
!*/
!*/
// ----------------------------------------------------------------------------------------
const
matrix_exp
subm_clipped
(
const
matrix_exp
&
m
,
long
row
,
long
col
,
long
nr
,
long
nc
);
/*!
ensures
- This function is just like subm() except that it will automatically clip the
indicated sub matrix window so that it does not extend outside m.
In particular:
- Let box = rectangle(col,row,col+nc-1,row+nr-1)
(i.e. the box that contains the indicated sub matrix)
- Let box_clipped = box.intersect(get_rect(m))
- Then this function returns a matrix R such that:
- R.nr() == box_clipped.height()
- R.nc() == box_clipped.width()
- for all valid r and c:
R(r, c) == m(r+box_clipped.top(),c+box_clipped.left())
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
const
matrix_exp
subm
(
const
matrix_exp
subm
(
...
@@ -123,6 +147,22 @@ namespace dlib
...
@@ -123,6 +147,22 @@ namespace dlib
R(r, c) == m(r+rect.top(), c+rect.left())
R(r, c) == m(r+rect.top(), c+rect.left())
!*/
!*/
// ----------------------------------------------------------------------------------------
const
matrix_exp
subm_clipped
(
const
matrix_exp
&
m
,
const
rectangle
&
rect
);
/*!
ensures
- Let box_clipped == rect.intersect(get_rect(m))
- returns a matrix R such that:
- R.nr() == box_clipped.height()
- R.nc() == box_clipped.width()
- for all valid r and c:
R(r, c) == m(r+box_clipped.top(), c+box_clipped.left())
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
const
matrix_exp
rowm
(
const
matrix_exp
rowm
(
...
...
dlib/test/matrix.cpp
View file @
b34c46a5
...
@@ -433,6 +433,8 @@ namespace
...
@@ -433,6 +433,8 @@ namespace
{
{
DLIB_TEST
(
subm
(
a
,
1
,
2
,
2
,
3
)(
r
,
c
)
==
(
r
+
1
)
*
a
.
nc
()
+
c
+
2
);
DLIB_TEST
(
subm
(
a
,
1
,
2
,
2
,
3
)(
r
,
c
)
==
(
r
+
1
)
*
a
.
nc
()
+
c
+
2
);
DLIB_TEST
(
subm
(
a
,
1
,
2
,
2
,
3
)
==
subm
(
a
,
rect
));
DLIB_TEST
(
subm
(
a
,
1
,
2
,
2
,
3
)
==
subm
(
a
,
rect
));
DLIB_TEST
(
subm_clipped
(
a
,
1
,
2
,
2
,
3
)
==
subm
(
a
,
rect
));
DLIB_TEST
(
subm_clipped
(
a
,
1
,
2
,
2
,
3
)
==
subm_clipped
(
a
,
rect
));
}
}
}
}
...
...
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