A global thresholding technique is one which makes use of a single threshold value for the whole image, whereas local thresholding technique makes use of unique threshold values for the partitioned subimages obtained from the whole image. 1

ImageJ Auto Threshold plugin is an open source Java implementation that brings us seventeen global thresholding methods for processing and analyzing scientific images, converting them to black and white.

To use them in your project, you will need the histogram of your BufferedImage bufferedImage object, an array with 256 positions (one for each 8 bits color) with the counting of the color occurrence on the original image. 2

byte[] pixels = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData();

int[] histogram = new int[256];
for (int y = 0; y < (bufferedImage.getHeight()); y++) {
    int i = y * bufferedImage.getWidth();
    for (int x = 0; x < (bufferedImage.getWidth()); x++) {
        int v = pixels[i++] & 0xff;
        histogram[v]++;
    }
}

Copy the Auto Threshold method of your choice from https://github.com/fiji/Auto_Threshold/blob/master/src/main/java/fiji/threshold/Auto_Threshold.java to your project and pass your histogram as a parameter.

int threshold = IJDefault(histogram);

Once you run the method, it will return a threshold value, which you can use on your BufferedImage bufferedImage object, to decide which value is white and which is black.

for (int y = 0; y < bufferedImage.getHeight(); y++) {
    for (int x = 0; x < bufferedImage.getWidth(); x++) {
        int i = y * bufferedImage.getWidth() + x;
        if ((pixels[i] & 0xff) > threshold)
            bufferedImage.setRGB(x, y, Color.WHITE.getRGB());
        else
            bufferedImage.setRGB(x, y, Color.BLACK.getRGB());
    }
}

Now that your image has only white and black values, you can use a TYPE_BYTE_BINARY BufferedImage.

BufferedImage bwBufferedImage = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(), BufferedImage.TYPE_BYTE_BINARY);
Graphics2D graphics2D = bwBufferedImage.createGraphics();
graphics2D.drawImage(bim, 0, 0, bufferedImage.getWidth(), bufferedImage.getHeight(), null);
graphics2D.dispose();