Made threshold_image() handle signed pixels properly.

This commit is contained in:
Davis King 2011-05-30 10:58:53 -04:00
parent 2dd28ac0fe
commit b13bb3642c
2 changed files with 5 additions and 8 deletions

View File

@ -24,7 +24,7 @@ namespace dlib
void threshold_image (
const in_image_type& in_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 );
@ -45,13 +45,10 @@ namespace dlib
{
for (long c = 0; c < in_img.nc(); ++c)
{
typename out_image_type::type p;
assign_pixel(p,in_img[r][c]);
if (p >= thresh)
p = on_pixel;
if (get_pixel_intensity(in_img[r][c]) >= thresh)
assign_pixel(out_img[r][c], on_pixel);
else
p = off_pixel;
out_img[r][c] = p;
assign_pixel(out_img[r][c], off_pixel);
}
}
}

View File

@ -22,7 +22,7 @@ namespace dlib
void threshold_image (
const in_image_type& in_img,
out_image_type& out_img,
unsigned long thresh
typename pixel_traits<typename in_image_type::type>::basic_pixel_type thresh
);
/*!
requires