mirror of https://github.com/davisking/dlib.git
Added image_plane()
This commit is contained in:
parent
04797b664e
commit
c219900980
|
@ -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,
|
||||
"\tconst 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 (
|
||||
|
|
|
@ -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 (
|
||||
|
|
Loading…
Reference in New Issue