从X像素或更少像素的图像中删除形状 [英] Remove shapes from image with X number of pixels or less

查看:170
本文介绍了从X像素或更少像素的图像中删除形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有图像,让我们说方块。是否可以删除由10(非白色)像素或更少像素形成的所有形状,并保留由11像素或更多像素组成的所有形状?我想以编程方式或命令行来完成。

If I have a image with, let's say squares. Is it possible to remove all shapes formed by 10 (non white) pixels or less and keep all shapes that is formed by 11 pixels or more? I want to do it programmatically or with a command line.

提前致谢!

推荐答案

有几种方法可以解决这个问题。您所指的是文档成像应用程序中通常称为Despeckle。文档扫描仪在扫描过程中经常会在图像中引入大量污垢和噪声,因此必须将其移除以帮助提高OCR准确度。

There are a couple of ways to approach this. What you are referring to is commonly called Despeckle in Document Imaging Applications. Document scanners often introduce a lot of dirt and noise into an image during scanning and so this must be removed removed to help improve OCR accuracy.

我假设您正在处理B /这里的W图像或者可以将图像转换为B / W,否则会变得复杂得多。通过分析页面上的所有斑点来完成去斑点。另一种决定blob大小的方法是决定宽度,高度和组合像素的数量。

I assume you are processing B/W images here or can convert your image to B/W otherwise it becomes a lot more complex. Despeckle is done by analysing all the blobs on the page. Another way to decide on blob size is to decide on width, height and number of pixels combined.

Leptonica.com - 是一个基于开源C的库,它有blob您需要的分析功能。通过一些简单的检查和循环,您可以删除这些较小的对象。 Leptonica也可以很容易地编译成命令行程序。有许多示例程序,这是学习Leptionica的最佳方法。

Leptonica.com - Is an Open Source C based library that has the blob analysis functions you require. With some simple check and loops you can delete these smaller objects. Leptonica can also be compiled quite easily into a command line program. There are many example programs and that is the best way to learn Leptionica.

对于测试,您可能想尝试ImageMagick。它有一个用于去除斑点的命令行选项,但它没有其他参数。
http://www.imagemagick.org/script/command -line-options.php #despeckle

For testing, you may want to try ImageMagick. It has a command line option for despeckle but it has no further parameters. http://www.imagemagick.org/script/command-line-options.php#despeckle

另一种选择是在Google中寻找去除斑点算法。

The other option is to look for "despeckle" algorithms in Google.

这篇关于从X像素或更少像素的图像中删除形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆