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

Function test_segment_image

dlib/test/image.cpp:1706–1742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1704
1705 template <typename T>
1706 void test_segment_image()
1707 {
1708 print_spinner();
1709 array2d<T> img(100,100);
1710 for (long r = 0; r < img.nr(); ++r)
1711 {
1712 for (long c = 0; c < img.nc(); ++c)
1713 {
1714 if (c < 50 || r < 50)
1715 assign_pixel(img[r][c], 0);
1716 else
1717 assign_pixel(img[r][c], 255);
1718 }
1719 }
1720
1721 array2d<unsigned long> out;
1722 segment_image(img, out);
1723
1724 DLIB_TEST(get_rect(img) == get_rect(out));
1725 const unsigned long v1 = out[0][0];
1726 const unsigned long v2 = out[90][90];
1727
1728 for (long r = 0; r < img.nr(); ++r)
1729 {
1730 for (long c = 0; c < img.nc(); ++c)
1731 {
1732 if (c < 50 || r < 50)
1733 {
1734 DLIB_TEST(out[r][c] == v1);
1735 }
1736 else
1737 {
1738 DLIB_TEST(out[r][c] == v2);
1739 }
1740 }
1741 }
1742 }
1743
1744// ----------------------------------------------------------------------------------------
1745

Callers

nothing calls this directly

Calls 6

print_spinnerFunction · 0.85
assign_pixelFunction · 0.85
segment_imageFunction · 0.85
get_rectFunction · 0.85
nrMethod · 0.45
ncMethod · 0.45

Tested by

no test coverage detected