Commit 2a224bf0 authored by Davis King's avatar Davis King

Made the point up/down mapping for pyramid_down<2> and pyramid_down<3> a little

bit more accurate.
parent afed9767
......@@ -156,8 +156,7 @@ namespace dlib
const vector<T,2>& p
) const
{
//do return (p - vector<T,2>(2,2))/2.0;
return p/2.0 - vector<double,2>(1,1);
return p/2.0 - vector<double,2>(1.25,0.75);
}
template <typename T>
......@@ -165,7 +164,7 @@ namespace dlib
const vector<T,2>& p
) const
{
return p*2 + vector<T,2>(2,2);
return (p + vector<T,2>(1.25,0.75))*2;
}
// -----------------------------
......@@ -497,8 +496,7 @@ namespace dlib
) const
{
const double ratio = 2.0/3.0;
//do return (p - vector<T,2>(1,1))*ratio;
return p*ratio - vector<double,2>(ratio,ratio);
return p*ratio - vector<double,2>(1,1);
}
template <typename T>
......@@ -507,7 +505,7 @@ namespace dlib
) const
{
const double ratio = 3.0/2.0;
return p*ratio + vector<T,2>(1,1);
return p*ratio + vector<T,2>(ratio,ratio);
}
// -----------------------------
......
......@@ -206,7 +206,7 @@ void test_pyramid_down_rgb2()
template <typename pyramid_down_type>
void test_pyramid_down_grayscale2()
{
array2d<unsigned char> img, img3;
array2d<unsigned char> img;
array2d<unsigned char> img2, img4;
......@@ -225,7 +225,6 @@ void test_pyramid_down_grayscale2()
pyramid_down_type pyr;
pyr(img, img2);
pyr(img, img3);
DLIB_TEST(((rect1.tl_corner() - pyr.rect_down(pyr.rect_up(rect1,2),2).tl_corner()).length()) < 1);
......@@ -246,17 +245,13 @@ void test_pyramid_down_grayscale2()
/*
image_window my_window(img);
image_window win2(img2);
image_window win3(img3);
win2.add_overlay(image_window::overlay_rect(rect1, rgb_pixel(255,0,0)));
win2.add_overlay(image_window::overlay_rect(rect2, rgb_pixel(255,0,0)));
win2.add_overlay(image_window::overlay_rect(rect3, rgb_pixel(255,0,0)));
win3.add_overlay(image_window::overlay_rect(rect1, rgb_pixel(255,0,0)));
win3.add_overlay(image_window::overlay_rect(rect2, rgb_pixel(255,0,0)));
win3.add_overlay(image_window::overlay_rect(rect3, rgb_pixel(255,0,0)));
*/
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(mat(img2)),rect1)) - 255) < 3);
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(mat(img2)),rect1)) - 255) <= 3);
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(mat(img2)),rect2)) - 170) < 3);
DLIB_TEST(std::abs((int)mean(subm(matrix_cast<long>(mat(img2)),rect3)) - 100) < 3);
assign_image(img4, img);
......
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