C# 中的图像转换
我正在开发一个生成和读取表单的文档处理应用程序。所附的示例表单生成为打印文档,由人员填写、扫描并反馈到应用程序以检测填充值,包括光学标记(气泡)、文本 (OCR) 等。 单击此处获取示例表格。
由于扫描会在旋转、缩放和平移方面扭曲图像,因此我使用三个标记来检测方向并以相当原始的方式校正图像,这在计算和内存方面非常昂贵。其要点如下:
- 从磁盘读入图像。
- 使用 AForge.net 检测 bolb。
- 使用形状、相对大小和其他属性过滤掉标记。
- 计算旋转并旋转图像。
- 使用 AForge.net 从旋转图像中检测 bolb。
- 计算比例和比例旋转图像。
- 使用 AForge.net 从缩放图像中检测 bolb。
- 计算平移并平移旋转、缩放的图像。
- 使用 AForge.net 从翻译后的图像中检测 bolb。
- 过滤掉答案标记(气泡),因为我已经有了原始表格的位置。
- 提取平均颜色并与阈值进行比较以确定选项是否已填充。
上述是一种极其准确但效率低下的处理方法,我希望采用几何方法仅提取一次斑点,过滤掉标记/气泡并使用简单的数学来计算气泡相对于标记的预期位置。这将减少 80% 的处理时间和 60% 的内存使用量。
或者,必须有一种方法可以在单个图像上应用所有三种变换,而不会影响下一个图像。这也将减少三次斑点检测的需要。
I am working on a document processing application that generates and reads forms. The sample form attached is generated as a printed document, filled out by people, scanned and fed back to the application to detect filled values including Optical Marks (Bubbles), Text (OCR), etc. Click here for Sample Form.
Since scanning distorts the image in terms of rotation, scale and translation, I use the three markers to detect orientation and correct the image in a rather primitive way that is VERY expensive on computation and memory. Here is the gist of it:
- Read in the image from disk.
- Detect bolbs using AForge.net.
- Filter out the markers using shape, relative size and other properties.
- Calculate rotation and rotate image.
- Detect bolbs from the rotated image using AForge.net.
- Calculate scale and scale rotated image.
- Detect bolbs from the scaled image using AForge.net.
- Calculate translation and translate rotated, scaled image.
- Detect bolbs from the translated image using AForge.net.
- Filter out answer marks (bubbles) since I already have the positions of the original form.
- Extract mean color and compare to threshold to determine if the option is filled.
The above being an extremely accurate but inefficient way to process, I am looking to take a geometric approach to extracting blobs only ONCE, filtering out markers/bubbles and using simple math to figure out expected positions of bubbles relative to the markers. This should cut down the processing time by 80% and memory usage by 60%.
Alternately, there HAS to be a way to apply all three transformations on a single image without one affecting the next. That would also reduce the need for blob detection thrice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会对图像进行建模,并在内存中的模型(而不是实际图像)上进行转换。然后,一旦计算出变换矩阵,您就可以将其应用于实际图像来进行 OCR。
I would model the image and do the transformations on that model in memory instead of the actual image. Then once you have calculated the transformation matrix you can apply it to the actual image to do the OCR.