0

I am trying to implement Connected Component Labeling algorithm using java swing library.

First, my code reads any B/W image from computer. Then, it iterates through image pixels (x,y) and returns specified pixel color.

The new image will be drawn on a JPanel. using Graphics library.

The code to draw a pixel is: g.fillRect(x, y, width, height);

The problem is that I am willing to get background color of the JPanel that I am drawing on it in order to fully implement this algorithm.

gpasch
  • 2,672
  • 3
  • 10
  • 12
Abdulla Dlshad
  • 106
  • 1
  • 14
  • 3
    `getBackground()`? – dryairship Apr 16 '16 at 13:34
  • No, i use `getRGB()` for the image. but I do not know how should i get `JPanel` color – Abdulla Dlshad Apr 16 '16 at 13:36
  • get screenshot the panel and convert it to a image and use getRGB() to get color of any pixel that you want. And also you can check this http://stackoverflow.com/questions/22839618/how-to-get-pixel-color-from-graphics-g – ziLk Apr 16 '16 at 20:03

0 Answers0