Java RGB Color Convert To rgbToBlackWhite(int pix, int threshold)

Here you can find the source of rgbToBlackWhite(int pix, int threshold)

Description

rgb To Black White

License

Apache License

Declaration

public final static boolean rgbToBlackWhite(int pix, int threshold) 

Method Source Code

//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
}

Related

  1. rgbaToHex(String color)
  2. RGBAtoI(byte r, byte g, byte b, byte a)
  3. rgbBitfieldToString(int rgb)
  4. rgbToBgr(final byte[] pixels)
  5. RGBtoBGR(String color)
  6. rgbToColor(int r, int g, int b)
  7. rgbToDecimal(int r, int g, int b)
  8. rgbToGray(int colorIn)
  9. rgbToGray(int pixels)