Commit b13bb364 authored by Davis King's avatar Davis King

Made threshold_image() handle signed pixels properly.

parent 2dd28ac0
...@@ -24,7 +24,7 @@ namespace dlib ...@@ -24,7 +24,7 @@ namespace dlib
void threshold_image ( void threshold_image (
const in_image_type& in_img, const in_image_type& in_img,
out_image_type& out_img, out_image_type& out_img,
unsigned long thresh typename pixel_traits<typename in_image_type::type>::basic_pixel_type thresh
) )
{ {
COMPILE_TIME_ASSERT( pixel_traits<typename in_image_type::type>::has_alpha == false ); COMPILE_TIME_ASSERT( pixel_traits<typename in_image_type::type>::has_alpha == false );
...@@ -45,13 +45,10 @@ namespace dlib ...@@ -45,13 +45,10 @@ namespace dlib
{ {
for (long c = 0; c < in_img.nc(); ++c) for (long c = 0; c < in_img.nc(); ++c)
{ {
typename out_image_type::type p; if (get_pixel_intensity(in_img[r][c]) >= thresh)
assign_pixel(p,in_img[r][c]); assign_pixel(out_img[r][c], on_pixel);
if (p >= thresh)
p = on_pixel;
else else
p = off_pixel; assign_pixel(out_img[r][c], off_pixel);
out_img[r][c] = p;
} }
} }
} }
......
...@@ -22,7 +22,7 @@ namespace dlib ...@@ -22,7 +22,7 @@ namespace dlib
void threshold_image ( void threshold_image (
const in_image_type& in_img, const in_image_type& in_img,
out_image_type& out_img, out_image_type& out_img,
unsigned long thresh typename pixel_traits<typename in_image_type::type>::basic_pixel_type thresh
); );
/*! /*!
requires requires
......
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