Package loci.formats
Class ImageTools
java.lang.Object
loci.formats.ImageTools
A utility class with convenience methods for manipulating images
in primitive array form.
To work with images in
BufferedImage form,
use the AWTImageTools class.- Author:
- Curtis Rueden ctrueden at wisc.edu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 voidbgrToRgb(byte[] buf, boolean interleaved, int bpp, int c) static byte[]getSubimage(byte[] src, byte[] dest, int originalWidth, int originalHeight, int x, int y, int w, int h, int bpp, int channels, boolean interleaved) 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 byte[]interpolate(short[] s, byte[] buf, int[] bayerPattern, int width, int height, boolean littleEndian) 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 byte[][]make24Bits(Object pixels, int w, int h, boolean interleaved, boolean reverse, Double min, Double max) Convert an arbitrary primitive type array with 3 samples per pixel to a 3 x (width * height) byte array.static int[]make24Bits(Object pixels, int w, int h, boolean interleaved, Double min, Double max) Convert an arbitrary primitive type array with 3 samples per pixel to an int array, i.e.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 Double[]scanData(byte[] plane, int bits, boolean littleEndian) Scan a plane for the channel min and max values.static byte[]splitChannels(byte[] array, byte[] rtn, int index, int c, int bytes, boolean reverse, boolean interleaved, int channelLength) Splits the given multi-channel array into a 2D array.static byte[]splitChannels(byte[] array, int index, int c, int bytes, boolean reverse, boolean interleaved) Splits the given multi-channel array into a 2D array.
-
Constructor Details
-
ImageTools
private ImageTools()
-
-
Method Details
-
make24Bits
public 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. -
make24Bits
public static byte[][] make24Bits(Object pixels, int w, int h, boolean interleaved, boolean reverse, Double min, Double max) Convert an arbitrary primitive type array with 3 samples per pixel to a 3 x (width * height) byte array. Scaling is performed according to the specified minimum and maximum pixel values in the original image. If the minimum is null, it is assumed to be 0. If the maximum is null, it is assumed to be 2^nbits - 1. -
make24Bits
Convert an arbitrary primitive type array with 3 samples per pixel to an int array, i.e. RGB color with 8 bits per pixel. -
make24Bits
public static int[] make24Bits(Object pixels, int w, int h, boolean interleaved, Double min, Double max) Convert an arbitrary primitive type array with 3 samples per pixel to an int array, i.e. RGB color with 8 bits per pixel. Scaling is performed according to the specified minimum and maximum pixel values in the original image. If the minimum is null, it is assumed to be 0. If the maximum is null, it is assumed to be 2^nbits - 1. -
splitChannels
public static byte[] splitChannels(byte[] array, int index, int c, int bytes, boolean reverse, boolean interleaved) Splits the given multi-channel array into a 2D array. The "reverse" parameter is false if channels are in RGB order, true if channels are in BGR order. -
splitChannels
public static byte[] splitChannels(byte[] array, byte[] rtn, int index, int c, int bytes, boolean reverse, boolean interleaved, int channelLength) Splits the given multi-channel array into a 2D array. The "reverse" parameter is false if channels are in RGB order, true if channels are in BGR order. If the 'rtn' parameter is not null, the specified channel will be copied into 'rtn'. The 'channelLength' parameter specifies the number of bytes that are expected to be in a single channel. In many cases, this will match the value of 'rtn.length', but specifying it separately allows 'rtn' to be larger than the size of a single channel. -
padImage
public 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. The image will be centered within the new bounds. -
padImage
public 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. The image will be centered within the new bounds. -
padImage
public 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. The image will be centered within the new bounds. -
padImage
public 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. The image will be centered within the new bounds. -
padImage
public 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. The image will be centered within the new bounds. -
autoscale
public 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. If the number of bytes per pixel is 1, then nothing happens. -
scanData
Scan a plane for the channel min and max values. -
getSubimage
public static byte[] getSubimage(byte[] src, byte[] dest, int originalWidth, int originalHeight, int x, int y, int w, int h, int bpp, int channels, boolean interleaved) -
indexedToRGB
public static byte[][] indexedToRGB(byte[][] lut, byte[] b) Converts a LUT and an array of indices into an array of RGB tuples. -
indexedToRGB
public static short[][] indexedToRGB(short[][] lut, byte[] b, boolean le) Converts a LUT and an array of indices into an array of RGB tuples. -
interpolate
public static byte[] interpolate(short[] s, byte[] buf, int[] bayerPattern, int width, int height, boolean littleEndian) -
bgrToRgb
public static void bgrToRgb(byte[] buf, boolean interleaved, int bpp, int c)
-