Commit 905fd903 authored by Davis King's avatar Davis King

Changed the hessian_pyramid so that it has a slightly smaller border

region and therefore finds more interest points.
parent ddaefb6c
...@@ -119,10 +119,10 @@ namespace dlib ...@@ -119,10 +119,10 @@ namespace dlib
for (long o = 0; o < num_octaves; ++o) for (long o = 0; o < num_octaves; ++o)
{ {
const long step_size = get_step_size(o); const long step_size = get_step_size(o);
const long border_size = get_border_size(o)*step_size;
for (long i = 0; i < num_intervals; ++i) for (long i = 0; i < num_intervals; ++i)
{ {
const long border_size = get_border_size(i)*step_size;
const long lobe_size = static_cast<long>(std::pow(2.0, o+1.0)+0.5)*(i+1) + 1; const long lobe_size = static_cast<long>(std::pow(2.0, o+1.0)+0.5)*(i+1) + 1;
const double area_inv = 1.0/std::pow(3.0*lobe_size, 2.0); const double area_inv = 1.0/std::pow(3.0*lobe_size, 2.0);
...@@ -178,17 +178,17 @@ namespace dlib ...@@ -178,17 +178,17 @@ namespace dlib
} }
long get_border_size ( long get_border_size (
long octave long interval
) const ) const
{ {
DLIB_ASSERT(0 <= octave && octave < octaves(), DLIB_ASSERT(0 <= interval && interval < intervals(),
"\tlong get_border_size(octave)" "\tlong get_border_size(interval)"
<< "\n\tInvalid octave value" << "\n\tInvalid interval value"
<< "\n\t this: " << this << "\n\t this: " << this
<< "\n\t octave: " << octave << "\n\t interval: " << interval
); );
const double lobe_size = std::pow(2.0, octave+1.0)*(num_intervals+1) + 1; const double lobe_size = 2.0*(interval+1) + 1;
const double filter_size = 3*lobe_size; const double filter_size = 3*lobe_size;
const long bs = static_cast<long>(std::ceil(filter_size/2.0)); const long bs = static_cast<long>(std::ceil(filter_size/2.0));
...@@ -246,8 +246,8 @@ namespace dlib ...@@ -246,8 +246,8 @@ namespace dlib
{ {
DLIB_ASSERT(0 <= octave && octave < octaves() && DLIB_ASSERT(0 <= octave && octave < octaves() &&
0 <= interval && interval < intervals() && 0 <= interval && interval < intervals() &&
get_border_size(octave) <= r && r < nr(octave)-get_border_size(octave) && get_border_size(interval) <= r && r < nr(octave)-get_border_size(interval) &&
get_border_size(octave) <= c && c < nc(octave)-get_border_size(octave), get_border_size(interval) <= c && c < nc(octave)-get_border_size(interval),
"\tdouble get_value(octave, interval, r, c)" "\tdouble get_value(octave, interval, r, c)"
<< "\n\tInvalid inputs to this function" << "\n\tInvalid inputs to this function"
<< "\n\t this: " << this << "\n\t this: " << this
...@@ -259,7 +259,7 @@ namespace dlib ...@@ -259,7 +259,7 @@ namespace dlib
<< "\n\t c: " << c << "\n\t c: " << c
<< "\n\t nr(octave): " << nr(octave) << "\n\t nr(octave): " << nr(octave)
<< "\n\t nc(octave): " << nc(octave) << "\n\t nc(octave): " << nc(octave)
<< "\n\t get_border_size(octave): " << get_border_size(octave) << "\n\t get_border_size(interval): " << get_border_size(interval)
); );
return std::abs(pyramid[num_intervals*octave + interval][r][c]); return std::abs(pyramid[num_intervals*octave + interval][r][c]);
...@@ -274,8 +274,8 @@ namespace dlib ...@@ -274,8 +274,8 @@ namespace dlib
{ {
DLIB_ASSERT(0 <= octave && octave < octaves() && DLIB_ASSERT(0 <= octave && octave < octaves() &&
0 <= interval && interval < intervals() && 0 <= interval && interval < intervals() &&
get_border_size(octave) <= r && r < nr(octave)-get_border_size(octave) && get_border_size(interval) <= r && r < nr(octave)-get_border_size(interval) &&
get_border_size(octave) <= c && c < nc(octave)-get_border_size(octave), get_border_size(interval) <= c && c < nc(octave)-get_border_size(interval),
"\tdouble get_laplacian(octave, interval, r, c)" "\tdouble get_laplacian(octave, interval, r, c)"
<< "\n\tInvalid inputs to this function" << "\n\tInvalid inputs to this function"
<< "\n\t this: " << this << "\n\t this: " << this
...@@ -287,7 +287,7 @@ namespace dlib ...@@ -287,7 +287,7 @@ namespace dlib
<< "\n\t c: " << c << "\n\t c: " << c
<< "\n\t nr(octave): " << nr(octave) << "\n\t nr(octave): " << nr(octave)
<< "\n\t nc(octave): " << nc(octave) << "\n\t nc(octave): " << nc(octave)
<< "\n\t get_border_size(octave): " << get_border_size(octave) << "\n\t get_border_size(interval): " << get_border_size(interval)
); );
// return the sign of the laplacian // return the sign of the laplacian
...@@ -436,6 +436,11 @@ namespace dlib ...@@ -436,6 +436,11 @@ namespace dlib
temp.score = pyr.get_value(o,i,r,c); temp.score = pyr.get_value(o,i,r,c);
temp.laplacian = pyr.get_laplacian(o,i,r,c); temp.laplacian = pyr.get_laplacian(o,i,r,c);
} }
else
{
// this indicates to the caller that no interest point was found.
temp.score = -1;
}
return temp; return temp;
} }
...@@ -469,43 +474,26 @@ namespace dlib ...@@ -469,43 +474,26 @@ namespace dlib
// do non-maximum suppression on all the intervals in the current octave and // do non-maximum suppression on all the intervals in the current octave and
// accumulate the results in result_points // accumulate the results in result_points
for (long i = 1; i < pyr.intervals()-1; i += 3) for (long i = 1; i < pyr.intervals()-1; i += 1)
{ {
for (long r = border_size+1; r < nr - border_size-1; r += 3) const long border_size = pyr.get_border_size(i+1);
for (long r = border_size+1; r < nr - border_size-1; r += 1)
{ {
for (long c = border_size+1; c < nc - border_size-1; c += 3) for (long c = border_size+1; c < nc - border_size-1; c += 1)
{ {
double max_val = pyr.get_value(o,i,r,c); double max_val = pyr.get_value(o,i,r,c);
long max_i = i; long max_i = i;
long max_r = r; long max_r = r;
long max_c = c; long max_c = c;
// loop over this 3x3x3 block and find the largest element
for (long ii = i; ii < std::min(i + 3, pyr.intervals()-1); ++ii)
{
for (long rr = r; rr < std::min(r + 3, nr - border_size - 1); ++rr)
{
for (long cc = c; cc < std::min(c + 3, nc - border_size - 1); ++cc)
{
double temp = pyr.get_value(o,ii,rr,cc);
if (temp > max_val)
{
max_val = temp;
max_i = ii;
max_r = rr;
max_c = cc;
}
}
}
}
// If the max point we found is really a maximum in its own region and // If the max point we found is really a maximum in its own region and
// is big enough then add it to the results. // is big enough then add it to the results.
if (max_val > threshold && is_maximum_in_region(pyr, o, max_i, max_r, max_c)) if (max_val >= threshold && is_maximum_in_region(pyr, o, max_i, max_r, max_c))
{ {
//cout << max_val << endl; //cout << max_val << endl;
interest_point sp = interpolate_point (pyr, o, max_i, max_r, max_c); interest_point sp = interpolate_point (pyr, o, max_i, max_r, max_c);
if (sp.score > threshold) if (sp.score >= threshold)
{ {
result_points.push_back(sp); result_points.push_back(sp);
} }
......
...@@ -73,13 +73,13 @@ namespace dlib ...@@ -73,13 +73,13 @@ namespace dlib
!*/ !*/
long get_border_size ( long get_border_size (
long octave long interval
) const; ) const;
/*! /*!
requires requires
- 0 <= octave < octaves() - 0 <= interval < intervals()
ensures ensures
- Each octave of the pyramid has a certain sized border region where we - Each interval of the pyramid has a certain sized border region where we
can't compute the Hessian values since they are too close to the edge can't compute the Hessian values since they are too close to the edge
of the input image. This function returns the size of that border. of the input image. This function returns the size of that border.
!*/ !*/
...@@ -129,7 +129,7 @@ namespace dlib ...@@ -129,7 +129,7 @@ namespace dlib
requires requires
- 0 <= octave < octaves() - 0 <= octave < octaves()
- 0 <= interval < intervals() - 0 <= interval < intervals()
- Let BS == get_border_size(octave): then - Let BS == get_border_size(interval): then
- BS <= r < nr(octave)-BS - BS <= r < nr(octave)-BS
- BS <= c < nc(octave)-BS - BS <= c < nc(octave)-BS
ensures ensures
...@@ -148,7 +148,7 @@ namespace dlib ...@@ -148,7 +148,7 @@ namespace dlib
requires requires
- 0 <= octave < octaves() - 0 <= octave < octaves()
- 0 <= interval < intervals() - 0 <= interval < intervals()
- Let BS == get_border_size(octave): then - Let BS == get_border_size(interval): then
- BS <= r < nr(octave)-BS - BS <= r < nr(octave)-BS
- BS <= c < nc(octave)-BS - BS <= c < nc(octave)-BS
ensures ensures
...@@ -175,7 +175,12 @@ namespace dlib ...@@ -175,7 +175,12 @@ namespace dlib
- center == the x/y location of the center of the interest point - center == the x/y location of the center of the interest point
(in image space coordinates. y gives the row and x gives the (in image space coordinates. y gives the row and x gives the
column in the image) column in the image)
- scale == the scale at which the point was detected - scale == the scale at which the point was detected. This is a number
>= 1. If it is 1 then it means the interest point was detected at
the lowest scale in the image pyramid. Larger numbers indicate that
the interest point is from high up in the image pyramid. For
example, a scale of 4 would mean the interest point was located at a
point in the pyramid where the image had been shrunk by a factor of 4.
- score == the determinant of the Hessian for the interest point - score == the determinant of the Hessian for the interest point
- laplacian == the sign of the laplacian for the interest point - laplacian == the sign of the laplacian for the interest point
!*/ !*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment