2016-09-14 3 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)

関連する問題