ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

7.29 第四场 License Plate Recognition

2021-08-02 23:03:40  阅读:201  来源: 互联网

标签:Little 7.29 character image ....................................................


License Plate Recognition

Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 332 Accepted Submission(s): 175

Problem Description

Little Rabbit is a college student who is studying Communication Engineering. In this term, he has a course called Digital Image Processing. At the end of the course, Little Rabbit needs to complete a project called License Plate Recognition, in which Little Rabbit should program a system to recognize the characters of a license plate in an image.

A classic License Plate Recognition system has three modules:

  • License Plate Localization: to localize the license plate in the image.
  • Character Segmentation: to segment the image so that the characters of the license plate can be separated.
  • Character Recognition: to recognize the characters in the image and get the result string.

To complete the project, Little Rabbit builds a team of three members. Each member is in charge of one module. Here, Little Rabbit is in charge of the second module — Character Segmentation.

After the License Plate Localization module and some preprocessing, Little Rabbit gets some binary images that represent the license plates. The binary images are all 100 pixels in width and 30 pixels in height, containing only black pixels and white pixels. The black pixels represent the background, and the white pixels represent the characters.

Little Rabbit’s task is to segment the binary images so that the characters in the images can be separated. According to the standard, there are seven characters in a license plate, lining up from left to right. Specifically, Little Rabbit’s task is to find the left boundary and the right boundary of each character.

Let’s consider the images as matrices with 30 rows and 100 columns. Then number the columns 1 to 100 from left to right. We define the left boundary of a character as the index of the column where the leftmost pixel is located, and the right boundary as the index of the column where the rightmost pixel is located. For example, in the following picture, the left boundary of the character is 3, and the right boundary is 7.

img

Now given the binary images that Little Rabbit needs to segment, please output the left boundary and the right boundary of each character. In this problem, we use . to represent a black pixel, and # to represent a white pixel.

Input

The first line contains an integer T (1≤T≤50) — the number of test cases.

Each test case represents a binary image, which contains 30 lines of strings. Each line contains 100 characters, either . (a black pixel) or # (a white pixel).

Here are all the characters that may appear in the image.

Chinese characters:

img

ASCII version: https://paste.ubuntu.com/p/B5pTWv7s6J/
(Backup: https://github.com/cjj490168650/plate/blob/main/chn.txt)

English and numeric characters:

img

ASCII version: https://paste.ubuntu.com/p/59bjvwY3Yr/
(Backup: https://github.com/cjj490168650/plate/blob/main/eng.txt)

It is guaranteed that:

  • The characters in the image follow the standard of license plates. There are seven characters in the image, lining up from left to right. The first character is a Chinese character. The second character is an English character. The last five characters are English or numeric characters.
  • All characters in the image are identical to the characters given above (ASCII version), including the size and the shape.
  • There are no redundant white pixels in the image.
  • There is spacing between characters.
  • The characters won’t touch or get out of the image boundaries.

Output

For the x-th test case, output Case #x: in the first line.

Then in the next seven lines, the i-th line contains two integers separated by a space character, indicating the left boundary and the right boundary of the i-th character.

Sample Input

1
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
..........................##...........##..........#####......########..........##......########....
.......#.......#..........###..........##.........#######.....########.........###......########....
.......#.......#..........###..........##........##....##..........###.........###......##..........
.......#.......#.........####..........##...............##........###.........####......##..........
....###############......####..........##..............##........###..........####......##..........
.......#.......#.........##.#..........##..............##.......###...........####......##..........
.......#.......#.........##.##.........##..............##.......#####........#####......#######.....
.......#.......#.........##.##.........##.............##........######.......##.##......########....
.......#.......#........###.##.........##............###............##......###.##............###...
.......#########........##..##.........##...........###.............##......##..##.............##...
.......#.......#........##...#.........##...........##..............##......##..##.............##...
.......#.......#........##...##........##..........###..............##.....##...##.............##...
.......#.......#........#######........##.........###.........##....##.....#########...........##...
.......#.......#.......########........##.........##..........##....##.....#########....##.....##...
.......#########.......##....##........##........###..........###...##..........##.......##...###...
.......#.......#.......##....##........##........########......######...........##.......#######....
.......................##.....##.......##........########.......####............##........#####.....
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................
....................................................................................................

Sample Output

Case #1:
5 19
24 32
40 41
50 58
63 70
76 84
89 97

大概题意

判断所给车牌二值图中各个字母汉字边界

思路

避免汉字中间有空白,从右往左扫描

代码

//
// Created by Black on 2021/7/29.
//

#include<iostream>
#include <cstring>

using namespace std;
const int N = 110;
int t;
bool st[N];
string s;
pair<int, int> res[10];

int main() {
    cin >> t;
    getchar();
    for (int p = 0; p < t; ++p) {
        memset(st, 0, sizeof st);
        for (int j = 0; j < 30; ++j) {
            getline(cin, s);
            for (int i = 0; i < s.length(); ++i) {
                if (s[i] == '#')
                    st[i] = true;
            }
        }
        int end = 0, start = 0;
        int i = 105, idx = 0;
        while (i--) {
            while (!st[i])i--;
            end = i + 1;
            if (idx == 6)
                break;
            while (st[i])i--;
            start = i + 2;
            res[idx++] = {start, end};
        }
        for (int j = 0; j < end; ++j) {
            if (st[j]) {
                start = j + 1;
                break;
            }
        }
        res[idx++] = {start, end};
        cout << "Case #" << p + 1 << ":\n";
        for (int j = 6; j >= 0; --j) {
            cout << res[j].first << " " << res[j].second << "\n";
        }
    }
    return 0;
}

标签:Little,7.29,character,image,....................................................
来源: https://blog.csdn.net/qq_46039856/article/details/119335944

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有