Advertisement
junbjn98

Untitled

Oct 4th, 2017
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. image = new SimpleImage("flowers.jpg");
  2. width = image.getWidth();
  3. height = image.getHeight();
  4. // Tăng vòng lặp lên để tăng độ nhiễu
  5. for (i = 0; i < 10000; i++) {
  6. x = Math.floor(Math.random() * (width - 1));
  7. y = Math.floor(Math.random() * (height - 1));
  8. pixel = image.getPixel(x, y);
  9. pixel.setRed(255);
  10. pixel.setGreen(255);
  11. pixel.setBlue(255);
  12. }
  13.  
  14. for (i = 0; i < 10000; i++) {
  15. x = Math.floor(Math.random() * (width - 1));
  16. y = Math.floor(Math.random() * (height - 1));
  17. pixel = image.getPixel(x, y);
  18. pixel.setRed(255);
  19. pixel.setGreen(0);
  20. pixel.setBlue(0);
  21. }
  22.  
  23. for (i = 0; i < 10000; i++) {
  24. x = Math.floor(Math.random() * (width - 1));
  25. y = Math.floor(Math.random() * (height - 1));
  26. pixel = image.getPixel(x, y);
  27. pixel.setRed(0);
  28. pixel.setGreen(0);
  29. pixel.setBlue(255);
  30. }
  31. print(image);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement