我怎样才能从mahotas中的图像和python中的opencv中减去背景? [英] How can i subtract the background from an image in mahotas and opencv in python?
本文介绍了我怎样才能从mahotas中的图像和python中的opencv中减去背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I have many image like this or like this and i use this code:
fork = mh.imread(path)
bin = fork[:,:,0]
bin = mh.erode(bin)
bin = (bin < 80)
但是我必须使用这个:
bin = (bin < 127)
对于第一个。
有一种方法可以自动获得没有背景的好图像,或者我必须选择一个中值,希望对我的大多数图像都有好处?
There is a way for automatically obtain a good image without background, or i have to choose a median value hopefully is good for the most of my images?
推荐答案
有一个名为Otsu Threshold的阈值。 此处您有更多信息。
There is a threshold value that is called "Otsu Threshold". Here you have more information.
您可以使用 otsu
在Mahotas或 threshold_otsu $ c scikit-image 中的$ c>
:
You can use otsu
to do it in Mahotas or threshold_otsu
in scikit-image:
fork = mh.imread(path)
bin = fork[:,:,0]
thresh = mh.otsu(bin)
binary =( bin< thresh)
这篇关于我怎样才能从mahotas中的图像和python中的opencv中减去背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文