Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
c2199009
Commit
c2199009
authored
Oct 25, 2015
by
Davis King
Browse files
Added image_plane()
parent
04797b66
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
dlib/dnn/tensor.h
dlib/dnn/tensor.h
+25
-0
dlib/dnn/tensor_abstract.h
dlib/dnn/tensor_abstract.h
+20
-0
No files found.
dlib/dnn/tensor.h
View file @
c2199009
...
...
@@ -241,6 +241,31 @@ namespace dlib
return
mat
(
t
,
t
.
num_samples
(),
t
.
size
()
/
t
.
num_samples
());
}
inline
const
matrix_op
<
op_pointer_to_mat
<
float
>
>
image_plane
(
const
tensor
&
t
,
long
sample
=
0
,
long
k
=
0
)
{
DLIB_ASSERT
(
0
<=
sample
&&
sample
<
t
.
num_samples
()
&&
0
<=
k
&&
k
<
t
.
k
()
&&
t
.
size
()
!=
0
,
"
\t
const matrix_exp image_plane(tensor,sample,k)"
<<
"
\n\t
Invalid arguments were given to this function."
<<
"
\n\t
sample: "
<<
sample
<<
"
\n\t
k: "
<<
k
<<
"
\n\t
t.num_samples(): "
<<
t
.
num_samples
()
<<
"
\n\t
t.k(): "
<<
t
.
k
()
<<
"
\n\t
t.size(): "
<<
t
.
size
()
);
typedef
op_pointer_to_mat
<
float
>
op
;
return
matrix_op
<
op
>
(
op
(
t
.
host
()
+
((
sample
*
t
.
k
()
+
k
)
*
t
.
nr
())
*
t
.
nc
(),
t
.
nr
(),
t
.
nc
()));
}
// ----------------------------------------------------------------------------------------
inline
bool
have_same_dimensions
(
...
...
dlib/dnn/tensor_abstract.h
View file @
c2199009
...
...
@@ -295,6 +295,26 @@ namespace dlib
- returns mat(t, t.num_samples(), t.size()/t.num_samples())
!*/
const
matrix_exp
image_plane
(
const
tensor
&
t
,
long
sample
=
0
,
long
k
=
0
);
/*!
requires
- t.size() != 0
- 0 <= sample < t.num_samples()
- 0 <= k < t.k()
ensures
- returns the k-th image plane from the sample-th image in t. That is,
returns a matrix M such that:
- M contains float valued elements.
- M.nr() == t.nr()
- M.nc() == t.nc()
- for all valid r and c:
- M(r,c) == t.host()[((sample*t.k() + k)*t.nr() + r)*t.nc() + c]
!*/
// ----------------------------------------------------------------------------------------
bool
have_same_dimensions
(
...
...
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