-
Notifications
You must be signed in to change notification settings - Fork 0
/
parm5.c
50 lines (38 loc) · 920 Bytes
/
parm5.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
class parm5
{
static void func1()throws Exception
{
BufferedImage image,image2;
int width;
int height;
File input = new File("generated_image1.jpg");
image = ImageIO.read(input);
width = image.getWidth();
height = image.getHeight();
int i,j;
int red,green,blue;
for(i=0; i<height; i++)
{
for(j=0; j<width; j++)
{
Color c = new Color(image.getRGB(j, i));
red=(int)(c.getRed() * 0.299);
green=(int)(c.getGreen() * 0.587);
blue=(int)(c.getBlue() *0.114);
Color newColor = new Color(red+green+blue,red+green+blue,red+green+blue);
image.setRGB(j,i,newColor.getRGB());
}
}
File ouptut = new File("generated_image1.jpg");
ImageIO.write(image, "jpg", ouptut);
}
public static void main(String args[]) throws Exception
{
func1();
}
}