Skip to content

Commit

Permalink
Made threshold_image() handle signed pixels properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
davisking committed May 30, 2011
1 parent 2dd28ac commit b13bb36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions dlib/image_transforms/thresholding.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion dlib/image_transforms/thresholding_abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b13bb36

Please sign in to comment.