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

Function binary_complement

dlib/image_transforms/morphological_operations.h:613–653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611 typename out_image_type
612 >
613 void binary_complement (
614 const in_image_type& in_img_,
615 out_image_type& out_img_
616 )
617 {
618 typedef typename image_traits<in_image_type>::pixel_type in_pixel_type;
619 typedef typename image_traits<out_image_type>::pixel_type out_pixel_type;
620 COMPILE_TIME_ASSERT( pixel_traits<in_pixel_type>::has_alpha == false );
621 COMPILE_TIME_ASSERT( pixel_traits<out_pixel_type>::has_alpha == false );
622
623
624 using namespace morphological_operations_helpers;
625 COMPILE_TIME_ASSERT(pixel_traits<in_pixel_type>::grayscale);
626 DLIB_ASSERT(is_binary_image(in_img_) ,
627 "\tvoid binary_complement()"
628 << "\n\tin_img must be a binary image"
629 );
630
631 const_image_view<in_image_type> in_img(in_img_);
632 image_view<out_image_type> out_img(out_img_);
633
634 // if there isn't any input image then don't do anything
635 if (in_img.size() == 0)
636 {
637 out_img.clear();
638 return;
639 }
640
641 out_img.set_size(in_img.nr(),in_img.nc());
642
643 for (long r = 0; r < in_img.nr(); ++r)
644 {
645 for (long c = 0; c < in_img.nc(); ++c)
646 {
647 if (in_img[r][c] == on_pixel)
648 assign_pixel(out_img[r][c], off_pixel);
649 else
650 assign_pixel(out_img[r][c], on_pixel);
651 }
652 }
653 }
654
655 template <
656 typename image_type

Callers

nothing calls this directly

Calls 7

is_binary_imageFunction · 0.85
assign_pixelFunction · 0.85
sizeMethod · 0.45
clearMethod · 0.45
set_sizeMethod · 0.45
nrMethod · 0.45
ncMethod · 0.45

Tested by

no test coverage detected