문제

I am trying to remove a background using MatLab.

I have achieved what looks like very good results using the traditional

imsubtracted = im - background;

However, the blackness that has replaced the background is not pure black. Further image processing reveals that there is a significant amount of noise left over. Is it possible to either completely remove the background or make it uniformly the same color?

Please note, I am dealing with very small objects in a rather large black space.

도움이 되었습니까?

해결책

Once you subtract the background, you should threshold the resulting image to create a binary foreground mask. Set all the differences less than a threshold to 0 (background), and set the ones greater than or equal to a threshold to 1 (foreground). You can then use morphology such as imopen to get rid of small noisy specks in the background and imclose to get rid of small gaps or holes in the foreground.

Once you are happy with your foreground mask, you can use it as a logical index to set the background pixels to whatever color you choose.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top