Advertisement
dan-masek

Untitled

Dec 1st, 2022
820
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. lab_rule_1 = L >= L_mean
  2. lab_rule_2 = a >= a_mean
  3. lab_rule_3 = b >= b_mean
  4. lab_rule_4 = b >= a_mean
  5. lab_satisfied = lab_rule_1 & lab_rule_2 & lab_rule_3 & lab_rule_4
  6.  
  7. rgb_rule_1 = (R > G) & (G > B) # No chaining in numpy
  8. rgb_rule_2 = R >= R_mean
  9. rgb_satisfied = rgb_rule_1 & rgb_rule_2
  10.  
  11. ycbcr_rule_1 = (R >= G) & (G > B)
  12. ycbcr_rule_2 = (R > 190) & (G > 100) & (B < 140)
  13. ycbcr_rule_3 = Y >= Cb
  14. ycbcr_rule_4 = Cr >= Cb
  15. ycbcr_satisfied = (ycbcr_rule_1 & ycbcr_rule_2) | (ycbcr_rule_3 & ycbcr_rule_4)
  16.  
  17.  
  18. lab_convert = np.uint8(lab_satisfied) * 255
  19. rgb_convert = np.uint8(rgb_satisfied) * 255
  20. ycbcr_convert = np.uint8(ycbcr_satisfied) * 255
  21.  
  22. combined = lab_convert | rgb_convert | ycbcr_convert
  23. frame_copy = np.repeat(combined[:, :, np.newaxis], 3, axis=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement