Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csteutils.*;
- import csteutils.myro.*;
- import java.awt.Color;
- import java.lang.Math;
- class Main
- {
- public static void main(String[] args)
- {
- String image = "images/400x4002.jpeg";
- int height = 400;
- int width = 400;
- MyroColorImage originalImage = new MyroColorImage();
- originalImage.loadImage(image);
- originalImage.resize(width, height);
- originalImage.show();
- MyroColorImage newImage = new MyroColorImage();
- newImage.resize(width,height);
- for (int y = 0; y < height; y++)
- {
- for(int x = 0; x < width; x++)
- {
- Color c = originalImage.getPixel(x,y).getColor();
- int red = c.getRed();
- int green = c.getGreen();
- int blue = c.getBlue();
- red = (int) Math.min(255, (red * .393) + (green * .769) + (blue * .189));
- green = (int) Math.min(255, (red * .349) + (green *.686) + (blue * .168));
- blue = (int) Math.min(255, (red * .272) + (green *.534) + (blue * .131));
- newImage.getPixel(x,y).setColor(new Color(red, green, blue)); }
- }
- newImage.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment