Java BufferedImage Operation binary(BufferedImage src)

Here you can find the source of binary(BufferedImage src)

Description

binary

License

Apache License

Declaration

public static final BufferedImage binary(BufferedImage src) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.image.BufferedImage;

import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

public class Main {

    public static final BufferedImage binary(BufferedImage src) {
        int width = src.getWidth();
        int height = src.getHeight();

        BufferedImage grayImage = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_BINARY);
        for (int i = 0; i < width; i++) {
            for (int j = 0; j < height; j++) {
                int rgb = src.getRGB(i, j);
                grayImage.setRGB(i, j, rgb);
            }/*www. ja  va2  s  .  co m*/
        }
        return grayImage;
    }

    public static final BufferedImage binary(File f) throws IOException {
        BufferedImage src = ImageIO.read(f);
        return binary(src);
    }
}

Related

  1. applyShadow(BufferedImage image)
  2. areBufferedImagesEqual(BufferedImage img1, BufferedImage img2)
  3. autoPanImage(BufferedImage img, Color bgcolor)
  4. binarize(BufferedImage image)
  5. binarize(BufferedImage original)
  6. blackAndWhiteCleaning(BufferedImage image)
  7. boostBufferedImagePerformance(BufferedImage image, boolean translucent)
  8. buildColorStatisticsOfImage(BufferedImage image)
  9. buildingCoordinatesInImage(BufferedImage imageSection)