Background subtracting in MATLAB

前端 未结 3 1373
被撕碎了的回忆
被撕碎了的回忆 2021-01-12 18:24

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

3条回答
  •  别那么骄傲
    2021-01-12 19:03

    What kind of image do you work with?

    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.

    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.

提交回复
热议问题