|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectloci.formats.ImageTools
public final class ImageTools
A utility class with convenience methods for manipulating images. Much code was stolen and adapted from DrLaszloJamf's posts at: http://forum.java.sun.com/thread.jspa?threadID=522483
Field Summary | |
---|---|
protected static Component |
OBS
ImageObserver for working with AWT images. |
Method Summary | |
---|---|
static BufferedImage |
autoscale(BufferedImage img,
int min,
int max)
Perform autoscaling on the given BufferedImage; map min to 0 and max to 255. |
static byte[] |
autoscale(byte[] b,
int min,
int max,
int bpp,
boolean little)
Perform autoscaling on the given byte array; map min to 0 and max to 255. |
static BufferedImage |
blankImage(int w,
int h,
int c,
int type)
Creates a blank image with the given dimensions and transfer type. |
static BufferedImage |
copyScaled(BufferedImage source,
BufferedImage target,
Object hint)
Copies the source image into the target, applying scaling. |
static short[][] |
demosaic(short[][] input,
int w,
int h)
Perform demosaicing on a byte array, assuming a {B, G, G, R} mosaic. |
static byte[][] |
getBytes(BufferedImage image)
Extracts pixel data as arrays of unsigned bytes, one per channel. |
static byte[] |
getBytes(BufferedImage img,
boolean separated,
int c)
Get the bytes from an image, merging the channels as necessary. |
static GraphicsConfiguration |
getDefaultConfiguration()
Gets the default graphics configuration for the environment. |
static double[][] |
getDoubles(BufferedImage image)
Extracts pixel data as arrays of doubles, one per channel. |
static float[][] |
getFloats(BufferedImage image)
Extracts pixel data as arrays of floats, one per channel. |
static int[][] |
getInts(BufferedImage image)
Extracts pixel data as arrays of signed integers, one per channel. |
static byte[][] |
getPixelBytes(BufferedImage img,
boolean little)
Return a 2D array of bytes representing the image. |
static Object |
getPixels(BufferedImage image)
Gets the image's pixel data as arrays of primitives, one per channel. |
static int |
getPixelType(BufferedImage image)
Gets the pixel type of the given image. |
static short[][] |
getShorts(BufferedImage image)
Extracts pixel data as arrays of unsigned shorts, one per channel. |
static Dimension |
getSize(Image image)
Gets the width and height of the given AWT image, waiting for it to finish loading if necessary. |
static BufferedImage |
indexedToRGB(BufferedImage img,
boolean le)
Converts an indexed color BufferedImage to an RGB BufferedImage. |
static byte[][] |
indexedToRGB(byte[][] lut,
byte[] b)
Converts a LUT and an array of indices into an array of RGB tuples. |
static short[][] |
indexedToRGB(short[][] lut,
byte[] b,
boolean le)
Converts a LUT and an array of indices into an array of RGB tuples. |
static boolean |
loadImage(Image image)
Ensures the given AWT image is fully loaded. |
static int[] |
make24Bits(Object pixels,
int w,
int h,
boolean interleaved)
Convert an arbitrary primitive type array with 3 samples per pixel to an int array, i.e. |
static byte[][] |
make24Bits(Object pixels,
int w,
int h,
boolean interleaved,
boolean reverse)
Convert an arbitrary primitive type array with 3 samples per pixel to a 3 x (width * height) byte array. |
static BufferedImage |
makeBuffered(Image image)
Creates a buffered image from the given AWT image object. |
static BufferedImage |
makeBuffered(Image image,
ColorModel cm)
Creates a buffered image possessing the given color model, from the specified AWT image object. |
static ColorModel |
makeColorModel(int c,
int dataType)
Gets a color space for the given number of color components. |
static BufferedImage |
makeCompatible(BufferedImage image,
GraphicsConfiguration gc)
Creates a buffered image compatible with the given graphics configuration, using the given buffered image as a source. |
static BufferedImage |
makeImage(byte[][] data,
int w,
int h)
Creates an image from the given unsigned byte data. |
static BufferedImage |
makeImage(byte[][] data,
int w,
int h,
int bpp,
boolean little)
Creates an image from the given data, performing type conversions as necessary. |
static BufferedImage |
makeImage(byte[][] data,
int w,
int h,
int bpp,
boolean fp,
boolean little)
Creates an image from the given data, performing type conversions as necessary. |
static BufferedImage |
makeImage(byte[] data,
int w,
int h)
Creates an image from the given single-channel unsigned byte data. |
static BufferedImage |
makeImage(byte[] data,
int w,
int h,
int c,
boolean interleaved)
Creates an image from the given unsigned byte data. |
static BufferedImage |
makeImage(byte[] data,
int w,
int h,
int c,
boolean interleaved,
int bpp,
boolean little)
Creates an image from the given data, performing type conversions as necessary. |
static BufferedImage |
makeImage(byte[] data,
int w,
int h,
int c,
boolean interleaved,
int bpp,
boolean fp,
boolean little)
Creates an image from the given data, performing type conversions as necessary. |
static BufferedImage |
makeImage(double[][] data,
int w,
int h)
Creates an image from the given double-precision floating point data. |
static BufferedImage |
makeImage(double[] data,
int w,
int h)
Creates an image from the given single-channel double data. |
static BufferedImage |
makeImage(double[] data,
int w,
int h,
int c,
boolean interleaved)
Creates an image from the given double data. |
static BufferedImage |
makeImage(float[][] data,
int w,
int h)
Creates an image from the given single-precision floating point data. |
static BufferedImage |
makeImage(float[] data,
int w,
int h)
Creates an image from the given single-channel float data. |
static BufferedImage |
makeImage(float[] data,
int w,
int h,
int c,
boolean interleaved)
Creates an image from the given float data. |
static BufferedImage |
makeImage(int[][] data,
int w,
int h)
Creates an image from the given signed int data. |
static BufferedImage |
makeImage(int[] data,
int w,
int h)
Creates an image from the given single-channel signed int data. |
static BufferedImage |
makeImage(int[] data,
int w,
int h,
int c,
boolean interleaved)
Creates an image from the given signed int data. |
static BufferedImage |
makeImage(short[][] data,
int w,
int h)
Creates an image from the given unsigned short data. |
static BufferedImage |
makeImage(short[] data,
int w,
int h)
Creates an image from the given single-channel unsigned short data. |
static BufferedImage |
makeImage(short[] data,
int w,
int h,
int c,
boolean interleaved)
Creates an image from the given unsigned short data. |
static BufferedImage |
mergeChannels(BufferedImage[] images)
Merges the given images into a single multi-channel image. |
static BufferedImage |
padImage(BufferedImage img,
int width,
int height)
Pads (or crops) the image to the given width and height. |
static byte[] |
padImage(byte[] b,
boolean interleaved,
int c,
int oldWidth,
int width,
int height)
Pads (or crops) the byte array to the given width and height. |
static double[] |
padImage(double[] b,
boolean interleaved,
int c,
int oldWidth,
int width,
int height)
Pads (or crops) the double array to the given width and height. |
static float[] |
padImage(float[] b,
boolean interleaved,
int c,
int oldWidth,
int width,
int height)
Pads (or crops) the float array to the given width and height. |
static int[] |
padImage(int[] b,
boolean interleaved,
int c,
int oldWidth,
int width,
int height)
Pads (or crops) the int array to the given width and height. |
static short[] |
padImage(short[] b,
boolean interleaved,
int c,
int oldWidth,
int width,
int height)
Pads (or crops) the short array to the given width and height. |
static BufferedImage |
scale(BufferedImage source,
int width,
int height,
boolean pad)
Scales the image using the most appropriate API, with the resultant image having the same color model as the original image. |
static BufferedImage |
scale2D(BufferedImage image,
int width,
int height,
Object hint,
ColorModel cm)
Scales the image using the Java2D API, with the resultant image having the given color model. |
static BufferedImage |
scale2D(BufferedImage image,
int width,
int height,
Object hint,
GraphicsConfiguration gc)
Scales the image using the Java2D API, with the resultant image optimized for the given graphics configuration. |
static Image |
scaleAWT(BufferedImage source,
int width,
int height,
int hint)
Scales the image using the AWT Image API. |
static Double[] |
scanData(byte[] plane,
int bits,
boolean littleEndian)
Scan a plane for the channel min and max values. |
static BufferedImage[] |
splitChannels(BufferedImage image)
Splits the given multi-channel image into single-channel images. |
static byte[][] |
splitChannels(byte[] array,
int c,
int bytes,
boolean reverse,
boolean interleaved)
Splits the given multi-channel array into a 2D array. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Component OBS
Method Detail |
---|
public static BufferedImage makeImage(byte[] data, int w, int h)
data
- Array containing image data.w
- Width of image plane.h
- Height of image plane.public static BufferedImage makeImage(short[] data, int w, int h)
data
- Array containing image data.w
- Width of image plane.h
- Height of image plane.public static BufferedImage makeImage(int[] data, int w, int h)
data
- Array containing image data.w
- Width of image plane.h
- Height of image plane.public static BufferedImage makeImage(float[] data, int w, int h)
data
- Array containing image data.w
- Width of image plane.h
- Height of image plane.public static BufferedImage makeImage(double[] data, int w, int h)
data
- Array containing image data.w
- Width of image plane.h
- Height of image plane.public static BufferedImage makeImage(byte[] data, int w, int h, int c, boolean interleaved)
data
- Array containing image data.w
- Width of image plane.h
- Height of image plane.c
- Number of channels.interleaved
- If set, the channels are assumed to be interleaved;
otherwise they are assumed to be sequential.
For example, for RGB data, the pattern "RGBRGBRGB..." is interleaved,
while "RRR...GGG...BBB..." is sequential.public static BufferedImage makeImage(short[] data, int w, int h, int c, boolean interleaved)
data
- Array containing image data.w
- Width of image plane.h
- Height of image plane.c
- Number of channels.interleaved
- If set, the channels are assumed to be interleaved;
otherwise they are assumed to be sequential.
For example, for RGB data, the pattern "RGBRGBRGB..." is interleaved,
while "RRR...GGG...BBB..." is sequential.public static BufferedImage makeImage(int[] data, int w, int h, int c, boolean interleaved)
data
- Array containing image data.w
- Width of image plane.h
- Height of image plane.c
- Number of channels.interleaved
- If set, the channels are assumed to be interleaved;
otherwise they are assumed to be sequential.
For example, for RGB data, the pattern "RGBRGBRGB..." is interleaved,
while "RRR...GGG...BBB..." is sequential.public static BufferedImage makeImage(float[] data, int w, int h, int c, boolean interleaved)
data
- Array containing image data.w
- Width of image plane.h
- Height of image plane.c
- Number of channels.interleaved
- If set, the channels are assumed to be interleaved;
otherwise they are assumed to be sequential.
For example, for RGB data, the pattern "RGBRGBRGB..." is interleaved,
while "RRR...GGG...BBB..." is sequential.public static BufferedImage makeImage(double[] data, int w, int h, int c, boolean interleaved)
data
- Array containing image data.w
- Width of image plane.h
- Height of image plane.c
- Number of channels.interleaved
- If set, the channels are assumed to be interleaved;
otherwise they are assumed to be sequential.
For example, for RGB data, the pattern "RGBRGBRGB..." is interleaved,
while "RRR...GGG...BBB..." is sequential.public static BufferedImage makeImage(byte[][] data, int w, int h)
data
- Array containing image data.
It is assumed that each channel corresponds to one element of the array.
For example, for RGB data, data[0] is R, data[1] is G, and data[2] is B.w
- Width of image plane.h
- Height of image plane.public static BufferedImage makeImage(short[][] data, int w, int h)
data
- Array containing image data.
It is assumed that each channel corresponds to one element of the array.
For example, for RGB data, data[0] is R, data[1] is G, and data[2] is B.w
- Width of image plane.h
- Height of image plane.public static BufferedImage makeImage(int[][] data, int w, int h)
data
- Array containing image data.
It is assumed that each channel corresponds to one element of the array.
For example, for RGB data, data[0] is R, data[1] is G, and data[2] is B.w
- Width of image plane.h
- Height of image plane.public static BufferedImage makeImage(float[][] data, int w, int h)
data
- Array containing image data.
It is assumed that each channel corresponds to one element of the array.
For example, for RGB data, data[0] is R, data[1] is G, and data[2] is B.w
- Width of image plane.h
- Height of image plane.public static BufferedImage makeImage(double[][] data, int w, int h)
data
- Array containing image data.
It is assumed that each channel corresponds to one element of the array.
For example, for RGB data, data[0] is R, data[1] is G, and data[2] is B.w
- Width of image plane.h
- Height of image plane.public static BufferedImage makeImage(byte[] data, int w, int h, int c, boolean interleaved, int bpp, boolean little)
data
- Array containing image data.w
- Width of image plane.h
- Height of image plane.c
- Number of channels.interleaved
- If set, the channels are assumed to be interleaved;
otherwise they are assumed to be sequential.
For example, for RGB data, the pattern "RGBRGBRGB..." is interleaved,
while "RRR...GGG...BBB..." is sequential.bpp
- Denotes the number of bytes in the returned primitive type
(e.g. if bpp == 2, we should return an array of type short).little
- Whether byte array is in little-endian order.public static BufferedImage makeImage(byte[] data, int w, int h, int c, boolean interleaved, int bpp, boolean fp, boolean little)
data
- Array containing image data.w
- Width of image plane.h
- Height of image plane.c
- Number of channels.interleaved
- If set, the channels are assumed to be interleaved;
otherwise they are assumed to be sequential.
For example, for RGB data, the pattern "RGBRGBRGB..." is interleaved,
while "RRR...GGG...BBB..." is sequential.bpp
- Denotes the number of bytes in the returned primitive type
(e.g. if bpp == 2, we should return an array of type short).fp
- If set and bpp == 4 or bpp == 8, then return floats or doubles.little
- Whether byte array is in little-endian order.public static BufferedImage makeImage(byte[][] data, int w, int h, int bpp, boolean little)
data
- Array containing image data, one channel per element.w
- Width of image plane.h
- Height of image plane.bpp
- Denotes the number of bytes in the returned primitive type
(e.g. if bpp == 2, we should return an array of type short).little
- Whether byte array is in little-endian order.public static BufferedImage makeImage(byte[][] data, int w, int h, int bpp, boolean fp, boolean little)
data
- Array containing image data, one channel per element.w
- Width of image plane.h
- Height of image plane.bpp
- Denotes the number of bytes in the returned primitive type
(e.g. if bpp == 2, we should return an array of type short).fp
- If set and bpp == 4 or bpp == 8, then return floats or doubles.little
- Whether byte array is in little-endian order.public static BufferedImage blankImage(int w, int h, int c, int type)
w
- Width of image plane.h
- Height of image plane.c
- Number of channels.type
- One of the following types:public static Object getPixels(BufferedImage image)
public static byte[][] getBytes(BufferedImage image)
public static short[][] getShorts(BufferedImage image)
public static int[][] getInts(BufferedImage image)
public static float[][] getFloats(BufferedImage image)
public static double[][] getDoubles(BufferedImage image)
public static byte[][] getPixelBytes(BufferedImage img, boolean little)
public static int getPixelType(BufferedImage image)
public static byte[] getBytes(BufferedImage img, boolean separated, int c)
public static byte[][] make24Bits(Object pixels, int w, int h, boolean interleaved, boolean reverse)
public static int[] make24Bits(Object pixels, int w, int h, boolean interleaved)
public static byte[][] splitChannels(byte[] array, int c, int bytes, boolean reverse, boolean interleaved)
public static BufferedImage[] splitChannels(BufferedImage image)
public static BufferedImage mergeChannels(BufferedImage[] images)
public static BufferedImage padImage(BufferedImage img, int width, int height)
public static byte[] padImage(byte[] b, boolean interleaved, int c, int oldWidth, int width, int height)
public static short[] padImage(short[] b, boolean interleaved, int c, int oldWidth, int width, int height)
public static int[] padImage(int[] b, boolean interleaved, int c, int oldWidth, int width, int height)
public static float[] padImage(float[] b, boolean interleaved, int c, int oldWidth, int width, int height)
public static double[] padImage(double[] b, boolean interleaved, int c, int oldWidth, int width, int height)
public static short[][] demosaic(short[][] input, int w, int h)
public static BufferedImage autoscale(BufferedImage img, int min, int max)
public static byte[] autoscale(byte[] b, int min, int max, int bpp, boolean little)
public static Double[] scanData(byte[] plane, int bits, boolean littleEndian)
public static BufferedImage copyScaled(BufferedImage source, BufferedImage target, Object hint)
public static BufferedImage scale2D(BufferedImage image, int width, int height, Object hint, GraphicsConfiguration gc)
public static BufferedImage scale2D(BufferedImage image, int width, int height, Object hint, ColorModel cm)
public static Image scaleAWT(BufferedImage source, int width, int height, int hint)
public static BufferedImage scale(BufferedImage source, int width, int height, boolean pad)
public static BufferedImage makeBuffered(Image image)
public static BufferedImage makeBuffered(Image image, ColorModel cm)
public static boolean loadImage(Image image)
public static Dimension getSize(Image image)
public static BufferedImage makeCompatible(BufferedImage image, GraphicsConfiguration gc)
public static GraphicsConfiguration getDefaultConfiguration()
public static ColorModel makeColorModel(int c, int dataType)
public static BufferedImage indexedToRGB(BufferedImage img, boolean le)
public static byte[][] indexedToRGB(byte[][] lut, byte[] b)
public static short[][] indexedToRGB(short[][] lut, byte[] b, boolean le)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |