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)

관련 문제