MATLAB中的背景减法 [英] Background subtracting in MATLAB

查看:825
本文介绍了MATLAB中的背景减法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找在图像上减去背景。我是MATLAB的新手,也是图像处理/分析的新手,很抱歉,如果这听起来很愚蠢。 1)除 imsubtract()之外还有其他方法可以进行背景减法(除了将一个图像与另一个图像进行比较)之外? 2)在数学作品中解释 imsubtract( )为什么他们将结构元素作为磁盘?到目前为止,这似乎相当困难,因为每次尝试某些东西时,我最终不仅会减去嘈杂的背景,还会丢失我想看的图像部分!

I'm looking to do background subtracting on an image. I'm new to MATLAB and new to image processing/analysis, so sorry if any of this sounds stupid. 1) Other than imsubtract() are there other ways to do background subtracting (besides comparing one image to another)? 2) In the Math Works explanation for imsubtract() why do they make their structuring element a disk? This seems rather difficult so far because every time I try something, I end up not only subtracting the noisy background but also losing the parts of the image I want to look at!

推荐答案

你使用什么样的形象?

背景减法很容易。如果要减去常量值或背景与图像大小相同,只需编写 img = img - background 即可。 imsubtract 只需确保背景大于图像的输出为零。

Background subtraction is easy. If you want to subtract a constant value, or a background with the same size as your image, you simply write img = img - background. imsubtract simply makes sure that the output is zero wherever the background is larger than the image.

背景估计很难。在那里你需要知道你正在看什么样的图像,否则,背景估计将失败。

Background estimation is hard. There you need to know what kind of image you're looking at, otherwise, the background estimation will fail.

如果你有例如斑点或线条特征要么是在暗背景上都是暗的,要么在黑暗的背景下都是明亮的,你可以使用局部最大过滤器( imdilate )或局部最小过滤器( imerode) ),分别大于您的功能,因此无论您在何处放置滤镜遮罩,都会有一些像素覆盖背景。此外,您希望过滤器的形状与功能有些相似。在您的情况下,如果您丢失了部分图像,则可能需要尝试使滤镜更大(但不要太大)。

If you have, for example, spot or line features that are either all dark on bright or bright on dark background, you can pass through with a local maximum filter (imdilate) or a local minimum filter (imerode), respectively, that is larger than your features, so that wherever you place the filter mask, there are some pixels that cover background. Also, you want the filter to have somewhat similar shape as the features. In your case, if you lose part of your image, you may want to try and make the filter larger (but not too large).

而不是减去最大值或最小值,减去中位数可以很好地工作,但你必须选择滤镜大小,使得滤镜蒙版内通常有大部分背景像素。不幸的是,中值过滤相当慢。

Instead of subtracting maximum or minimum, subtracting the median can work well, though you have to choose the filter size such that there's usually a majority of background pixels inside the filter mask. Unfortunately, median filtering is rather slow.

这篇关于MATLAB中的背景减法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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