public final class ImageTools extends Object
| Modifier and Type | Field and Description |
|---|---|
private static org.apache.log4j.Logger |
logger |
| Constructor and Description |
|---|
ImageTools() |
| Modifier and Type | Method and Description |
|---|---|
static javax.media.jai.PlanarImage |
combineChannels(javax.media.jai.PlanarImage pi,
List<Integer> bands)
Combines the specified channels (bands) from a given image to a single
band grey value image.
|
static javax.media.jai.PlanarImage |
copyCustomImageProperties(javax.media.jai.PlanarImage source,
javax.media.jai.PlanarImage destination)
Copies the image properties
image_name
file_name
model_name
from the source to the destination object. |
static String |
createB64EncodedToolTipImg(javax.media.jai.PlanarImage image,
int targetWidth,
int targetHeight)
Creates a base64 encoded string for the data URI of an image to be used
in an HTML tag.
|
static Thumbnail |
createManagerThumb(javax.media.jai.PlanarImage pi)
Generate a 40-by-40 pixel thumb nail of a given image.
|
static Thumbnail |
createTankThumb(javax.media.jai.PlanarImage pi)
Generate a 60-by-60 pixel thumb nail of a given image for the Tank list.
|
static ImageIcon |
createThumbnail(javax.media.jai.PlanarImage image,
int targetWidth,
int targetHeight,
boolean keepAspectRatio,
boolean withBorder)
This static method returns an image icon of a given
PlanarImage. |
static javax.media.jai.PlanarImage |
extractBlackChannel(javax.media.jai.PlanarImage pi)
Extracts an entirely black channel of the size of a given image.
|
static javax.media.jai.PlanarImage |
extractChannel(javax.media.jai.PlanarImage pi,
int band)
Extracts a specified channel (band) from a given image.
|
static javax.media.jai.PlanarImage |
extractChannels(javax.media.jai.PlanarImage pi,
List<Integer> bands)
Extracts a specified channels (bands) from a given image and produces a
multi-banded image.
|
static double[] |
getCenterOfGravity(javax.media.jai.PlanarImage pi)
This method calculates the center of gravity The center coordinates refer
to the upper left corner
|
static String |
getImgType(javax.media.jai.PlanarImage pi)
This static method gets the image type
|
static double |
getImgTypeGreyMax(javax.media.jai.PlanarImage pi)
This method gets the maximal possible grey value depending on the image
type
|
static int |
getRasterSample(Raster r,
int x,
int y,
int band)
This method returns a raster sample from within the Raster's bounding
rectangle.
|
static void |
main(String[] args) |
static javax.media.jai.PlanarImage |
paintROIsOnImage(javax.media.jai.PlanarImage image,
List<IDrawingLayer> layers)
Superimposes a set of regions of interest on an underlying image.
|
static javax.media.jai.PlanarImage |
removeAlphaChannel(javax.media.jai.PlanarImage image)
Removes the alpha channel, if any present and returns the image with the
number of original color bands.
|
static Raster |
removeAlphaChannel(Raster raster)
Removes the alpha channel, if any present and returns the raster with the
number of original color bands.
|
static javax.media.jai.PlanarImage |
scale(javax.media.jai.PlanarImage image,
int targetWidth,
int targetHeight)
Scales a given image to a specified size.
|
static javax.media.jai.PlanarImage |
scaleKeepAspectRatio(javax.media.jai.PlanarImage image,
int targetSize)
Scales a given image to a target size by keeping the aspect ratio.
|
static void |
showImage(BufferedImage image,
String title)
Displays the
BufferedImage in a separate JFrame. |
static BufferedImage |
toBufferedImage(RenderedImage img) |
static byte[] |
toByteArray(javax.media.jai.PlanarImage image,
String encoding)
Creates a base64 encoded string for the data URI of an image to be used
in an HTML tag.
|
static RenderedImage |
toCompatibleImage(RenderedImage input)
Draws the input image to a compatible format for the current local
GraphicsEnvironment. |
public static javax.media.jai.PlanarImage copyCustomImageProperties(javax.media.jai.PlanarImage source,
javax.media.jai.PlanarImage destination)
image_namefile_namemodel_namesource - destination - public static double[] getCenterOfGravity(javax.media.jai.PlanarImage pi)
public static int getRasterSample(Raster r, int x, int y, int band)
r - x - y - band - public static String getImgType(javax.media.jai.PlanarImage pi)
pi - - PlanarImage instancepublic static double getImgTypeGreyMax(javax.media.jai.PlanarImage pi)
public static Thumbnail createTankThumb(javax.media.jai.PlanarImage pi)
pi - an imagepublic static Thumbnail createManagerThumb(javax.media.jai.PlanarImage pi)
pi - the image to be scaledpublic static ImageIcon createThumbnail(javax.media.jai.PlanarImage image, int targetWidth, int targetHeight, boolean keepAspectRatio, boolean withBorder)
PlanarImage.image - the image to be scaledtargetWidth - the target width of the thumb nailtargetHeight - the target height of the thumb nail (only used if
keepAspectRatio is false)keepAspectRatio - whether or not the value given in targetWidth
should be used as longest edgewithBorder - whether or not a grey border should be painted around the
scaled imagepublic static String createB64EncodedToolTipImg(javax.media.jai.PlanarImage image, int targetWidth, int targetHeight)
image - the imagetargetWidth - the target widthtargetHeight - the target heightStringpublic static javax.media.jai.PlanarImage scaleKeepAspectRatio(javax.media.jai.PlanarImage image,
int targetSize)
image - targetSize - public static javax.media.jai.PlanarImage scale(javax.media.jai.PlanarImage image,
int targetWidth,
int targetHeight)
image - the original imagetargetWidth - the target widthtargetHeight - the target heightpublic static void showImage(BufferedImage image, String title)
BufferedImage in a separate JFrame.image - public static byte[] toByteArray(javax.media.jai.PlanarImage image,
String encoding)
image - the imageencoding - the encoding string for
ImageIO.write(java.awt.image.RenderedImage, String, java.io.OutputStream)byte[]public static void main(String[] args)
public static javax.media.jai.PlanarImage removeAlphaChannel(javax.media.jai.PlanarImage image)
If the image does not have an alpha channel, it is returned unchanged.
image - IllegalArgumentException - if the image is nullpublic static Raster removeAlphaChannel(Raster raster)
If the raster does not have an alpha channel, it is returned unchanged.
raster - IllegalArgumentException - if the image is nullpublic static javax.media.jai.PlanarImage extractChannel(javax.media.jai.PlanarImage pi,
int band)
pi - the source imageband - the band to be extractedIllegalArgumentException - if pi is null,
band<0, or band>
pi.getNumBands()public static javax.media.jai.PlanarImage extractBlackChannel(javax.media.jai.PlanarImage pi)
pi - the source imageIllegalArgumentException - if pi is nullpublic static javax.media.jai.PlanarImage combineChannels(javax.media.jai.PlanarImage pi,
List<Integer> bands)
pi - the source imagebands - the ordered list of bands to be extractedIllegalArgumentException - if pi is null,
bands.size()==0, or
bands.get(i)>pi.getNumBands()public static javax.media.jai.PlanarImage extractChannels(javax.media.jai.PlanarImage pi,
List<Integer> bands)
pi - the source imagebands - the ordered list of bands to be extractedIllegalArgumentException - if pi is null,
bands.size()==0, or
bands.get(i)>pi.getNumBands()public static BufferedImage toBufferedImage(RenderedImage img)
public static RenderedImage toCompatibleImage(RenderedImage input)
GraphicsEnvironment.input - the imagepublic static javax.media.jai.PlanarImage paintROIsOnImage(javax.media.jai.PlanarImage image,
List<IDrawingLayer> layers)
image - layers - Copyright © 2009–2017 Helmut Ahammer, Philipp Kainz. All rights reserved.