2016-09-14 24 views
0

我有一个图像,我可以从下面的代码中看到一个蒙版颜色。面具提供黑白图像。白色是我检测到的颜色。白色的像素值是255,黑色是0.Python OpenCV获得最底层的蒙版值

我想获得掩模白色部分的最底部的x和Y像素。我该怎么做呢? 我的代码如下:

image = cv2.imread(FILENAME) 

# THE COLOURS ARE IN RGB 
lower_blue = np.array([50, 0, 0]) 
upper_blue = np.array([255, 50, 50]) 

# loop over the boundaries 
# for (lower, upper) in boundaries: 
    # create NumPy arrays from the boundaries 
lower = np.array(lower_blue, dtype = "uint8") 
upper = np.array(upper_blue, dtype = "uint8") 

# find the colors within the specified boundaries and apply 
# the mask 
mask = cv2.inRange(image, lower, upper) 

回答

0

可以使用numpy的的where搜索你的面具的特定值:

np.max(np.where(np.max(img_binary,axis=1)==255)