首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Remove some interference through opening and closing operations

Remove some interference through opening and closing operations

原创
作者头像
Swing Dunn
发布2025-10-18 10:14:29
发布2025-10-18 10:14:29
280
举报
文章被收录于专栏:答题卡识别答题卡识别

Due to printing, especially oil printing rather than laser printing, the printing quality may be poor. In addition, uneven filling by students may also lead to similar results. After scanning, the areas that should have been solid rectangles become regions composed of noise points.

Positioning block may like this:

positioning block
positioning block

Opt question ans blocks may like this:

option blocks
option blocks

This situation can be addressed by filling in small areas after contour search or by directly eliminating interference through closing operations.

Select the size of the structure as needed,Here, a 9*9 structure is used outside.

代码语言:txt
复制
	Mat kernel = getStructuringElement(MORPH_RECT, Size(9, 9));
	Mat closed;
	morphologyEx(binary, closed, MORPH_CLOSE, kernel);

Result img:

closed positioning block(binary)
closed positioning block(binary)
closed option block(binary)
closed option block(binary)

However, due to the contamination around the positioning block, it may also cause some new problems, resulting in the rectangular shape of the positioning block being larger than expected.

Red rect is the detected rect shape of the positioning block, which is larger than expected,the blue one.

positioning block
positioning block

Here, the open operation is adopted to eliminate the interfering items that extend outwards. Of course, an inward search method can also be used here to remove the black borders around the white target rectangle.

Here, we employ a 5*5 structure to perform the opening operation.

代码语言:txt
复制
Mat kernel2 = getStructuringElement(MORPH_RECT, Size(5, 5));
Mat opened;
morphologyEx(closed, opened, MORPH_OPEN, kernel);
binary = opened.clone();  

Here , result:

result
result

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档