Here you can find the source of rgbToBlackWhite(int pix, int threshold)
public final static boolean rgbToBlackWhite(int pix, int threshold)
//package com.java2s; //License from project: Apache License public class Main { public final static boolean rgbToBlackWhite(int pix, int threshold) { final int r = (pix >> 16) & 0xff; final int g = (pix >> 8) & 0xff; final int b = (pix >> 0) & 0xff; final int intensity = ((r * 306) + (g * 601) + (b * 117)) >> 10; return (intensity > threshold); // true == white == fg }//from w ww. j a v a2s . co m }