我在使用 mahotas 库的灰色背景图像时遇到了一些问题:
例子:
这是代码:
import mahotas as mh
path ="./imagepath/a.jpg"
fork = mh.imread(path)
bin = fork[:,:,0]
bfork = bin <230
之后我得到了:
我该怎么做才能获得黑色背景和白色标志?我在 opencv 模块中尝试过并且很好,但我更喜欢 mahotas。
import cv2
path ="./imagepath/a.jpg"
ow = int ((oshape[0]/100 )*7 )
oh = int ((oshape[0]/100 )*7 )
gray = cv2.imread(path,0)
element = cv2.getStructuringElement(cv2.MORPH_CROSS,(ow,oh))
graydilate = cv2.erode(gray, element)
ret,thresh = cv2.threshold(graydilate,127,255,cv2.THRESH_BINARY_INV)
bin = thresh