List of utility methods to do BufferedImage to Gray Scale
BufferedImage | imageToGrayscale(BufferedImage image) image To Grayscale final BufferedImage grayscale; if (image.getType() == BufferedImage.TYPE_BYTE_BINARY) { return image; } else if (image.getType() == BufferedImage.TYPE_BYTE_GRAY) { grayscale = image; } else if (image.getType() == BufferedImage.TYPE_INT_RGB || image.getType() == BufferedImage.TYPE_BYTE_INDEXED) { grayscale = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_BYTE_GRAY); ... |
BufferedImage | imageToGrayscale(BufferedImage img) image To Grayscale colorConvert.filter(img, img);
return img;
|
BufferedImage | gray(BufferedImage src) gray int width = src.getWidth(); int height = src.getHeight(); BufferedImage grayImage = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY); 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); return grayImage; |
BufferedImage | grayImage(BufferedImage image) gray Image int width = image.getWidth(); int height = image.getHeight(); BufferedImage grayImage = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { int rgb = image.getRGB(i, j); grayImage.setRGB(i, j, rgb + 100); return grayImage; |
void | byteBufferToGrayBufferedImage(ByteBuffer buffer, BufferedImage bi) Converts depth values in ShortBuffer to a gray scale BufferedImage .
if (bi.getType() != BufferedImage.TYPE_USHORT_GRAY) throw new IllegalArgumentException( "Invalid image type. Expect image " + "type BufferedImage.TYPE_USHORT_GRAY."); int maxDepth = 1 << 16 - 1; short[] imageArray = ((DataBufferUShort) bi.getRaster().getDataBuffer()).getData(); buffer.rewind(); while (buffer.remaining() > 0) { int pos = buffer.position(); ... |