In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "Python traditional image processing skin area detection methods have what", in daily operation, I believe many people in Python traditional image processing skin area detection methods have what problems, small editor consulted all kinds of data, sorted out simple and easy to use operation methods, hope to answer "Python traditional image processing skin area detection methods have what" doubts help! Next, please follow the small series to learn together!
1. RGB space
The range of skin tones in the RGB model basically satisfies the following constraints:
Under uniform illumination, the following discriminant shall be satisfied:
R>95 AND G>40 B>20 AND MAX(R,G,B)-MIN(R,G,B)>15 AND ABS(R-G)>15 AND R>G AND R>B
In edge-lit environments:
R>220 AND G>210 AND B>170 AND ABS(R-G)B AND G>B
Code:
def skinMask_rgb(image): b, g, r = cv2.split(image) mask_uniformity = (r>95)*(g>40)*(b>20)* (np.max(image, axis=2) -np.min(image,axis=2)>15)* (abs(r-g)>15)*(r>g)*(r>b) mask_side = (r>220)*(g>210)*(b>170)*(abs(r-g)b)*(g>b) mask = mask_uniformity|mask_side skin = np.array(mask, np.uint8)*255 ratio = np.sum(skin/255)/(image.shape[0]*image.shape[1]) return skin, ratio
Effect:
2. Ycrcb space
In RGB space, the skin color of human face is greatly affected by brightness, so it is difficult to separate skin color points from non-skin color points, that is to say, after processing in this space, skin color points are discrete points with many non-skin colors embedded in the middle. If RGB is converted to YCrCb space, the effect of Y(luminance) can be ignored, because this space is less affected by luminance, and skin color will produce good clustering. This reduces the three-dimensional space to two-dimensional CrCb, and the skin color points will form a certain shape.
133≤Cr≤173
77≤Cb≤127
Code:
def skinMask_YCrCb(image): YCrCb = cv2.cvtColor(image, cv2.COLOR_BGR2YCR_CB) #Convert to YCrCb space (y,cr,cb) = cv2.split(YCrCb) #Split Y,Cr,Cb values skin = np.zeros(cr.shape, dtype = np.uint8) (x,y) = cr.shape cr_mask1 = cr >= 133 cr_mask2 = cr = 77 cb_mask2 = cb
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.