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

Function binary_intersection

dlib/image_transforms/morphological_operations.h:397–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395 typename out_image_type
396 >
397 void binary_intersection (
398 const in_image_type1& in_img1_,
399 const in_image_type2& in_img2_,
400 out_image_type& out_img_
401 )
402 {
403 typedef typename image_traits<in_image_type1>::pixel_type in_pixel_type1;
404 typedef typename image_traits<in_image_type2>::pixel_type in_pixel_type2;
405 typedef typename image_traits<out_image_type>::pixel_type out_pixel_type;
406 COMPILE_TIME_ASSERT( pixel_traits<in_pixel_type1>::has_alpha == false );
407 COMPILE_TIME_ASSERT( pixel_traits<in_pixel_type2>::has_alpha == false );
408 COMPILE_TIME_ASSERT( pixel_traits<out_pixel_type>::has_alpha == false );
409
410 using namespace morphological_operations_helpers;
411 COMPILE_TIME_ASSERT(pixel_traits<in_pixel_type1>::grayscale);
412 COMPILE_TIME_ASSERT(pixel_traits<in_pixel_type2>::grayscale);
413 DLIB_ASSERT(is_binary_image(in_img1_) ,
414 "\tvoid binary_intersection()"
415 << "\n\tin_img1 must be a binary image"
416 );
417 DLIB_ASSERT(is_binary_image(in_img2_) ,
418 "\tvoid binary_intersection()"
419 << "\n\tin_img2 must be a binary image"
420 );
421
422 const_image_view<in_image_type1> in_img1(in_img1_);
423 const_image_view<in_image_type2> in_img2(in_img2_);
424 image_view<out_image_type> out_img(out_img_);
425
426 DLIB_ASSERT(in_img1.nc() == in_img2.nc(),
427 "\tvoid binary_intersection()"
428 << "\n\tin_img1 and in_img2 must have the same ncs."
429 << "\n\tin_img1.nc(): " << in_img1.nc()
430 << "\n\tin_img2.nc(): " << in_img2.nc()
431 );
432 DLIB_ASSERT(in_img1.nr() == in_img2.nr(),
433 "\tvoid binary_intersection()"
434 << "\n\tin_img1 and in_img2 must have the same nrs."
435 << "\n\tin_img1.nr(): " << in_img1.nr()
436 << "\n\tin_img2.nr(): " << in_img2.nr()
437 );
438
439
440
441 // if there isn't any input image then don't do anything
442 if (in_img1.size() == 0)
443 {
444 out_img.clear();
445 return;
446 }
447
448 out_img.set_size(in_img1.nr(),in_img1.nc());
449
450 for (long r = 0; r < in_img1.nr(); ++r)
451 {
452 for (long c = 0; c < in_img1.nc(); ++c)
453 {
454 if (in_img1[r][c] == on_pixel && in_img2[r][c] == on_pixel)

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected