Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. void Imagem::binariza()
  2. {
  3. for (int y = 0; y < altura - 1; y++)
  4. for (int x = 0; x < largura; x++)
  5. {
  6. int RGB = getPixel(x, y);
  7. int B = RGB >> 16 & 255;
  8. int G = RGB >> 8 & 255;
  9. int R = RGB & 255;
  10.  
  11. R = (R + G + B) / 3.0;
  12.  
  13. if (R > 127)
  14. R = 255;
  15. else
  16. R = 0;
  17.  
  18. G = R;
  19. B = R;
  20. setPixel(x, y, R, G, B);
  21. }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement