From a7289869089b142e41cd269f3764e6f16f088da0 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sat, 4 Aug 2018 11:03:19 +0200 Subject: Ignore small digit notes --- shot.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/shot.cpp b/shot.cpp index b0c1fdb..bcaa607 100644 --- a/shot.cpp +++ b/shot.cpp @@ -81,12 +81,13 @@ int w, h; template int flood(int x, int y, bool *mark) { + if (!F(img[w*y+x])) return 0; mark[w*y+x] = true; int t = 1; - if (x > 0 && !mark[w*y+x-1] && F(img[w*y+x-1])) t += flood(x-1, y, mark); - if (y > 0 && !mark[w*(y-1)+x] && F(img[w*(y-1)+x])) t += flood(x, y-1, mark); - if (x < w-1 && !mark[w*y+x+1] && F(img[w*y+x+1])) t += flood(x+1, y, mark); - if (y < h-1 && !mark[w*(y+1)+x] && F(img[w*(y+1)+x])) t += flood(x, y+1, mark); + if (x > 0 && !mark[w*y+x-1]) t += flood(x-1, y, mark); + if (y > 0 && !mark[w*(y-1)+x]) t += flood(x, y-1, mark); + if (x < w-1 && !mark[w*y+x+1]) t += flood(x+1, y, mark); + if (y < h-1 && !mark[w*(y+1)+x]) t += flood(x, y+1, mark); return t; } @@ -140,6 +141,7 @@ void cmd_recog() { // writeimg(img, w, h, "out1.png"); bool *mark = new bool[w*h](); + bool *mark2 = new bool[w*h]; int maxn = -1, maxi = -1; for (int y = 0; y < h; y++) { @@ -150,10 +152,19 @@ void cmd_recog() { maxn = n; maxi = w*y + x; } + if (0 < n && n < 300) { + memset(mark2, 0, w*h*sizeof(bool)); + flood(x, y, mark2); + for (int i = 0; i < w*h; i++) { + if (mark2[i]) img[i] = {255, 255, 255}; + } + } } } } + delete[] mark2; + memset(mark, 0, w*h*sizeof(bool)); flood(maxi%w, maxi/w, mark); -- cgit v1.2.3-70-g09d2