I just started image processing and was given an assignment to basically make the top quarter of a picture with a sunset effect, the lower quarter should be lightened, the quarter lower than that in grayscale, and the bottom quarter needs to be negative.
I think the easy part was getting the first class which i called ImageUtility. This class includes all the code needed to do all the actual changes to the picture. I have compiled this class and have no errors. Here is my code for this class.
CODE
import java.awt.*;
public class ImageUtility
{
public static void sunset(Picture pic, int a, int b)
{
Pixel[] pixelArray = pic.getPixels();
Pixel pixs = null;
int value = 0;
int i = 0;
while (i < pixelArray.length)
{
pixs = pixelArray[i];
value = pixs.getBlue();
pixs.setBlue((int) (value * 0.7));
value = pixs.getGreen();
pixs.setGreen((int) (value * 0.7));
i++;
}
}
public static void lightening(Picture pic, int a, int b)
{
Pixel[] pixelArray = pic.getPixels();
Color col = null;
Pixel pixs = null;
for (int i = 0; i < pixelArray.length; i++)
{
pixs = pixelArray[i];
col = pixs.getColor();
col = col.brighter();
pixs.setColor(col);
}
}
public static void grayscale(Picture pic, int a, int b)
{
Pixel[] pixelArray = pic.getPixels();
Pixel pixs = null;
int amount = 0;
for (int i = 0; i < pixelArray.length; i++)
{
pixs = pixelArray[i];
amount = (int) ((pixs.getRed() + pixs.getGreen() + pixs.getBlue()) / 3);
pixs.setColor(new Color(amount, amount, amount));
}
}
public static void negativeImg(Picture pic, int a, int b)
{
Pixel[] pixelArray = pic.getPixels();
Pixel pixs = null;
int redValue, blueValue, greenValue = 0;
for (int i = 0; i < pixelArray.length; i++)
{
pixs = pixelArray[i];
redValue = pixs.getRed();
greenValue = pixs.getGreen();
blueValue = pixs.getBlue();
pixs.setColor (new Color(255 - redValue, 255 - greenValue, 255 - blueValue));
}
}
}
The part where I'm having trouble is actually implementing the code. I made a class called MultiTrans and have made it so that the user could choose any file they want. In order to brake the picture up into quarters I knew i would have to define the height and width as integers so I did that. This is where I get confused, in the template for my first class my teacher made it so that there would be three objects to use, (picture pic, int a, int

. I have no idea what he want me to input for the objects. Also I'm not sure on how where I should put all of my code.
Here is what I have when I try to implement the sunset effect on an image.
CODE
public class MultiTrans
{
public static void main(String[] args)
{
String filename = FileChooser.pickAFile();
System.out.println(filename);//so the user can choose any picture they want and it will be displayed
Picture pic = new Picture(filename);
int Height = pic.getHeight();
int Width = pic.getWidth();
int c = 0;//first pixel in the picture
int d = ((height/4-1)*(width)+(width-1));//this should be the last picture in order to just capture the top quarter of the picture
for (int a = 0; a<= d; a++)
{
ImageUtility.sunset(pic, 0, int d);
}
}
pic.show();
}
^right now the error message im getting is at this line
CODE
ImageUtility.sunset(pic, 0, int d);
and it is saying that '.class' expected, which i dont understand because I thought .sunset would be that class. If anyone could help me that'd be great.