| | |
| | | |
| | | } |
| | | |
| | | //手数,带有单位手 |
| | | else if (type == 6) { |
| | | //分隔手 |
| | | int num_end = endx; |
| | | int emptyIndex=-1; |
| | | int i; |
| | | for (i = endx; i >= startx; i--) { |
| | | bool empty = 1; |
| | | for (int y = starty; y < endy; y++) { |
| | | if (get_binary_value(img_in[get_one_level_position(width, i, y)]) > 0) { |
| | | empty = 0; |
| | | break; |
| | | } |
| | | } |
| | | if (empty) { |
| | | emptyIndex = i; |
| | | } |
| | | else if (emptyIndex > 0) { |
| | | num_end = i; |
| | | break; |
| | | } |
| | | } |
| | | endx = num_end; |
| | | //去除上下空白 |
| | | int startNy = -1; |
| | | int endNy = -1; |
| | | int y; |
| | | for (y = starty; y <= endy; y++) { |
| | | bool empty = 1; |
| | | for (int x = startx; x <= endx; x++) |
| | | { |
| | | int p = get_one_level_position(width, x, y); |
| | | unsigned char value = get_binary_value(img_in[p]); |
| | | //有数据 |
| | | if (value > 0) { |
| | | empty = 0; |
| | | break; |
| | | } |
| | | } |
| | | if (!empty) { |
| | | startNy = y; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | for (y = endy; y >= starty; y--) { |
| | | bool empty = 1; |
| | | for (int x = startx; x <= endx; x++) |
| | | { |
| | | int p = get_one_level_position(width, x, y); |
| | | unsigned char value = get_binary_value(img_in[p]); |
| | | //有数据 |
| | | if (value > 0) { |
| | | empty = 0; |
| | | break; |
| | | } |
| | | } |
| | | if (!empty) { |
| | | endNy = y; |
| | | break; |
| | | } |
| | | } |
| | | if (endNy > 0) |
| | | { |
| | | endy = endNy; |
| | | } |
| | | if (startNy > 0) |
| | | { |
| | | starty = startNy; |
| | | } |
| | | nps[0] = startx; |
| | | nps[1] = starty; |
| | | nps[2] = endx; |
| | | nps[3] = endy; |
| | | |
| | | nps[4] = -1; |
| | | nps[5] = -1; |
| | | nps[6] = -1; |
| | | nps[7] = -1; |
| | | |
| | | nps[8] = -1; |
| | | nps[9] = -1; |
| | | nps[10] = -1; |
| | | nps[11] = -1; |
| | | } |
| | | |
| | | //分隔数据 |
| | | |
| | | |