|
NASA World Wind | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgov.nasa.worldwind.util.ImageUtil
public class ImageUtil
| Nested Class Summary | |
|---|---|
static class |
ImageUtil.AlignedImage
|
| Field Summary | |
|---|---|
static int |
BILINEAR_INTERPOLATION
|
static int |
IMAGE_TILE_SIZE
|
static int |
NEAREST_NEIGHBOR_INTERPOLATION
|
static Color |
TRANSPARENT
|
| Constructor Summary | |
|---|---|
ImageUtil()
|
|
| Method Summary | |
|---|---|
static ImageUtil.AlignedImage |
alignImage(BufferedImage sourceImage,
float[] latitudes,
float[] longitudes)
Reprojects an image into an aligned image, one with edges of constant latitude and longitude. |
static ImageUtil.AlignedImage |
alignImage(BufferedImage sourceImage,
float[] latitudes,
float[] longitudes,
Sector sector)
Reprojects an image into an aligned image, one with edges of constant latitude and longitude. |
static BufferedImage[] |
buildMipmaps(BufferedImage image)
Builds a sequence of mipmaps for the specified image. |
static BufferedImage[] |
buildMipmaps(BufferedImage image,
int mipmapImageType,
int maxLevel)
Builds a sequence of mipmaps for the specified image. |
static void |
computeBestFittingControlPoints4(Point2D[] imagePoints,
LatLon[] geoPoints,
Point2D[] outImagePoints,
LatLon[] outGeoPoints)
Computes which three control points out of four provide the best estimate an image's geographic location. |
static List<LatLon> |
computeImageCorners(int imageWidth,
int imageHeight,
Matrix imageToGeographic)
Returns the geographic corners of an image with the specified dimensions, and a transform that maps image coordinates to geographic coordinates. |
static long |
computeSizeInBytes(BufferedImage image)
Returns the size in bytes of the specified image. |
static BufferedImage |
convertToPowerOfTwoImage(BufferedImage image,
boolean scaleToFit)
Returns a copy of the specified image such that the new dimensions are powers of two. |
static void |
drawImageOnCanvas(BufferedImage image,
BufferedImage canvas)
Draws the specified image onto the canvas, scaling or streching the image to fit the
canvas. |
static int |
getMaxMipmapLevel(int width,
int height)
Returns the maximum desired mip level for an image with dimensions width and height. |
static int |
interpolateColor(double x,
double y,
int c0,
int c1,
int c2,
int c3)
Performs bilinear interpolation of 32-bit colors over a convex quadrilateral. |
static void |
mergeImage(Sector canvasSector,
Sector imageSector,
double aspectRatio,
BufferedImage image,
BufferedImage canvas)
Merge an image into another image. |
static AVList |
openSpatialImage(File imageFile)
Opens a spatial image. |
static AVList |
openSpatialImage(File imageFile,
int interpolation_mode)
Opens a spatial image. |
static Sector |
positionImage(BufferedImage sourceImage,
Point[] imagePoints,
LatLon[] geoPoints,
BufferedImage destImage)
|
static Sector |
positionImage3(BufferedImage sourceImage,
Point[] imagePoints,
LatLon[] geoPoints,
BufferedImage destImage)
|
static Sector |
positionImage4(BufferedImage sourceImage,
Point[] imagePoints,
LatLon[] geoPoints,
BufferedImage destImage)
|
static void |
reprojectUtmToGeographic(AVList values,
int mode)
Reprojects an imge in UTM projection to Geo/WGS84. |
static Sector |
warpImageWithControlPoints(BufferedImage sourceImage,
Point2D[] imagePoints,
LatLon[] geoPoints,
BufferedImage destImage)
Convenience method for transforming a georeferenced source image into a geographically aligned destination image. |
static Sector |
warpImageWithControlPoints3(BufferedImage sourceImage,
Point2D[] imagePoints,
LatLon[] geoPoints,
BufferedImage destImage)
Transforms a georeferenced source image into a geographically aligned destination image. |
static Sector |
warpImageWithControlPoints4(BufferedImage sourceImage,
Point2D[] imagePoints,
LatLon[] geoPoints,
BufferedImage destImage)
Transforms a georeferenced source image into a geographically aligned destination image. |
static void |
warpImageWithTransform(BufferedImage image,
BufferedImage canvas,
Matrix canvasToImageTransform)
Rasterizes the image into the canvas, given a transform that maps canvas coordinates to image coordinates. |
static Sector |
warpImageWithWorldFile(BufferedImage sourceImage,
AVList worldFileParams,
BufferedImage destImage)
Transforms a georeferenced source image into a geographically aligned destination image. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static int BILINEAR_INTERPOLATION
public static int IMAGE_TILE_SIZE
public static int NEAREST_NEIGHBOR_INTERPOLATION
public static Color TRANSPARENT
| Constructor Detail |
|---|
public ImageUtil()
| Method Detail |
|---|
public static ImageUtil.AlignedImage alignImage(BufferedImage sourceImage,
float[] latitudes,
float[] longitudes)
sourceImage - the image to reproject, typically a non-aligned imagelatitudes - an array identifying the latitude of each pixels if the source image. There must be an entry
in the array for all pixels. The values are taken to be in row-major order relative to the
image -- the horizontal component varies fastest.longitudes - an array identifying the longitude of each pixels if the source image. There must be an entry
in the array for all pixels. The values are taken to be in row-major order relative to the
image -- the horizontal component varies fastest.
public static ImageUtil.AlignedImage alignImage(BufferedImage sourceImage,
float[] latitudes,
float[] longitudes,
Sector sector)
sourceImage - the image to reproject, typically a non-aligned imagelatitudes - an array identifying the latitude of each pixels if the source image. There must be an entry
in the array for all pixels. The values are taken to be in row-major order relative to the
image -- the horizontal component varies fastest.longitudes - an array identifying the longitude of each pixels if the source image. There must be an entry
in the array for all pixels. The values are taken to be in row-major order relative to the
image -- the horizontal component varies fastest.sector - the sector to align the image to.
public static BufferedImage[] buildMipmaps(BufferedImage image)
buildMipmaps(BufferedImage, int, int), with mipmapImageType equal to
image.getType(), and maxLevel equal to getMaxMipmapLevel(image.getWidth(),
image.getHeight()).
image - the BufferedImage to build mipmaps for.
IllegalArgumentException - if image is null.
public static BufferedImage[] buildMipmaps(BufferedImage image,
int mipmapImageType,
int maxLevel)
maxLevel + 1, including level 0. The level 0 image will be a reference to the original image, not a
copy. Each mipmap level will be created with the specified BufferedImage type mipmapImageType. Each
level will have dimensions equal to 1/2 the previous level's dimensions, rownding down, to a minimum width or
height of 1.
image - the BufferedImage to build mipmaps for.mipmapImageType - the BufferedImage type to use when creating each mipmap image.maxLevel - the maximum mip level to create. Specifying zero will return an array containing the
original image.
IllegalArgumentException - if image is null, or if maxLevel is less than zero.getMaxMipmapLevel(int, int)
public static void computeBestFittingControlPoints4(Point2D[] imagePoints,
LatLon[] geoPoints,
Point2D[] outImagePoints,
LatLon[] outGeoPoints)
outImagePoints and outGeoPoints, both of
which must be non-null and at least length 3.
imagePoints - four control points in the image.geoPoints - four geographic locations corresponding to the four imagePoints.outImagePoints - three control points that best estimate the image's location.outGeoPoints - three geographic locations correstponding to the three outImagePoints.
IllegalArgumentException - if any of imagePoints, geoPoints,
outImagePoints or outGeoPoints is null, or if
imagePoints or geoPoints have length less than 4,
or if outImagePoints or outGeoPoints have length
less than 3.
public static List<LatLon> computeImageCorners(int imageWidth,
int imageHeight,
Matrix imageToGeographic)
imageWidth - width of the image grid.imageHeight - height of the image grid.imageToGeographic - Matrix that maps image coordinates to geographic coordinates.
IllegalArgumentException - if either imageWidth or imageHeight are less than 1,
or if imageToGeographic is null.public static long computeSizeInBytes(BufferedImage image)
image - the BufferedImage to compute the size of.
IllegalArgumentException - if image is null.
public static BufferedImage convertToPowerOfTwoImage(BufferedImage image,
boolean scaleToFit)
scaleToFit determines whether the original
image should be drawn into the new image with no special scalign, or whether the original image should be scaled
to fit exactly in the new image. If the original image dimensions are already powers of two, this will simply
return the original image.
image - the BufferedImage to convert to a power of two image.scaleToFit - true if image should be scaled to fit the new image dimensions; false otherwise.s
image with power of two dimensions.
IllegalArgumentException - if image is null.
public static void drawImageOnCanvas(BufferedImage image,
BufferedImage canvas)
image onto the canvas, scaling or streching the image to fit the
canvas. This will apply a bilinear filter to the image if any scaling or streching is necessary.
image - the BufferedImage to draw, potentially scaling or streching to fit the canvas.canvas - the BufferedImage to receive the scaled or streched image.
IllegalArgumentException - if either image or canvas is null.
public static int getMaxMipmapLevel(int width,
int height)
width and height.
The maximum desired level is the number of levels required to reduce the original image dimensions to a 1x1
image.
width - the level 0 image width.height - the level 0 image height.
width and height.
IllegalArgumentException - if either width or height are less than 1.
public static int interpolateColor(double x,
double y,
int c0,
int c1,
int c2,
int c3)
x - horizontal coordinate of the interpolation point relative to the lower left corner of the
quadrilateral. The value should generally be in the range [0, 1].y - vertical coordinate of the interpolation point relative to the lower left corner of the quadrilateral.
The value should generally be in the range [0, 1].c0 - color at the lower left corner of the quadrilateral.c1 - color at the lower right corner of the quadrilateral.c2 - color at the pixel upper right corner of the quadrilateral.c3 - color at the pixel upper left corner of the quadrilateral.
public static void mergeImage(Sector canvasSector,
Sector imageSector,
double aspectRatio,
BufferedImage image,
BufferedImage canvas)
canvasSector - the sector defining the canvas' location and range.imageSector - the sector defining the image's locaion and range.aspectRatio - the aspect ratio, width/height, of the assembled image. If the aspect ratio is greater than
or equal to one, the assembled image uses the full width of the canvas; the height used is
proportional to the inverse of the aspect ratio. If the aspect ratio is less than one, the
full height of the canvas is used; the width used is proportional to the aspect ratio.
The aspect ratio is typically used to maintain consistent width and height units while
assembling multiple images into a canvas of a different aspect ratio than the canvas sector,
such as drawing a non-square region into a 1024x1024 canvas. An aspect ratio of 1 causes the
incoming images to be stretched as necessary in one dimension to match the aspect ratio of
the canvas sector.image - the image to merge into the canvas.canvas - the canvas into which the images are merged. The canvas is not changed if the specified image
and canvas sectors are disjoint.
IllegalArgumentException - if the any of the reference arguments are null or the aspect ratio is less than
or equal to zero.
public static AVList openSpatialImage(File imageFile)
throws IOException
imageFile - source image
IOException - if there is a problem opening the file.
public static AVList openSpatialImage(File imageFile,
int interpolation_mode)
throws IOException
imageFile - source imageinterpolation_mode - the interpolation mode if the image is reprojected.
IOException - if there is a problem opening the file.
WWRuntimeException - if the image type is unsupported.
public static Sector positionImage(BufferedImage sourceImage,
Point[] imagePoints,
LatLon[] geoPoints,
BufferedImage destImage)
public static Sector positionImage3(BufferedImage sourceImage,
Point[] imagePoints,
LatLon[] geoPoints,
BufferedImage destImage)
public static Sector positionImage4(BufferedImage sourceImage,
Point[] imagePoints,
LatLon[] geoPoints,
BufferedImage destImage)
public static void reprojectUtmToGeographic(AVList values,
int mode)
values - AVList: contains the bufferedimage and the values from the world file. Stores resulting image in
valuesmode - the interpolation mode if the image is reprojected.
public static Sector warpImageWithControlPoints(BufferedImage sourceImage,
Point2D[] imagePoints,
LatLon[] geoPoints,
BufferedImage destImage)
sourceImage - the source image to transform.imagePoints - three or four control points in the source image.geoPoints - three or four geographic locations corresponding to each source control point.destImage - the destination image to receive the transformed source imnage.
IllegalArgumentException - if any of sourceImage, destImage,
imagePoints or geoPoints is null, or if either
imagePoints or geoPoints have length less than 3.
public static Sector warpImageWithControlPoints3(BufferedImage sourceImage,
Point2D[] imagePoints,
LatLon[] geoPoints,
BufferedImage destImage)
sourceImage - the source image to transform.imagePoints - three control points in the source image.geoPoints - three geographic locations corresponding to each source control point.destImage - the destination image to receive the transformed source imnage.
IllegalArgumentException - if any of sourceImage, destImage,
imagePoints or geoPoints is null, or if either
imagePoints or geoPoints have length less than 3.
public static Sector warpImageWithControlPoints4(BufferedImage sourceImage,
Point2D[] imagePoints,
LatLon[] geoPoints,
BufferedImage destImage)
sourceImage - the source image to transform.imagePoints - four control points in the source image.geoPoints - four geographic locations corresponding to each source control point.destImage - the destination image to receive the transformed source imnage.
IllegalArgumentException - if any of sourceImage, destImage,
imagePoints or geoPoints is null, or if either
imagePoints or geoPoints have length less than 4.
public static void warpImageWithTransform(BufferedImage image,
BufferedImage canvas,
Matrix canvasToImageTransform)
image - the source image.canvas - the image to receive the transformed source image.canvasToImageTransform - Matrix that maps a canvas coordinates to image coordinates.
IllegalArgumentException - if any of image, canvas, or canvasToImageTransform
are null.
public static Sector warpImageWithWorldFile(BufferedImage sourceImage,
AVList worldFileParams,
BufferedImage destImage)
sourceImage - the source image to transform.worldFileParams - world file parameters which define an affine transform.destImage - the destination image to receive the transformed source imnage.
IllegalArgumentException - if any of sourceImage, destImage or
worldFileParams is null.
|
NASA World Wind | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||