| 1 | #include <cvd/connected_components.h> |
| 2 | #include <cvd/image.h> |
| 3 | #include <iostream> |
| 4 | |
| 5 | using namespace std; |
| 6 | using namespace CVD; |
| 7 | |
| 8 | int main() |
| 9 | { |
| 10 | for(int i = 0; i < (1 << 9); i++) |
| 11 | { |
| 12 | cout << "------------------------\n" |
| 13 | << i << endl; |
| 14 | int j = i; |
| 15 | vector<ImageRef> p; |
| 16 | for(int y = 0; y < 3; y++) |
| 17 | for(int x = 0; x < 3; x++) |
| 18 | { |
| 19 | if(j & 1) |
| 20 | p.push_back(ImageRef(x, y)); |
| 21 | j >>= 1; |
| 22 | } |
| 23 | |
| 24 | vector<vector<ImageRef>> v; |
| 25 | connected_components(p, v); |
| 26 | |
| 27 | Image<char> im(ImageRef(3, 3), '.'); |
| 28 | |
| 29 | for(unsigned int j = 0; j < v.size(); j++) |
| 30 | for(unsigned int k = 0; k < v[j].size(); k++) |
| 31 | im[v[j][k]] = 65 + j; |
| 32 | |
| 33 | cout << "Created " << v.size() << " groups\n"; |
| 34 | cout.write(im.data(), 3); |
| 35 | cout << endl; |
| 36 | cout.write(im.data() + 3, 3); |
| 37 | cout << endl; |
| 38 | cout.write(im.data() + 6, 3); |
| 39 | cout << endl; |
| 40 | cout << endl; |
| 41 | cin.get(); |
| 42 | } |
| 43 | } |