Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. public static void noise(int intensity){
  2. BufferedImage img = null;
  3. File f = null;
  4. try{
  5. f = new File("C:\\Users\\komp1\\Desktop\\resources\\input\\0.jpg");
  6. img = ImageIO.read(f);
  7. }catch(IOException e){
  8. System.out.println(e);
  9. }
  10. int width = img.getWidth();
  11. int height = img.getHeight();
  12. Random rand = new Random();
  13. for(int y = 0; y < intensity ; y++){
  14. for(int x = 0; x < intensity; x++){
  15.  
  16. img.setRGB(rand.nextInt(width), rand.nextInt(height), 0);
  17. }
  18. }
  19. try{
  20. f = new File("C:\\Users\\komp1\\Desktop\\resources\\noise\\0" + intensity+ ".jpg");
  21. ImageIO.write(img, "jpg", f);
  22. }catch(IOException e){
  23. System.out.println(e);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement