Any way to get the RGB values of the skin?
Closed this issue · 1 comments
nirdeshjoshiya commented
Is there any way to produce the RGB values of the skin in the console output? Something similar to how the output is produced as segments here But, I'm only wanting to produce a single RGB value for the skin. Any help would be highly appreciated!
WillBrennan commented
Hey - Sorry for the late reply. This is super simple to do with fancy indexing in numpy.
https://docs.scipy.org/doc/numpy/user/basics.indexing.html
Given your mask and image, you can
import numpy as np
image = np.random.randint(0, 256, (120, 240, 3))
# our mask can only contain 0 or 255.
mask = 255 * np.random.randint(0, 2, (120, 240))
skin_pixels = image[mask == 255]
print(skin_pixels.shape) # (N, 3)
mean_skin_colour = np.mean(skin_pixels, axis=0)
Happy learning!