Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. # Rule based filtering of skin pixels
  2. # (RED>95) && (GREEN>40) && (BLUE>20) && ((max(RED,max(GREEN,BLUE)) - min(RED,min(GREEN,BLUE)))>15) && (abs(RED-GREEN)>15) && (RED>GREEN) && (RED>BLUE);
  3.  
  4. result = np.zeros(img_color.shape)
  5.  
  6. # Method 1 - naive with loops
  7. # Remember BGR color space in OpenCV
  8. for row in range(img_color.shape[0]):
  9. for col in range(img_color.shape[1]):
  10. if (img_color[row, col, 2] > 95): # Condition on RED channel
  11. if (img_color[row, col, 1] > 40): # Condition on GREEN channel
  12. if (img_color[row, col, 0] > 20): # Condition on BLUE channel
  13. if ((np.maximum(img_color[row, col, 2], np.maximum(img_color[row, col, 1], img_color[row, col, 0])) - np.minimum(img_color[row, col, 2], np.minimum(img_color[row, col, 1], img_color[row, col, 0]))) > 15): # Condition on min max diff
  14. if (np.absolute(img_color[row, col, 2] - img_color[row, col, 1]) > 15): # Condition on absolute values
  15. if(img_color[row, col, 2] > img_color[row, col, 1]):
  16. if(img_color[row, col, 2] > img_color[row, col, 0]):
  17. # Now we can set the pixel value to 255
  18. result[row, col, :] = 255
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement