сегментация переднего и заднего плана (otsu) и преобразование изображения в цветовые пространства HSV и YCrCb и обнаружение потенциальных пикселей
blue = []
green = []
red = []
height, width, channels = img_face_only.shape
print('width: ', width)
print('height: ', height)
print('channel:', channels)
for i in range (height):
for j in range (width):
if((img_HSV.item(i, j, 0) <= 170) and (140 <= img_YCrCb.item(i, j, 1) <= 170) and
(90 <=img_YCrCb.item(i, j, 2) <= 120)):
blue.append(img_face_only[i, j].item(0))
green.append(img_face_only[i, j].item(1))
red.append(img_face_only[i, j].item(2))
else:
img_face_only[i, j] = [0, 0, 0]
display_image(img_face_only, "final segmentation")
# determine mean skin tone estimate
skin_tone_estimate_BGR = [np.mean(blue), np.mean(green), np.mean(red)]
print ("mean skin tone estimate (BGR)", skin_tone_estimate_BGR[0], skin_tone_estimate_BGR[1], skin_tone_estimate_BGR[2], "]")```
> the result is always a [nan nan nan] which is wrong, I need to return the bgr values.