0

I am new in python n java. I've given the task at my class for showing pixel array image from an image. Please help me?? Thanks

1
  • I mean the RGB value each pixel of an image. Commented Mar 25, 2011 at 23:08

3 Answers 3

1

Are you trying to get a 2D array if each pixel color? In the Java BufferedImage class, there is the method:

getRGB(int x, int y)

Therefore, you could just loop through each pixel and add it to your array, like this:

int[][] array = new int[img.getWidth()][img.getHeight()];
for (int i = 0; i < img.getWidth(); i++) {
   for (int j = 0; i < img.getHeight(); j++) {
      array[i][j] = img.getRGB(i, j);
   }
}

This will give you a 2D array of the RGB value of each pixel.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks very much. it's really I am need for doing my homework.. :D
0

You might study this Java example that uses the graphics context's drawImage() to enlarge an image and report the color of each pixel.

Comments

0

You might want to look in to the Python Image Library (PIL), I recommend it.

2 Comments

where can i download PIL for python 3? I never found it
I don't think they support it yet

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.