如何从图像中提取背景?

发布于 2024-08-16 12:29:01 字数 334 浏览 4 评论 0原文

基本上,假设我有指纹。我知道我的图像的尺寸,并且我知道指纹是白色背景上的黑色或黑色背景上的绿色或类似的东西。

有没有办法只处理界定图像的部分,在本例中是指纹?我想做的基本上是这样的:

1)定界指纹
2)提取重要点与其他指纹进行比较
3)在之前提取过点的其他指纹数据库中找到最佳匹配

我已经有了用于 2 和 3 的方法,所以现在我只需要界定图像。

编程语言必须是 Ruby、Java 或 C++。首选 Ruby,然后是 Java,如果我必须使用 C++,请上帝帮助我。我没有任何图像处理经验,但如果可能的话,我想使用多种常见格式(例如 jpg、gif、png)来完成此操作。

Basically, suppose that I have a fingerprint. I know the dimension of my image, and I know that the fingerprint is black on a white background or that it is green on a black background or something like that.

Is there a way to process only the parts that delimit the image, in this case, the fingerprint? What I'm trying to do is basically this:

1) Delimit fingerprint
2) Extract the important points to compare to other fingerprints
3) Find best match on a database of other fingerprints that had their points previously extracted

I already have methods for 2 and 3, so now I just would have to delimit the image.

Programming language would have to be Ruby, Java or C++. Ruby preferred, then Java, and God help me if I have to use C++. I don't have any experience with image processing, but I'd like to do this with multiple common formats such as jpg, gif, png, if possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请你别敷衍 2024-08-23 12:29:01

我认为最好的方法是对图像应用边缘检测过滤器。

维基百科(文章)建议了一些方法,但没有一个是微不足道的,因为它们研究梯度或内核。您应该检查Canny边缘检测,它应该足够简单地实现:教程

无论如何,如果您想避免深入了解实现细节,您应该使用OpenCV,它是一个计算机视觉库,能够以简单的方式完成这些事情。您肯定可以在 C++ 和 Java 中使用它,但我认为也提供了 Ruby 的包装器。 这是一个使用该库与 Canny 的简单示例算法。

编辑:实际上我的答案涵盖了第2-3点,所以我想知道你所说的界定图像是什么意思?考虑一下这样一个事实:如果您想比较不同的指纹,也必须考虑缩放或旋转:您需要一个模糊比较器..也许您应该研究图像的快速傅立叶变换版本,它可以以更好的方式处理此类事情。

I think that the best way to do it is applying a edge detection filter to your image.

There are may approaches as suggested by wikipedia (article), but noone of them is trivial because they work on gradients or kernels. You should check Canny Edge Detection that should be enough straight-forward to implement: tutorial.

In any case if you want to avoid going deep into implementation details you should use OpenCV that is a computer vision library able to do these things in a simple way. You can use it for sure in C++ and Java but I think that a wrapper for Ruby is offered too. This is a simple example using that library with Canny algorithm.

EDIT: actually my answer covers point 2-3, so I'm wondering what you mean by delimiting the image? Think about the fact that scaling or rotating must be considered too if you want to compare different fingerprints: you need a fuzzy comparator.. maybe you should work on the Fast Fouried Transform version of the image that can handle such things in a better way.

琴流音 2024-08-23 12:29:01

一个简单的方法是使用阈值,例如:

将图像转换为灰度 - 这样您的指纹就会变成黑底白字。

找到一个能够获取大部分指纹的阈值。

使用开运算(http://en.wikipedia.org/wiki/Mathematical_morphology)来消除噪声。
(用扩张实验几次)

找到图像的重心(x,y)和标准差(vx,vy)。

框中:

[x-2vx,y-2vy],
[x-2vx,y+2vy],
[x+2vx,y+2vy],
[x+2vx,y-2vy]

你会发现95.4%的像素
如果有许多异常值,您可以缩小框范围以找到其中的实际最大和最小像素。
使用该框从原始图像中剪辑。

这是一个简单的方法,可能适合您的情况:)

An easy approach could be using threshold, like:

Convert your image to grayscale - so you have fingerprint in white on black.

Find a threshold value that gets most of the fingerprint.

Use open operation (http://en.wikipedia.org/wiki/Mathematical_morphology) to remove noise.
(experiment with dilate a few times)

Find the center of gravity (x,y) of the image and the standard deviation (vx, vy).

In the box:

[x-2vx,y-2vy],
[x-2vx,y+2vy],
[x+2vx,y+2vy],
[x+2vx,y-2vy]

You will find 95.4% of the pixels
You could narrow the box down to find the actual max and min pixels in it, if you have many outliers.
Use the box to clip from the original image.

It is simple method that might work well for your situation :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文