Java tutorial
//package com.java2s; public class Main { /** * * @param r * @param g * @param b * @return */ public static int rgb2gray(int r, int g, int b) { return (int) Math.round(0.299 * r + 0.587 * g + 0.114 * b); } }