Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import aguiaj.iscte.Color;
  2. import aguiaj.iscte.ColorImage;
  3.  
  4. class manipulação{
  5. static ColorImage redução(ColorImage img, int escalar){
  6. int R=0;
  7. int G=0;
  8. int B=0;
  9. ColorImage imgreduzida = new ColorImage((int)img.getWidth()/escalar,(int)img.getHeight()/escalar);
  10. for(int i=0; i!=img.getWidth(); i++){
  11. for(int j=0; j!=img.getHeight(); j++){
  12. int [] [] médiacor = new int [3] [escalar*escalar];
  13. for(int mi=0; mi!=médiacor.length; mi++){
  14. for(int mj=j; mj==j; mj++){
  15. médiacor[0][mj]=img.getColor(i,j).getR();
  16. médiacor[1][mj]=img.getColor(i,j).getG();
  17. médiacor[2][mj]=img.getColor(i,j).getB();
  18. R+=médiacor[0][mj];
  19. G+=médiacor[1][mj];
  20. B+=médiacor[2][mj];
  21. }
  22. }
  23. R=(int)(R/(escalar*escalar));
  24. G=(int)(G/(escalar*escalar));
  25. B=(int)(B/(escalar*escalar));
  26. Color média = new Color (R,G,B);
  27. imgreduzida.setColor(i,j,média);
  28. }
  29. }
  30. return imgreduzida;
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement