MCPcopy Create free account
hub / github.com/davisking/dlib / threshold_image

Function threshold_image

dlib/image_transforms/thresholding.h:368–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366 typename out_image_type
367 >
368 void threshold_image (
369 const in_image_type& in_img_,
370 out_image_type& out_img_,
371 typename pixel_traits<typename image_traits<in_image_type>::pixel_type>::basic_pixel_type thresh
372 )
373 {
374 COMPILE_TIME_ASSERT( pixel_traits<typename image_traits<in_image_type>::pixel_type>::has_alpha == false );
375 COMPILE_TIME_ASSERT( pixel_traits<typename image_traits<out_image_type>::pixel_type>::has_alpha == false );
376
377 COMPILE_TIME_ASSERT(pixel_traits<typename image_traits<out_image_type>::pixel_type>::grayscale);
378
379 const_image_view<in_image_type> in_img(in_img_);
380 image_view<out_image_type> out_img(out_img_);
381
382 // if there isn't any input image then don't do anything
383 if (in_img.size() == 0)
384 {
385 out_img.clear();
386 return;
387 }
388
389 out_img.set_size(in_img.nr(),in_img.nc());
390
391 for (long r = 0; r < in_img.nr(); ++r)
392 {
393 for (long c = 0; c < in_img.nc(); ++c)
394 {
395 if (get_pixel_intensity(in_img[r][c]) >= thresh)
396 assign_pixel(out_img[r][c], on_pixel);
397 else
398 assign_pixel(out_img[r][c], off_pixel);
399 }
400 }
401 }
402
403// ----------------------------------------------------------------------------------------
404

Callers 4

py_threshold_image2Function · 0.85
py_threshold_imageFunction · 0.85
image_testFunction · 0.85
auto_threshold_imageFunction · 0.85

Calls 8

get_pixel_intensityFunction · 0.85
assign_pixelFunction · 0.85
partition_pixelsFunction · 0.85
sizeMethod · 0.45
clearMethod · 0.45
set_sizeMethod · 0.45
nrMethod · 0.45
ncMethod · 0.45

Tested by 1

image_testFunction · 0.68