Added image_plane()

This commit is contained in:
Davis King 2015-10-25 18:13:22 -04:00
parent 04797b664e
commit c219900980
2 changed files with 45 additions and 0 deletions

View File

@ -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 (

View File

@ -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 (