Monday, February 2, 2015

Grayscale.java in program



Grayscale.java

import java.awt.Color;

public class Grayscale
{

    public static void main(String[] args)
{
        Picture pic = new Picture(args[0]);
        int width  = pic.width();
        int height = pic.height();

       
        for (int x = 0; x < width; x++)
{
            for (int y = 0; y < height; y++)
 {
                Color color = pic.get(x, y);
                Color gray = Luminance.toGray(color);
                pic.set(x, y, gray);
            }
        }
        pic.show();
    }

}

No comments:

Post a Comment