Interface FastPixel
-
- All Known Implementing Classes:
FastPixelByte,FastPixelImpl,FastPixelInt,FastPixelSlowDefault
public interface FastPixelUtility class to access pixel data in a fraction of the time required by the native JDK methods.Additionally support different color spaces and bulk operations
- Author:
- Kilian
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static FastPixelcreate(BufferedImage bufferedImage)Return a fast pixel instance mapped to the buffered image typeint[][]getAlpha()Get the alpha component of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.intgetAlpha(int index)Get the alpha value of the specified pixeldefault intgetAlpha(int x, int y)Get the alpha value of the specified pixelint[][]getAverageGrayscale()Get the average grayscale of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.intgetAverageGrayscale(int index)Get the average grayscale at the specified offsetdefault intgetAverageGrayscale(int x, int y)Get the average grayscale of the specified pixelint[][]getBlue()Get the blue component of the entire image mapped to a 2d array representing the x and y coordinates of the image.intgetBlue(int index)Get the blue value of the specified offsetdefault intgetBlue(int x, int y)Get the blue value of the specified pixelint[]getBlue1D()Get the blue component of the entire image mapped to a 1d arraydefault intgetCb(int index)Return the Cb(blue-difference) component of the YCbCr color model for the specified offset.default intgetCb(int x, int y)Return the Cb(blue-difference) component of the YCbCr color model for the specified pixel.default intgetCr(int index)default intgetCr(int x, int y)Return the Cr(red-difference) component of the YCbCr color model for the specified pixel.int[][]getGreen()Get the green component of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.intgetGreen(int index)Get the green value of the specified offsetdefault intgetGreen(int x, int y)Get the green value of the specified pixelint[]getGreen1D()Get the green component of the entire image mapped to a 1d arraydefault intgetHue(int index)Return the hue component (angle) of the HSV color model for the specified offsetdefault intgetHue(int x, int y)Return the hue component (angle) of the HSV color model for the specified pixelint[][]getLuma()Return the Y(Luma) component of the YCbCr color model for the entire image mapped to a 2d array representing the x and y coordinates of the pixel.default intgetLuma(int index)Return the Y(Luma) component of the YCbCr color model for the specified offset.default intgetLuma(int x, int y)Return the Y(Luma) component of the YCbCr color model for the specified pixel.int[]getLuma1D()Return the Y(Luma) component of the YCbCr color model fof the entire image mapped to a 1d arrayintgetOffset(int x, int y)Map the x and y values to the underlying one dimensional data arrayint[][]getRed()Get the red component of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.intgetRed(int index)Get the red value at the specified offsetdefault intgetRed(int x, int y)Get the red value of the specified pixelint[]getRed1D()Get the red component of the entire image mapped to a 1d arrayint[][]getRGB()Returns the rgb values of the entire image in an 2 d array in the default RGB color model(TYPE_INT_ARGB).intgetRGB(int index)default intgetRGB(int x, int y)Returns an integer pixel in the default RGB color model(TYPE_INT_ARGB).default doublegetSat(int index)Return the saturation component of the HSV color model for the specified offsetdefault doublegetSat(int x, int y)Return the saturation component of the HSV color model for the specified pixeldefault intgetVal(int index)Return the value component of the HSV color model for the specified offsetdefault intgetVal(int x, int y)Return the value component of the HSV color model for the specified pixelbooleanhasAlpha()Check if an image supports alpha valuesbooleanisReplaceOpaqueColors()Check if the pixel loader replaces opaque colors with a non opaque version.voidsetAlpha(int[][] newAlpha)Set new alpha values for the entire picturevoidsetAlpha(int index, int newAlpha)Set the alpha value.default voidsetAlpha(int x, int y, int newAlpha)Set the alpha value of the specified pixel.voidsetAverageGrayscale(int[][] newGrayValue)Set the gray values of the entire image.default voidsetAverageGrayscale(int index, int newGrayValue)Set the gray values at the specified offsetdefault voidsetAverageGrayscale(int x, int y, int newGrayValue)Set the gray values of the specified pixel image.voidsetBlue(int[][] newBlue)Set new blue values for the entire picturevoidsetBlue(int index, int newBlue)default voidsetBlue(int x, int y, int newBlue)Set the blue value of the specified pixelvoidsetGreen(int[][] newGreen)Set new green values for the entire picturevoidsetGreen(int index, int newGreen)Set the green value at the specified offsetdefault voidsetGreen(int x, int y, int newGreen)Set the green value of the specified pixelvoidsetRed(int[][] newRed)Set new red values for the entire picturevoidsetRed(int index, int newRed)Set the red value at the specified offsetdefault voidsetRed(int x, int y, int newRed)Set the red value of the specified pixelvoidsetReplaceOpaqueColors(int alphaThreshold, int r, int g, int b, int a)Replace all pixels values in the image which have an alpha < than the specified threshold.default voidsetReplaceOpaqueColors(int alphaThreshold, Color replacementColor)Replace all pixels values in the image which have an alpha < than the specified threshold.default voidsetReplaceOpaqueColors(int alphaThreshold, javafx.scene.paint.Color replacementColor)Replace all pixels values in the image which have an alpha < than the specified threshold.
-
-
-
Field Detail
-
LOGGER
static final Logger LOGGER
-
-
Method Detail
-
create
static FastPixel create(BufferedImage bufferedImage)
Return a fast pixel instance mapped to the buffered image type- Parameters:
bufferedImage- the buffered image to create a fast pixel instance for- Returns:
- an instantiated FastPixelObject
-
isReplaceOpaqueColors
boolean isReplaceOpaqueColors()
Check if the pixel loader replaces opaque colors with a non opaque version. Opaque values are replaced only on get operations. To activate this option callsetReplaceOpaqueColors(int, int, int, int, int)and set a color which will be returned in case that the pixel has an alpha value smaller than the specified threshold- Returns:
- true if opaque colors are replaced by a user defined color
- Since:
- 1.0.0
-
setReplaceOpaqueColors
void setReplaceOpaqueColors(int alphaThreshold, int r, int g, int b, int a)Replace all pixels values in the image which have an alpha < than the specified threshold. The pixel value is replaced for all get operations, including luminosity calculation. Set operations are not touched by this setting.- Parameters:
alphaThreshold- replace each pixel which has an alpha value smaller or equal to the threshold in the range of [0-255]. A value of will disabled color replacementr- the red value which will be returned in case of an opaque pixel [0-255]g- the green value which will be returned in case of an opaque pixel [0-255]b- the blue value which will be returned in case of an opaque pixel [0-255]a- the alpha value which will be returned in case of an opaque pixel [0-255]- Since:
- 1.0.0
-
setReplaceOpaqueColors
default void setReplaceOpaqueColors(int alphaThreshold, Color replacementColor)Replace all pixels values in the image which have an alpha < than the specified threshold. The pixel value is replaced for all get operations, including luminosity calculation. Set operations are not touched by this setting.- Parameters:
alphaThreshold- replace each pixel which has an alpha value smaller or equal to the threshold in the range of [0-255]. A value of will disabled color replacementreplacementColor- the color which will be returned in case of an opaque pixel
-
setReplaceOpaqueColors
default void setReplaceOpaqueColors(int alphaThreshold, javafx.scene.paint.Color replacementColor)Replace all pixels values in the image which have an alpha < than the specified threshold. The pixel value is replaced for all get operations, including luminosity calculation. Set operations are not touched by this setting.- Parameters:
alphaThreshold- replace each pixel which has an alpha value smaller or equal to the threshold in the range of [0-255]. A value of will disabled color replacementreplacementColor- the color which will be returned in case of an opaque pixel
-
getRGB
int getRGB(int index)
-
getRGB
default int getRGB(int x, int y)Returns an integer pixel in the default RGB color model(TYPE_INT_ARGB). There are only 8-bits of precision for each color component in the returned data when using this method. An ArrayOutOfBoundsException may be thrown if the coordinates are not in bounds.- Parameters:
x- the X coordinate of the pixel from which to get the pixel in the default RGB color modely- the Y coordinate of the pixel from which to get the pixel in the default RGB color model- Returns:
- an integer pixel in the default RGB color model and default sRGB colorspace.
- Since:
- 1.3.0 com.github.kilianB
-
getRGB
int[][] getRGB()
Returns the rgb values of the entire image in an 2 d array in the default RGB color model(TYPE_INT_ARGB). There are only 8-bits of precision for each color component in the returned data when using this method. An ArrayOutOfBoundsException may be thrown if the coordinates are not in bounds.- Returns:
- a 2d integer array containing the argb values of the image
- Since:
- 1.3.0 com.github.kilianB
-
getAlpha
int getAlpha(int index)
Get the alpha value of the specified pixel- Parameters:
index- the offset in the underlying array- Returns:
- the alpha value in range [0-255] or -1 if alpha is not supported
- Since:
- 1.5.0 com.github.kilianB
-
getAlpha
default int getAlpha(int x, int y)Get the alpha value of the specified pixel- Parameters:
x- The x coordinate of the images' pixely- The y coordinate of the images' pixel- Returns:
- the alpha value in range [0-255] or -1 if alpha is not supported
- Since:
- 1.3.0 com.github.kilianB
-
getAlpha
int[][] getAlpha()
Get the alpha component of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.- Returns:
- the alpha values or null if alpha is not supported
- Since:
- 1.3.0 com.github.kilianB
-
setAlpha
default void setAlpha(int x, int y, int newAlpha)Set the alpha value of the specified pixel. This method is a NOP if alpha is not supported.- Parameters:
x- The x coordinate of the images' pixely- The y coordinate of the images' pixelnewAlpha- the new alpha value in range [0-255]- Since:
- 1.3.0 com.github.kilianB
-
setAlpha
void setAlpha(int index, int newAlpha)Set the alpha value. This method is a NOP if alpha is not supported.- Parameters:
index- the offset of the underlying arraynewAlpha- the new alpha value in range [0-255]- Since:
- 1.5.0 com.github.kilianB
-
setAlpha
void setAlpha(int[][] newAlpha)
Set new alpha values for the entire picture- Parameters:
newAlpha- red values in range [0-255]- Since:
- 1.4.5 com.github.kilianB
-
getRed
int getRed(int index)
Get the red value at the specified offset- Parameters:
index- offset of ther underlying array- Returns:
- the red value in range [0-255]
- Since:
- 1.5.0 com.github.kilianB
-
getRed
default int getRed(int x, int y)Get the red value of the specified pixel- Parameters:
x- The x coordinate of the images' pixely- The y coordinate of the images' pixel- Returns:
- the red value in range [0-255]
- Since:
- 1.3.0 com.github.kilianB
-
getRed
int[][] getRed()
Get the red component of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.- Returns:
- the red values in range [0-255]
- Since:
- 1.3.0 com.github.kilianB
-
getRed1D
int[] getRed1D()
Get the red component of the entire image mapped to a 1d array- Returns:
- the red values in range [0-255]
- Since:
- 1.5.5 com.github.kilianB
-
setRed
default void setRed(int x, int y, int newRed)Set the red value of the specified pixel- Parameters:
x- The x coordinate of the images' pixely- The y coordinate of the images' pixelnewRed- the new red value in range [0-255]- Since:
- 1.3.0 com.github.kilianB
-
setRed
void setRed(int index, int newRed)Set the red value at the specified offset- Parameters:
index- the offset of the underlying arraynewRed- the new red value in range [0-255]- Since:
- 1.5.0 com.github.kilianB
-
setRed
void setRed(int[][] newRed)
Set new red values for the entire picture- Parameters:
newRed- red values in range [0-255]- Since:
- 1.4.5 com.github.kilianB
-
getGreen
int getGreen(int index)
Get the green value of the specified offset- Parameters:
index- the offset of the underlying array- Returns:
- the green value in range [0-255]
- Since:
- 1.5.0 com.github.kilianB
-
getGreen
default int getGreen(int x, int y)Get the green value of the specified pixel- Parameters:
x- The x coordinate of the images' pixely- The y coordinate of the images' pixel- Returns:
- the green value in range [0-255]
- Since:
- 1.3.0 com.github.kilianB
-
setGreen
default void setGreen(int x, int y, int newGreen)Set the green value of the specified pixel- Parameters:
x- The x coordinate of the images' pixely- The y coordinate of the images' pixelnewGreen- the new green value in range [0-255]- Since:
- 1.3.0 com.github.kilianB
-
setGreen
void setGreen(int index, int newGreen)Set the green value at the specified offset- Parameters:
index- the offset of the underlying arraynewGreen- the new green value in range [0-255]- Since:
- 1.5.0 com.github.kilianB
-
setGreen
void setGreen(int[][] newGreen)
Set new green values for the entire picture- Parameters:
newGreen- red values in range [0-255]- Since:
- 1.4.5 com.github.kilianB
-
getGreen
int[][] getGreen()
Get the green component of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.- Returns:
- the green values in range [0-255]
- Since:
- 1.3.0 com.github.kilianB
-
getGreen1D
int[] getGreen1D()
Get the green component of the entire image mapped to a 1d array- Returns:
- the green values in range [0-255]
- Since:
- 1.5.5 com.github.kilianB
-
getBlue
int getBlue(int index)
Get the blue value of the specified offset- Parameters:
index- the offset of the underlying array- Returns:
- the green value in range [0-255]
- Since:
- 1.5.0 com.github.kilianB
-
getBlue
default int getBlue(int x, int y)Get the blue value of the specified pixel- Parameters:
x- The x coordinate of the images' pixely- The y coordinate of the images' pixel- Returns:
- the blue value in range [0-255]
- Since:
- 1.3.0 com.github.kilianB
-
setBlue
default void setBlue(int x, int y, int newBlue)Set the blue value of the specified pixel- Parameters:
x- The x coordinate of the images' pixely- The y coordinate of the images' pixelnewBlue- the new blue value in range [0-255]- Since:
- 1.3.0 com.github.kilianB
-
setBlue
void setBlue(int index, int newBlue)
-
getBlue
int[][] getBlue()
Get the blue component of the entire image mapped to a 2d array representing the x and y coordinates of the image.- Returns:
- the blue values in range [0-255]
- Since:
- 1.3.0 com.github.kilianB
-
getBlue1D
int[] getBlue1D()
Get the blue component of the entire image mapped to a 1d array- Returns:
- the red values in range [0-255]
- Since:
- 1.5.5 com.github.kilianB
-
setBlue
void setBlue(int[][] newBlue)
Set new blue values for the entire picture- Parameters:
newBlue- red values in range [0-255]- Since:
- 1.4.5 com.github.kilianB
-
getAverageGrayscale
int getAverageGrayscale(int index)
Get the average grayscale at the specified offsetAverage grayscale: (R+G+B)/3
This
- Parameters:
index- offset of der underlying array- Returns:
- the grayscale values in range [0-255]
- Since:
- 1.5.0 com.github.kilianB, 1.5.10 will return the default transparency color if com.github.kilianB
-
getAverageGrayscale
default int getAverageGrayscale(int x, int y)Get the average grayscale of the specified pixelAverage grayscale: (R+G+B)/3
- Parameters:
x- The x coordinate of the images' pixely- The y coordinate of the images' pixel- Returns:
- the grayscale values in range [0-255]
- Since:
- 1.5.0 com.github.kilianB
-
getAverageGrayscale
int[][] getAverageGrayscale()
Get the average grayscale of the entire image mapped to a 2d array representing the x and y coordinates of the pixel.Average grayscale: (R+G+B)/3
Average grayscale: (R+G+B)/3
- Returns:
- the grayscale values in range [0 - 255]
- Since:
- 1.5.0 com.github.kilianB
-
setAverageGrayscale
default void setAverageGrayscale(int index, int newGrayValue)Set the gray values at the specified offsetAverage grayscale: (R+G+B)/3
It is up to the inheriting class to decide how the gray value is reflected at the value level. If the image is still in rgb or argb mode the value of each individual channel will be set to the gray value
- Parameters:
index- offset of der underlaying arraynewGrayValue- to set the pixels to range [0 - 255]- Since:
- 1.5.0 com.github.kilianB
-
setAverageGrayscale
default void setAverageGrayscale(int x, int y, int newGrayValue)Set the gray values of the specified pixel image.Average grayscale: (R+G+B)/3
It is up to the inheriting class to decide how the gray value is reflected at the value level. If the image is still in rgb or argb mode the value of each individual channel will be set to the gray value
- Parameters:
x- The x coordinate of the images' pixely- The y coordinate of the images' pixelnewGrayValue- to set the pixels to range [0 - 255]- Since:
- 1.5.0 com.github.kilianB
-
setAverageGrayscale
void setAverageGrayscale(int[][] newGrayValue)
Set the gray values of the entire image.Average grayscale: (R+G+B)/3
It is up to the inheriting class to decide how the gray value is reflected at the value level. If the image is still in rgb or argb mode the value of each individual channel will be set to the gray value
- Parameters:
newGrayValue- to set the pixels to range [0 - 255]- Since:
- 1.5.0 com.github.kilianB
-
getLuma
default int getLuma(int index)
Return the Y(Luma) component of the YCbCr color model for the specified offset.- Parameters:
index- of the underlying array- Returns:
- the luma component in range [0-255]
- Since:
- 1.3.0 com.github.kilianB
-
getLuma
default int getLuma(int x, int y)Return the Y(Luma) component of the YCbCr color model for the specified pixel.- Parameters:
x- the x coordinate of the imagey- the y coordinate of the image- Returns:
- the luma component in range [0-255]
- Since:
- 1.3.0 com.github.kilianB
-
getLuma
int[][] getLuma()
Return the Y(Luma) component of the YCbCr color model for the entire image mapped to a 2d array representing the x and y coordinates of the pixel.- Returns:
- the luma component in range [0-255]
- Since:
- 1.3.1 com.github.kilianB
-
getLuma1D
int[] getLuma1D()
Return the Y(Luma) component of the YCbCr color model fof the entire image mapped to a 1d array- Returns:
- the luma component in range [0-255]
-
getCr
default int getCr(int index)
-
getCr
default int getCr(int x, int y)Return the Cr(red-difference) component of the YCbCr color model for the specified pixel.- Parameters:
x- the x coordinate of the imagey- the y coordinate of the image- Returns:
- the cr component in range [0-255]
- Since:
- 1.3.0 com.github.kilianB
-
getCb
default int getCb(int index)
Return the Cb(blue-difference) component of the YCbCr color model for the specified offset.- Parameters:
index- offset of the underlying array- Returns:
- the cb component in range [0-255]
- Since:
- 1.5.0 com.github.kilianB
-
getCb
default int getCb(int x, int y)Return the Cb(blue-difference) component of the YCbCr color model for the specified pixel.- Parameters:
x- the x coordinate of the imagey- the y coordinate of the image- Returns:
- the cb component in range [0-255]
- Since:
- 1.3.0 com.github.kilianB
-
getHue
default int getHue(int index)
Return the hue component (angle) of the HSV color model for the specified offset- Parameters:
index- offset of der underlying array- Returns:
- the hue component in range [0-360]. As defined the hue is 0 for undefined colors (e.g. white or black)
- Since:
- 1.5.0 com.github.kilianB
-
getHue
default int getHue(int x, int y)Return the hue component (angle) of the HSV color model for the specified pixel- Parameters:
x- the x coordinate of the imagey- the y coordinate of the image- Returns:
- the hue component in range [0-360]. As defined the hue is 0 for undefined colors (e.g. white or black)
- Since:
- 1.3.0 com.github.kilianB
-
getSat
default double getSat(int index)
Return the saturation component of the HSV color model for the specified offsetNote: Opposed to all other values for the hsb model saturation is returned as double in the range of [0-1] instead of [0-255] to allow for a higher accuracy.
- Parameters:
index- the offset of the underlying array- Returns:
- the sat component in range [0-1]. As defined the sat is 0 for undefined colors (i.e. black)
- Since:
- 1.5.0 com.github.kilianB
-
getSat
default double getSat(int x, int y)Return the saturation component of the HSV color model for the specified pixelNote: Opposed to all other values for the hsb model saturation is returned as double in the range of [0-1] instead of [0-255] to allow for a higher accuracy.
- Parameters:
x- the x coordinate of the imagey- the y coordinate of the image- Returns:
- the sat component in range [0-1]. As defined the sat is 0 for undefined colors (i.e. black)
- Since:
- 1.3.0 com.github.kilianB
-
getVal
default int getVal(int index)
Return the value component of the HSV color model for the specified offset- Parameters:
index- offset of the udnerlying array- Returns:
- the value component in range [0-255].
- Since:
- 1.5.0 com.github.kilianB
-
getVal
default int getVal(int x, int y)Return the value component of the HSV color model for the specified pixel- Parameters:
x- the x coordinate of the imagey- the y coordinate of the image- Returns:
- the value component in range [0-255].
-
hasAlpha
boolean hasAlpha()
Check if an image supports alpha values- Returns:
- true if the image has an alpha channel. false otherwise
-
getOffset
int getOffset(int x, int y)Map the x and y values to the underlying one dimensional data array- Parameters:
x- the x coordinatey- the y coordinate- Returns:
- the corresponding 1d array index
-
-