mirror of https://github.com/davisking/dlib.git
Added max_point()
This commit is contained in:
parent
4f2a07f5d3
commit
6ca45db06e
|
@ -122,6 +122,41 @@ namespace dlib
|
|||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <
|
||||
typename EXP
|
||||
>
|
||||
point max_point (
|
||||
const matrix_exp<EXP>& m
|
||||
)
|
||||
{
|
||||
DLIB_ASSERT(m.size() > 0,
|
||||
"\tpoint max_point(const matrix_exp& m)"
|
||||
<< "\n\tm can't be empty"
|
||||
<< "\n\tm.size(): " << m.size()
|
||||
<< "\n\tm.nr(): " << m.nr()
|
||||
<< "\n\tm.nc(): " << m.nc()
|
||||
);
|
||||
typedef typename matrix_exp<EXP>::type type;
|
||||
|
||||
point best_point(0,0);
|
||||
type val = m(0,0);
|
||||
for (long r = 0; r < m.nr(); ++r)
|
||||
{
|
||||
for (long c = 0; c < m.nc(); ++c)
|
||||
{
|
||||
type temp = m(r,c);
|
||||
if (dlib::impl::magnitude(temp) > dlib::impl::magnitude(val))
|
||||
{
|
||||
val = temp;
|
||||
best_point = point(c,r);
|
||||
}
|
||||
}
|
||||
}
|
||||
return best_point;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <
|
||||
|
|
|
@ -1409,6 +1409,19 @@ namespace dlib
|
|||
(i.e. m(index_of_min(m)) == min(m))
|
||||
!*/
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
point max_point (
|
||||
const matrix_exp& m
|
||||
);
|
||||
/*!
|
||||
requires
|
||||
- m.size() > 0
|
||||
ensures
|
||||
- returns the location of the maximum element of the array, that is, if the
|
||||
returned point is P then it will be the case that: m(P.y(),P.x()) == max(m).
|
||||
!*/
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
const matrix_exp::type sum (
|
||||
|
|
Loading…
Reference in New Issue