Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void noise(int intensity){
- BufferedImage img = null;
- File f = null;
- try{
- f = new File("C:\\Users\\komp1\\Desktop\\resources\\input\\0.jpg");
- img = ImageIO.read(f);
- }catch(IOException e){
- System.out.println(e);
- }
- int width = img.getWidth();
- int height = img.getHeight();
- Random rand = new Random();
- for(int y = 0; y < intensity ; y++){
- for(int x = 0; x < intensity; x++){
- img.setRGB(rand.nextInt(width), rand.nextInt(height), 0);
- }
- }
- try{
- f = new File("C:\\Users\\komp1\\Desktop\\resources\\noise\\0" + intensity+ ".jpg");
- ImageIO.write(img, "jpg", f);
- }catch(IOException e){
- System.out.println(e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement