| 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 |
nothing calls this directly
no test coverage detected