I have a rgb image and i want to convert binary image 0-255.
I calculate threshold in rgb image and pixel which in gray level image bigger than threshold, i set red = 255 green=255 and blue=255 and lower than threshold i set red = 0 green=0 and blue=0
private static int colorToRGB(int alpha, int red, int green, int blue) { int newPixel = 0; newPixel += alpha; newPixel = newPixel << 8; newPixel += red; newPixel = newPixel << 8; newPixel += green; newPixel = newPixel << 8; newPixel += blue; System.out.println("asd" + newPixel); return newPixel; }
newPixel's value -16777216 if pixel is white newPixel's value -1 if pixel is black
alpha value is constant 255 Where am i wrong because i want to pixel's value 0 and 255.
BufferedImage type is TYPE_INT_ARGB
Thank you for helping