Count white Pixel from binary image

-4

I've written a convert Grayscale to binary code like this.

    for(int x = 0; x < width; ++x) {
        for(int y = 0; y < height; ++y) {
            // get one pixel color
            int pixel = bmpOriginal.getPixel(x, y);
            int red = Color.red(pixel);
            int green = Color.green(pixel);
            int blue = Color.blue(pixel);
            int gray = (int)(red * 0.3 + green * 0.59 + blue * 0.11);

            //get binary value
            if(gray < threshold){
                bmpBinary.setPixel(x, y, 0xFF000000);
            } else{
                bmpBinary.setPixel(x, y, 0xFFFFFFFF);
            }
        }
    }
    return bmpBinary;

How can I count white pixel in binary image that I've already converted from Gray scale?

java
asked on Stack Overflow Feb 14, 2020 by Nawapan Duangrak • edited Feb 14, 2020 by QBrute

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0