0

pls my eclipse galileo int r = GImage.getRed(pixel);
int g = GImage.getGreen(pixel);
int b = GImage.getBlue(pixel);

also
int [][] array = image.getPixelArray();

as an error like its not in the library...

anyone pls

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by akinfemi
0

This is not enough informtion for anyone to be able to help you. Please post the code where the error happens (in code tags) and the exact complete error message.

0
import acm.graphics.*;
import acm.program.*;

public class BlacknWhite extends GraphicsProgram {
    public void run(){
        GImage image = new GImage ("akinfemi.jpg");
        GImage grayImage = createGrayScaleImage(image);

        add(image, 10, 50);
        add(grayImage, 100, 50);
    }
    private GImage createGrayScaleImage(GImage image){
        int [][] array = image.getPixelArray();

        int height = array.length;
        int width = array[0].length;

        for (int i = 0; i < height; i++){
            for (int j = 0; j < width; j++ ){
                int pixel = array[i][j];

                int r = GImage.getRed(pixel);
                int g = GImage.getGreen(pixel);
                int b = GImage.getBlue(pixel);

                int xx = computeLuminosity(r, g, b);

                array[i][j] = GImage.createdRGBPixel(xx, xx, xx);
            }


        }
    return GImage(array);
    }
    private int computeLuminosity(int r, int g, int b){
        return Math.round(0.299*r + 0.587*g + 0.114*b );
    }
}

Edited by Reverend Jim: Fixed formatting

0

getPixelArray, getRed, getGreen, getBlue are all underlined as wrong codes

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.