Saturday, June 7, 2014

Cara Mendapakan Nilai Pixel Gambar

  1 comment
private File file;
BufferedImage gambarAsli;

public GetPixelColor() {
  try {
    this.gambarAsli = ImageIO.read(new File("src/image/strawberry.jpg"));
        } catch (IOException ex) {
            Logger.getLogger(GetPixelColor.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
    //ambil nilai pixel (warna)
    public int v(int x, int y) {
        int rgb = gambarAsli.getRGB(x, y);
        int red = rgb & 0x000000FF;
        int green = (rgb & 0x0000FF00) >> 8;
        int blue = (rgb & 0x00FF0000) >> 16;
        return (red + green + blue) / 3;

    }

1 comment :

Bandi said...

Really Bandi Artikel Teknologi  Teknologi Informasi your post is really very good and I appreciate it.