Class ImageUtilities
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TiledImagecreateConstantImage(int minx, int miny, int width, int height, int tileWidth, int tileHeight, Number[] values) Creates a new TiledImage object with one or more bands of constant value.static TiledImagecreateConstantImage(int minx, int miny, int width, int height, Number value) Creates a new TiledImage object with a single band of constant value.static TiledImagecreateConstantImage(int minx, int miny, int width, int height, Number[] values) Creates a new TiledImage object with one or more bands of constant value.static TiledImagecreateConstantImage(int width, int height, Number value) Creates a new TiledImage object with a single band of constant value.static TiledImagecreateConstantImage(int width, int height, Number[] values) Creates a new TiledImage object with one or more bands of constant value.static RenderedImagecreateDisplayImage(RenderedImage dataImg, Map<Integer, Color> colourTable) Creates a proxy RGB display image for the given data image.static TiledImagecreateImageFromArray(Number[] array, int width, int height) Creates a new single-band TiledImage with the provided values.static Color[]createRampColours(int numColours) Create a set of colours using a simple colour ramp algorithm in the HSB colour space.static Color[]createRampColours(int numColours, float saturation, float brightness) Create a set of colours using a simple colour ramp algorithm in the HSB colour space.static Color[]createRampColours(int numColours, float startHue, float endHue, float saturation, float brightness) Create a set of colours using a simple colour ramp algorithm in the HSB colour space.static voidfillBackground(WritableRaster raster, Rectangle rect, double[] backgroundValues) Fill the specified rectangle ofrasterwith the provided background values.static List<RenderedImage>Get the bands of a multi-band image as a list of single-band images.static List<RenderedImage>getBandsAsImages(RenderedImage img, Collection<Integer> bandIndices) Get the specified bands of a multi-band image as a list of single-band images.static ColorModelgetColorModel(SampleModel sm, boolean setAlpha) Creates and returns a ColorModel compatible with the given SampleModelstatic booleanisBinary(SampleModel sm) Check whether aSampleModelrepresents a binary data set, i.e., a single band of data with one bit per pixel packed into aMultiPixelPackedSampleModel.static booleanDeprecated.static doublenext(double f) Finds the least double greater than f.static doubleprevious(double f) Finds the greatest double less than f.static doubleReturns the next or previous representable number.
-
Constructor Details
-
ImageUtilities
public ImageUtilities()
-
-
Method Details
-
rool
Returns the next or previous representable number. Ifamountis equals to0, then this method returns thevalueunchanged. Otherwise, The operation performed depends on the specifiedtype:-
If the
typeisDouble, then this method is equivalent to invokingprevious(double)ifamountis equals to-1, or invokingnext(double)ifamountis equals to+1. Ifamountis smaller than-1or greater than+1, then this method invokesprevious(double)ornext(double)in a loop forabs(amount)times. -
If the
typeisFloat, then this method is equivalent to invokingprevious(float)ifamountis equals to-1, or invokingnext(float)ifamountis equals to+1. Ifamountis smaller than-1or greater than+1, then this method invokesprevious(float)ornext(float)in a loop forabs(amount)times. -
If the
typeis an integer, then invoking this method is equivalent to computingvalue + amount.
- Parameters:
type- The type. Should be the class ofDouble,Float,Long,Integer,ShortorByte.value- The number to rool.amount- -1 to return the previous representable number, +1 to return the next representable number, or 0 to return the number with no change.- Returns:
- One of previous or next representable number as a
double. - Throws:
IllegalArgumentException- iftypeis not one of supported types.
-
-
isInteger
Deprecated.Moved toClasses. -
next
public static double next(double f) Finds the least double greater than f. IfNaN, returns same value.- See Also:
-
previous
public static double previous(double f) Finds the greatest double less than f. IfNaN, returns same value.- See Also:
-
fillBackground
Fill the specified rectangle ofrasterwith the provided background values. Suppose the raster is initialized to 0. Thus, for binary data, if the provided background values are 0, do nothing. -
isBinary
Check whether aSampleModelrepresents a binary data set, i.e., a single band of data with one bit per pixel packed into aMultiPixelPackedSampleModel. -
createConstantImage
Creates a new TiledImage object with a single band of constant value. The data type of the image corresponds to the class ofvalue.- Parameters:
width- image width in pixelsheight- image height in pixelsvalue- the constant value to fill the image- Returns:
- a new TiledImage object
-
createConstantImage
public static TiledImage createConstantImage(int minx, int miny, int width, int height, Number value) Creates a new TiledImage object with a single band of constant value. The data type of the image corresponds to the class ofvalue.- Parameters:
minx- minimum image X ordinateminy- minimum image Y ordinatewidth- image width in pixelsheight- image height in pixelsvalue- the constant value to fill the image- Returns:
- a new TiledImage object
-
createConstantImage
Creates a new TiledImage object with one or more bands of constant value. The number of bands in the output image corresponds to the length of the input values array and the data type of the image corresponds to theNumberclass used.- Parameters:
width- image width in pixelsheight- image height in pixelsvalues- array of values (must contain at least one element)- Returns:
- a new TiledImage object
-
createConstantImage
public static TiledImage createConstantImage(int minx, int miny, int width, int height, Number[] values) Creates a new TiledImage object with one or more bands of constant value. The number of bands in the output image corresponds to the length of the input values array and the data type of the image corresponds to theNumberclass used.- Parameters:
minx- minimum image X ordinateminy- minimum image Y ordinatewidth- image width in pixelsheight- image height in pixelsvalues- array of values (must contain at least one element)- Returns:
- a new TiledImage object
-
createConstantImage
public static TiledImage createConstantImage(int minx, int miny, int width, int height, int tileWidth, int tileHeight, Number[] values) Creates a new TiledImage object with one or more bands of constant value. The number of bands in the output image corresponds to the length of the input values array and the data type of the image corresponds to theNumberclass used.- Parameters:
minx- minimum image X ordinateminy- minimum image Y ordinatewidth- image widthheight- image heighttileWidth- width of image tilestileHeight- height of image tilesvalues- array of values (must contain at least one element)- Returns:
- a new TiledImage object
-
createImageFromArray
Creates a new single-band TiledImage with the provided values. Thearrayargument must be of lengthwidthxheight.- Parameters:
array- a 1D array of values for the imagewidth- image widthheight- image height- Returns:
- the new image
-
createRampColours
Create a set of colours using a simple colour ramp algorithm in the HSB colour space.- Parameters:
numColours- number of colours required- Returns:
- an array of colours sampled from the HSB space.
-
createRampColours
Create a set of colours using a simple colour ramp algorithm in the HSB colour space.- Parameters:
numColours- number of colours requiredsaturation- the saturation of all colours (between 0 and 1)brightness- the brightness of all colours (between 0 and 1)- Returns:
- an array of colours sampled from the HSB space between the start and end hues
-
createRampColours
public static Color[] createRampColours(int numColours, float startHue, float endHue, float saturation, float brightness) Create a set of colours using a simple colour ramp algorithm in the HSB colour space. All float arguments should be values between 0 and 1.- Parameters:
numColours- number of colours requiredstartHue- the starting hueendHue- the ending huesaturation- the saturation of all coloursbrightness- the brightness of all colours- Returns:
- an array of colours sampled from the HSB space between the start and end hues
-
createDisplayImage
public static RenderedImage createDisplayImage(RenderedImage dataImg, Map<Integer, Color> colourTable) Creates a proxy RGB display image for the given data image. The data image should be of integral data type. Only the first band of multi-band images will be used.- Parameters:
dataImg- the data imagecolourTable- a lookup table giving colours for each data image value- Returns:
- a new RGB image
-
getBandsAsImages
Get the bands of a multi-band image as a list of single-band images. This can be used, for example, to separate the result image returned by the KernelStats operator into separate result images.- Parameters:
img- the multi-band image- Returns:
- a List of new single-band images
-
getBandsAsImages
public static List<RenderedImage> getBandsAsImages(RenderedImage img, Collection<Integer> bandIndices) Get the specified bands of a multi-band image as a list of single-band images. This can be used, for example, to separate the result image returned by the KernelStats operator into separate result images.- Parameters:
img- the multi-band imagebandIndices- a Collection of Integer indices in the range 0 <= i < number of bands- Returns:
- a List of new single-band images
-
getColorModel
Creates and returns a ColorModel compatible with the given SampleModel
-
Classes.