public class IcyBufferedImageUtil extends java.lang.Object
IcyBufferedImage
utilities class.Modifier and Type | Class and Description |
---|---|
static class |
IcyBufferedImageUtil.FilterType |
Constructor and Description |
---|
IcyBufferedImageUtil() |
Modifier and Type | Method and Description |
---|---|
static IcyBufferedImage |
addChannel(IcyBufferedImage source)
Add an empty channel to the specified image and return result as a new image.
|
static IcyBufferedImage |
addChannel(IcyBufferedImage source,
int index)
Add an empty channel to the specified image and return result as a new image.
|
static IcyBufferedImage |
addChannels(IcyBufferedImage source,
int index,
int num)
Add empty channel(s) to the specified image and return result as a new image.
|
static IcyBufferedImage |
convertToType(IcyBufferedImage source,
DataType dataType,
boolean rescale)
Convert the source image to the specified data type.
|
static IcyBufferedImage |
convertToType(IcyBufferedImage source,
DataType dataType,
boolean rescale,
boolean useDataBounds)
Convert the source image to the specified data type.
|
static IcyBufferedImage |
convertToType(IcyBufferedImage source,
DataType dataType,
Scaler scaler)
Deprecated.
Use
convertType(IcyBufferedImage, DataType, Scaler[]) instead. |
static IcyBufferedImage |
convertType(IcyBufferedImage source,
DataType dataType,
Scaler[] scalers)
Convert the source image to the specified data type.
|
static IcyBufferedImage |
downscaleBy2(IcyBufferedImage input,
boolean filter)
Returns a down scaled by a factor of 2 of the input image (X and Y resolution are divided by
2).
|
static IcyBufferedImage |
downscaleBy2(IcyBufferedImage input,
boolean filter,
IcyBufferedImage output)
Returns a down scaled by a factor of 2 of the input image (X and Y resolution are divided by
2).
|
static IcyBufferedImage |
downscaleBy2(IcyBufferedImage source,
boolean filter,
int level)
Down scale the specified image with the given down scale factor.
|
static java.lang.Object |
downscaleBy2(java.lang.Object input,
int sizeX,
int sizeY,
boolean signed,
boolean filter)
Returns a down scaled by a factor of 2 of the input image data (X and Y resolution are
divided by 2).
|
static java.lang.Object |
downscaleBy2(java.lang.Object input,
int sizeX,
int sizeY,
boolean signed,
boolean filter,
java.lang.Object output)
Returns a down scaled by a factor of 2 of the input image data (X and Y resolution are
divided by 2).
|
static IcyBufferedImage |
extractChannel(IcyBufferedImage source,
int channel)
Build a new single channel image (greyscale) from the specified source image channel.
|
static IcyBufferedImage |
extractChannels(IcyBufferedImage source,
int... channels)
Build a new image from the specified source image channels.
|
static IcyBufferedImage |
extractChannels(IcyBufferedImage source,
java.util.List<java.lang.Integer> channelNumbers)
Deprecated.
Use
extractChannels(IcyBufferedImage, int[]) instead. |
static java.awt.image.BufferedImage |
getARGBImage(IcyBufferedImage source)
Convert the current
IcyBufferedImage into a ARGB BufferedImage . |
static java.awt.image.BufferedImage |
getARGBImage(IcyBufferedImage source,
java.awt.image.BufferedImage dest)
Deprecated.
Use
toBufferedImage(IcyBufferedImage, BufferedImage) instead. |
static java.awt.image.BufferedImage |
getARGBImage(IcyBufferedImage source,
LUT lut)
Convert the current
IcyBufferedImage into a ARGB BufferedImage . |
static java.awt.image.BufferedImage |
getARGBImage(IcyBufferedImage source,
LUT lut,
java.awt.image.BufferedImage dest)
Deprecated.
|
static IcyBufferedImage |
getCopy(IcyBufferedImage source)
Create a copy of the specified image.
|
static IcyBufferedImage |
getSubImage(IcyBufferedImage source,
int x,
int y,
int w,
int h)
Creates a new image which is a sub part of the source image from the specified
coordinates and dimensions.
|
static IcyBufferedImage |
getSubImage(IcyBufferedImage source,
int x,
int y,
int c,
int sizeX,
int sizeY,
int sizeC)
Deprecated.
Use
getSubImage(IcyBufferedImage, Rectangle, int, int) instead. |
static IcyBufferedImage |
getSubImage(IcyBufferedImage source,
java.awt.Rectangle region)
Creates a new image which is a sub part of the source image from the specified region.
|
static IcyBufferedImage |
getSubImage(IcyBufferedImage source,
java.awt.Rectangle region,
int c,
int sizeC)
Creates a new image from the specified region of the source image.
|
static IcyBufferedImage |
rotate(IcyBufferedImage source,
double angle)
Return a rotated version of the source image with specified parameters.
|
static IcyBufferedImage |
rotate(IcyBufferedImage source,
double xOrigin,
double yOrigin,
double angle,
IcyBufferedImageUtil.FilterType filterType)
Return a rotated version of the source image with specified parameters.
|
static IcyBufferedImage |
rotate(IcyBufferedImage source,
double angle,
IcyBufferedImageUtil.FilterType filterType)
Return a rotated version of the source image with specified parameters.
|
static IcyBufferedImage |
scale(IcyBufferedImage source,
int width,
int height)
Return a copy of the image with specified size.
|
static IcyBufferedImage |
scale(IcyBufferedImage source,
int width,
int height,
boolean resizeContent,
int xAlign,
int yAlign)
Return a copy of the image with specified size.
|
static IcyBufferedImage |
scale(IcyBufferedImage source,
int width,
int height,
boolean resizeContent,
int xAlign,
int yAlign,
IcyBufferedImageUtil.FilterType filterType)
Return a copy of the source image with specified size, alignment rules and filter type.
|
static IcyBufferedImage |
scale(IcyBufferedImage source,
int width,
int height,
IcyBufferedImageUtil.FilterType filterType)
Return a copy of the image with specified size
|
static java.awt.image.BufferedImage |
toBufferedImage(IcyBufferedImage source,
java.awt.image.BufferedImage dest)
Draw the source
IcyBufferedImage into the destination BufferedImage If dest is null then a new TYPE_INT_ARGB BufferedImage is returned. |
static java.awt.image.BufferedImage |
toBufferedImage(IcyBufferedImage source,
java.awt.image.BufferedImage dest,
LUT lut)
Draw the source
IcyBufferedImage into the destination BufferedImage If dest is null then a new TYPE_INT_ARGB BufferedImage is
returned. |
static java.awt.image.BufferedImage |
toBufferedImage(IcyBufferedImage source,
int imageType)
Convert the current
IcyBufferedImage into a BufferedImage of the specified
type. |
static java.awt.image.BufferedImage |
toBufferedImage(IcyBufferedImage source,
int imageType,
LUT lut)
Convert the current
IcyBufferedImage into a BufferedImage of the specified
type. |
static IcyBufferedImage |
toIcyBufferedImage(java.awt.image.BufferedImage image)
Deprecated.
Use
IcyBufferedImage.createFrom(BufferedImage) instead. |
static IcyBufferedImage |
toIcyBufferedImage(java.util.List<java.awt.image.BufferedImage> images)
Deprecated.
Use
IcyBufferedImage.createFrom(List) instead. |
static void |
translate(IcyBufferedImage source,
int dx,
int dy)
Translate image internal data (all channels) by the specified (x,y) vector.
|
static void |
translate(IcyBufferedImage source,
int dx,
int dy,
int channel)
Translate image internal data of specified channel by the specified (x,y) vector.
|
public IcyBufferedImageUtil()
@Deprecated public static IcyBufferedImage toIcyBufferedImage(java.awt.image.BufferedImage image)
IcyBufferedImage.createFrom(BufferedImage)
instead.@Deprecated public static IcyBufferedImage toIcyBufferedImage(java.util.List<java.awt.image.BufferedImage> images)
IcyBufferedImage.createFrom(List)
instead.public static java.awt.image.BufferedImage toBufferedImage(IcyBufferedImage source, java.awt.image.BufferedImage dest, LUT lut)
IcyBufferedImage
into the destination BufferedImage
dest
is null
then a new TYPE_INT_ARGB BufferedImage
is
returned.source
- source imagedest
- destination imagelut
- LUT
is used for color calculation (internal lut is used if null).public static java.awt.image.BufferedImage toBufferedImage(IcyBufferedImage source, java.awt.image.BufferedImage dest)
IcyBufferedImage
into the destination BufferedImage
dest
is null then a new TYPE_INT_ARGB BufferedImage
is returned.source
- source imagedest
- destination imagepublic static java.awt.image.BufferedImage toBufferedImage(IcyBufferedImage source, int imageType, LUT lut)
IcyBufferedImage
into a BufferedImage
of the specified
type.source
- source imageimageType
- wanted image type, only the following is accepted :lut
- lut used for color calculation (source image lut is used if null)public static java.awt.image.BufferedImage toBufferedImage(IcyBufferedImage source, int imageType)
IcyBufferedImage
into a BufferedImage
of the specified
type.source
- source imageimageType
- wanted image type, only the following is accepted :@Deprecated public static java.awt.image.BufferedImage getARGBImage(IcyBufferedImage source, LUT lut, java.awt.image.BufferedImage dest)
toBufferedImage(IcyBufferedImage, BufferedImage, LUT)
instead.IcyBufferedImage
into the destination ARGB BufferedImage
dest
is null
then a new ARGB BufferedImage
is
returned.toBufferedImage(IcyBufferedImage, BufferedImage, LUT)
but the output BufferedImage
is fixed to ARGB type (TYPE_INT_ARGB) and the image
cannot be volatile, use toBufferedImage(IcyBufferedImage, BufferedImage, LUT)
for no
ARGB image or if you want volatile accelerated image.source
- source imagedest
- destination image. Note that we access image data so it can't be volatile anymore
which may result in slower drawinglut
- LUT
is used for color calculation (internal lut is used if null).@Deprecated public static java.awt.image.BufferedImage getARGBImage(IcyBufferedImage source, java.awt.image.BufferedImage dest)
toBufferedImage(IcyBufferedImage, BufferedImage)
instead.IcyBufferedImage
into the destination ARGB BufferedImage
dest
is null then a new ARGB BufferedImage
is returned.toBufferedImage(IcyBufferedImage, BufferedImage)
but the output BufferedImage
is fixed to ARGB type (TYPE_INT_ARGB) and the image
cannot be volatile, use toBufferedImage(IcyBufferedImage, BufferedImage)
for no
ARGB image or if you want volatile accelerated image.source
- source imagedest
- destination image. Note that we access image data so it can't be volatile anymore
which may result in slower drawingpublic static java.awt.image.BufferedImage getARGBImage(IcyBufferedImage source, LUT lut)
IcyBufferedImage
into a ARGB BufferedImage
.source
- source imagelut
- LUT
is used for color calculation (internal lut is used if null).public static java.awt.image.BufferedImage getARGBImage(IcyBufferedImage source)
IcyBufferedImage
into a ARGB BufferedImage
.source
- source imagepublic static IcyBufferedImage convertType(IcyBufferedImage source, DataType dataType, Scaler[] scalers)
source
- source imagedataType
- data type wantedscalers
- scalers for scaling internal data during conversion (1 scaler per channel).null
to avoid value conversion.@Deprecated public static IcyBufferedImage convertToType(IcyBufferedImage source, DataType dataType, Scaler scaler)
convertType(IcyBufferedImage, DataType, Scaler[])
instead.public static IcyBufferedImage convertToType(IcyBufferedImage source, DataType dataType, boolean rescale, boolean useDataBounds)
dataType
- Data type wantedrescale
- Indicate if we want to scale data value according to data (or data type) rangeuseDataBounds
- Only used when rescale
parameter is true.public static IcyBufferedImage convertToType(IcyBufferedImage source, DataType dataType, boolean rescale)
dataType
- data type wantedrescale
- indicate if we want to scale data value according to data type rangepublic static IcyBufferedImage getCopy(IcyBufferedImage source)
public static IcyBufferedImage getSubImage(IcyBufferedImage source, java.awt.Rectangle region, int c, int sizeC)
public static IcyBufferedImage getSubImage(IcyBufferedImage source, java.awt.Rectangle region)
@Deprecated public static IcyBufferedImage getSubImage(IcyBufferedImage source, int x, int y, int c, int sizeX, int sizeY, int sizeC)
getSubImage(IcyBufferedImage, Rectangle, int, int)
instead.public static IcyBufferedImage getSubImage(IcyBufferedImage source, int x, int y, int w, int h)
public static IcyBufferedImage extractChannel(IcyBufferedImage source, int channel)
@Deprecated public static IcyBufferedImage extractChannels(IcyBufferedImage source, java.util.List<java.lang.Integer> channelNumbers)
extractChannels(IcyBufferedImage, int[])
instead.public static IcyBufferedImage extractChannels(IcyBufferedImage source, int... channels)
public static IcyBufferedImage addChannels(IcyBufferedImage source, int index, int num)
source
- source image.index
- position where we want to add channel(s).num
- number of channel(s) to add.public static IcyBufferedImage addChannel(IcyBufferedImage source, int index)
source
- source image.index
- position where we want to add channel.public static IcyBufferedImage addChannel(IcyBufferedImage source)
source
- source image.public static IcyBufferedImage rotate(IcyBufferedImage source, double xOrigin, double yOrigin, double angle, IcyBufferedImageUtil.FilterType filterType)
source
- source imagexOrigin
- X origin for the rotationyOrigin
- Y origin for the rotationangle
- rotation angle in radianfilterType
- filter resampling method usedpublic static IcyBufferedImage rotate(IcyBufferedImage source, double angle, IcyBufferedImageUtil.FilterType filterType)
source
- source imageangle
- rotation angle in radianfilterType
- filter resampling method usedpublic static IcyBufferedImage rotate(IcyBufferedImage source, double angle)
source
- source imageangle
- rotation angle in radianpublic static java.lang.Object downscaleBy2(java.lang.Object input, int sizeX, int sizeY, boolean signed, boolean filter, java.lang.Object output)
input
- input image data array (single dimension)sizeX
- width of source imagesizeY
- height of source imagesigned
- consider input byte data as signed (only meaningful when filter is enabled)filter
- enable pixel blending for better representation of the down sampled result image
(otherwise nearest neighbor is used)output
- output buffer (single dimension array with same data type as source image data array).
If set to null
a new array is allocated.public static java.lang.Object downscaleBy2(java.lang.Object input, int sizeX, int sizeY, boolean signed, boolean filter)
input
- input image data array (single dimension)sizeX
- width of source imagesizeY
- height of source imagesigned
- consider input byte data as signed (only meaningful when filter is enabled)filter
- enable pixel blending for better representation of the down sampled result image
(otherwise nearest neighbor is used)public static IcyBufferedImage downscaleBy2(IcyBufferedImage input, boolean filter, IcyBufferedImage output)
input
- input imagefilter
- enable pixel blending for better representation of the down sampled result image
(otherwise nearest neighbor is used)output
- output image receiving the result (should be of same type as input image with X and Y
resolution divided
by 2). If set to null
a new image is created.public static IcyBufferedImage downscaleBy2(IcyBufferedImage input, boolean filter)
input
- input imagefilter
- enable pixel blending for better representation of the down sampled result image
(otherwise nearest neighbor is used)public static IcyBufferedImage downscaleBy2(IcyBufferedImage source, boolean filter, int level)
0
then the input image is directly returned.source
- input imagefilter
- enable pixel blending for better representation of the down sampled result image
(otherwise nearest neighbor is used)level
- number of downscale to process: scale level = 1/2^level0
public static IcyBufferedImage scale(IcyBufferedImage source, int width, int height, boolean resizeContent, int xAlign, int yAlign, IcyBufferedImageUtil.FilterType filterType)
source
- source imageresizeContent
- indicate if content should be resized or not (empty area are 0 filled)xAlign
- horizontal image alignment (SwingConstants.LEFT / CENTER / RIGHT)yAlign
- vertical image alignment (SwingConstants.TOP / CENTER / BOTTOM)filterType
- filter method used for scale (used only if resizeContent is true)public static IcyBufferedImage scale(IcyBufferedImage source, int width, int height, boolean resizeContent, int xAlign, int yAlign)
source
- source imageresizeContent
- indicate if content should be resized or not (empty area are 0 filled)xAlign
- horizontal image alignment (SwingConstants.LEFT / CENTER / RIGHT)yAlign
- vertical image alignment (SwingConstants.TOP / CENTER / BOTTOM)public static IcyBufferedImage scale(IcyBufferedImage source, int width, int height, IcyBufferedImageUtil.FilterType filterType)
source
- source imagefilterType
- filter method used for scale (used only if resizeContent is true)public static IcyBufferedImage scale(IcyBufferedImage source, int width, int height)
public static void translate(IcyBufferedImage source, int dx, int dy, int channel)
public static void translate(IcyBufferedImage source, int dx, int dy)