#include "connected.h" #define _TEST #ifdef _TEST #include #include #include void test_inline_img() { const char *_img = { " " " * 0 * " " ** 0 * " " ******* " " * " " * " " *** " }; const unsigned char *img = (const unsigned char *)_img; int width = 14, height = 7; unsigned char *out_uc = (unsigned char *)malloc(width*height); ConnectedComponents cc(30); cc.connected(img, out_uc, width, height, std::equal_to(), false); for(int r=0; r(), constant()); unsigned char *out_uc = (unsigned char *)malloc(width*height); std::copy(out, out+width*height, out_uc); FILE *fout = fopen(outfname, "w"); fwrite(out_uc, 1, width*height, fout); fclose(fout); fclose(fin); free(img); free(out); free(out_uc); } main() { test_inline_img(); test_raw_img("img.raw", "out.raw", 321, 241); } #endif // _TEST