Class ImageData
java.lang.Object
org.ojalgo.data.image.ImageData
- All Implemented Interfaces:
Consumer<Access2D<?>>, Group, Group.Additive<MatrixStore<Double>>, NormedVectorSpace<MatrixStore<Double>, Double>, Operation, Operation.Addition<MatrixStore<Double>>, Operation.Multiplication<MatrixStore<Double>>, Operation.Subtraction<MatrixStore<Double>>, ScalarOperation, ScalarOperation.Addition<MatrixStore<Double>, Double>, ScalarOperation.Division<MatrixStore<Double>, Double>, ScalarOperation.Multiplication<MatrixStore<Double>, Double>, ScalarOperation.Subtraction<MatrixStore<Double>, Double>, VectorSpace<MatrixStore<Double>, Double>, Matrix2D<Double, MatrixStore<Double>>, ElementsSupplier<Double>, MatrixStore<Double>, Access1D<Double>, Access1D.Aggregatable<Double>, Access1D.Collectable<Double,Mutate1D>, Access1D.Sliceable<Double>, Access1D.Visitable<Double>, Access2D<Double>, Access2D.Aggregatable<Double>, Access2D.Collectable<Double, TransformableRegion<Double>>, Access2D.Sliceable<Double>, Access2D.Visitable<Double>, Mutate1D, Mutate1D.Fillable<Double>, Mutate2D, Mutate2D.Fillable<Double>, Mutate2D.Receiver<Double>, Operate2D<Double, ElementsSupplier<Double>>, Structure1D, Structure2D, Structure2D.Logical<Access2D<Double>, MatrixStore<Double>>, Structure2D.ReducibleTo1D<ElementsSupplier<Double>>
- Direct Known Subclasses:
ImageData.SingleChannel
Treats an image as a matrix. (Wraps a
BufferedImage and implements MatrixStore.)
By default this wrapper treats the underlying image as a grey scale image (with no alpha).
- If the underlying image actually is a colour image, then
convertToGreyScale()usually improves the grey scale image quality (visual appearance). - By using
sliceRedChannel(),sliceGreenChannel(),sliceBlueChannel()andsliceAlphaChannel()you access the individual colour channels separately. Then, instead of 1 grey scale image, you have 3 (or 4) colour channel images. Even if they're all backed by the same image, manipulating one channel does not alter the others. - The numbers you get/set are always (enforced to be) in the range [0,255]. If it's a grey scale image, it has 256 shades of grey. Each of the sliced colour channels have 256 shades of their respective colour.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface(package private) static final classNested classes/interfaces inherited from interface Access2D
Access2D.Aggregatable<N>, Access2D.Collectable<N,R>, Access2D.ColumnView<N>, Access2D.ElementView<N>, Access2D.RowView<N>, Access2D.SelectionView<N>, Access2D.Sliceable<N>, Access2D.Visitable<N> Nested classes/interfaces inherited from interface Group
Group.Additive<T>, Group.Multiplicative<T>Nested classes/interfaces inherited from interface Mutate1D
Mutate1D.Fillable<N>, Mutate1D.Mixable<N>, Mutate1D.Modifiable<N>, Mutate1D.ModifiableReceiver<N>, Mutate1D.Receiver<N>, Mutate1D.SortableNested classes/interfaces inherited from interface Mutate2D
Mutate2D.Exchangeable, Mutate2D.Fillable<N>, Mutate2D.Mixable<N>, Mutate2D.Modifiable<N>, Mutate2D.ModifiableReceiver<N>, Mutate2D.Receiver<N>Nested classes/interfaces inherited from interface Operation
Operation.Addition<T>, Operation.Division<T>, Operation.Multiplication<T>, Operation.Subtraction<T>Nested classes/interfaces inherited from interface ScalarOperation
ScalarOperation.Addition<T,N>, ScalarOperation.Division<T, N>, ScalarOperation.Multiplication<T, N>, ScalarOperation.Subtraction<T, N> Nested classes/interfaces inherited from interface Structure1D
Structure1D.BasicMapper<T>, Structure1D.IndexMapper<T>, Structure1D.IntIndex, Structure1D.Logical<S,B>, Structure1D.LongIndex, Structure1D.LoopCallback Nested classes/interfaces inherited from interface Structure2D
Structure2D.IntRowColumn, Structure2D.Logical<S,B>, Structure2D.LongRowColumn, Structure2D.ReducibleTo1D<R>, Structure2D.Reshapable, Structure2D.RowColumnKey<R, C>, Structure2D.RowColumnMapper<R, C> -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int(package private) static final int(package private) static final int(package private) static final intprivate final BufferedImage(package private) static final int(package private) static final int(package private) static final int(package private) static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyGaussianBlur(double sigma) Creates a new image (of the same type) blurring the input using a Gaussian blur kernel.bytebyteValue(int row, int col) convertTo(int imageType) Creates a new image, converting the input to the specified image type in the process.static ImageDatalongOnly need to implement if the structure may contain more than Integer.MAX_VALUE elements.longOnly need to implement if the structure may contain more than Integer.MAX_VALUE elements.private doubledoubleValue(double row, double col) doubledoubleValue(int row, int col) Extracts one element of this matrix as a double.voidfillMatching(Access2D<?> values) floatfloatValue(int row, int col) static ImageDatafromFrequencyDomain(MatrixStore<ComplexNumber> transformed) Creates a new image, transforming the input (back) from the frequency domain to the spatial domain using the inverse discrete Fourier transform.get(int row, int col) protected intgetARGB(int row, int col) intprivate static KernelgetGaussianKernel(double sigma, int radius) getImage()intintintValue(int row, int col) static ImageDatanewColour(int nbRows, int nbCols) static ImageDatanewColour(Structure2D shape) static ImageDatanewGreyScale(int nbRows, int nbCols) static ImageDatanewGreyScale(Structure2D shape) static Transformation2D<ComplexNumber> Creates a new transformation that can be used to transform a matrix of complex numbers in the frequency domain.static ImageDataofPowerSpectrum(Access2D<ComplexNumber> transformed) Converts a matrix of complex numbers to an image of its power spectrum (log10 of the squared norms).physical()static ImageDatastatic ImageDataresample(int nbRows, int nbCols) Will create a new image - the largest possible, with the same aspect ratio, that fits within the specified number of rows/columns (pixel height and width).voidset(int row, int col, double value) voidset(int row, int col, float value) voidset(int row, int col, int value) voidset(int row, int col, long value) voidset(long row, long col, Comparable<?> value) protected voidsetARGB(int row, int col, int argb) Transforms the spatial representation of the image to its frequency representation using the discrete Fourier transform.(package private) static inttoRanged(int value) static ImageDatawrap(BufferedImage image) voidThe file format is derived from the file name ending (png, jpg...)voidMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Access1D
asCollectable1D, asKeyed1D, asList, axpy, dot, select, supplyTo, toList, toRawCopy1DMethods inherited from interface Access1D.Collectable
collectMethods inherited from interface Access1D.Visitable
visitAll, visitRangeMethods inherited from interface Access2D
asCollectable2D, asKeyed2D, byteValue, byteValue, byteValue, columns, doubleValue, doubleValue, doubleValue, elements, floatValue, floatValue, floatValue, get, intValue, intValue, intValue, longValue, longValue, longValue, longValue, nonzeros, rows, shortValue, shortValue, shortValue, shortValue, toRawCopy2DMethods inherited from interface Access2D.Aggregatable
aggregateColumn, aggregateDiagonal, aggregateRow, reduceColumns, reduceRowsMethods inherited from interface Access2D.Collectable
collectMethods inherited from interface Access2D.Sliceable
sliceColumn, sliceDiagonal, sliceRowMethods inherited from interface Access2D.Visitable
visitColumn, visitColumn, visitDiagonal, visitDiagonal, visitOne, visitRow, visitRowMethods inherited from interface ElementsSupplier
onAny, onColumns, onColumns, onMatching, onMatching, onRows, onRowsMethods inherited from interface MatrixStore
above, above, above, add, add, add, aggregateAll, aggregateColumn, aggregateDiagonal, aggregateRange, aggregateRow, below, below, below, bidiagonal, column, column, columns, columns, conjugate, copy, diagonal, diagonally, divide, divide, equals, get, get, hermitian, hessenberg, indexOfLargest, isHermitian, isNormal, isSmall, isSmall, left, left, left, limits, logical, multiply, multiply, multiply, multiply, multiplyBoth, negate, norm, offsets, onAll, operate, power, premultiply, reduceColumns, reduceRows, repeat, right, right, right, row, row, rows, rows, select, select, signum, sliceColumn, sliceDiagonal, sliceRange, sliceRow, subtract, subtract, subtract, superimpose, superimpose, supplyTo, supplyTo, symmetric, toScalar, transpose, triangular, tridiagonal, visitOneMethods inherited from interface Mutate1D.Fillable
fillAll, fillAll, fillCompatible, fillMatching, fillMatching, fillMatching, fillMatching, fillRange, fillRangeMethods inherited from interface Mutate2D
set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, setMethods inherited from interface Mutate2D.Fillable
fillColumn, fillColumn, fillColumn, fillColumn, fillColumn, fillColumn, fillCompatible, fillDiagonal, fillDiagonal, fillDiagonal, fillDiagonal, fillDiagonal, fillDiagonal, fillRow, fillRow, fillRow, fillRow, fillRow, fillRowMethods inherited from interface Mutate2D.Receiver
accept, isAcceptableMethods inherited from interface Operate2D
onAll, onAll, onAll, onAll, onAll, onCompatible, onCompatibleMethods inherited from interface ScalarOperation.Addition
addMethods inherited from interface ScalarOperation.Division
divideMethods inherited from interface ScalarOperation.Multiplication
multiplyMethods inherited from interface ScalarOperation.Subtraction
subtractMethods inherited from interface Structure2D
count, firstInColumn, firstInRow, getMaxDim, getMinDim, isEmpty, isFat, isScalar, isSquare, isTall, isVector, limitOfColumn, limitOfRow, size
-
Field Details
-
MASK_ALPHA
static final int MASK_ALPHA- See Also:
-
MASK_BLUE
static final int MASK_BLUE- See Also:
-
MASK_GREEN
static final int MASK_GREEN- See Also:
-
MASK_RED
static final int MASK_RED- See Also:
-
SHIFT_ALPHA
static final int SHIFT_ALPHA- See Also:
-
SHIFT_BLUE
static final int SHIFT_BLUE- See Also:
-
SHIFT_GREEN
static final int SHIFT_GREEN- See Also:
-
SHIFT_RED
static final int SHIFT_RED- See Also:
-
myImage
-
-
Constructor Details
-
ImageData
ImageData(BufferedImage image)
-
-
Method Details
-
copy
-
fromFrequencyDomain
Creates a new image, transforming the input (back) from the frequency domain to the spatial domain using the inverse discrete Fourier transform. The transformation also reverts the shift of the frequency representation – the input should be in a format as returned bytoFrequencyDomain(). The new image will be of the same dimensions as the input matrix.- See Also:
-
newColour
-
newColour
-
newGreyScale
-
newGreyScale
-
newTransformation
public static Transformation2D<ComplexNumber> newTransformation(ImageData.FrequencyDomainUpdater updater) Creates a new transformation that can be used to transform a matrix of complex numbers in the frequency domain. The transformation will invoke the updater for each element in the input matrix, passing the distance from the centre of the matrix as the first argument. The distance is scaled so that the radius of the largest circle that can fit in the image rectangle is 100. -
ofPowerSpectrum
Converts a matrix of complex numbers to an image of its power spectrum (log10 of the squared norms). In addition there is scaling applied to adapt the values towards the range [0,255].This is meant to be used with the output from
toFrequencyDomain()to get a visual representation of the frequency content of an image. -
read
-
read
-
wrap
-
getGaussianKernel
-
toRanged
static int toRanged(int value) -
applyGaussianBlur
Creates a new image (of the same type) blurring the input using a Gaussian blur kernel.- Parameters:
sigma- The standard deviation of the Gaussian blur kernel
-
byteValue
-
convertTo
Creates a new image, converting the input to the specified image type in the process.BufferedImage.TYPE_BYTE_GRAY,BufferedImage.TYPE_INT_ARGBor any other valid type... -
convertToGreyScale
- See Also:
-
countColumns
public long countColumns()Description copied from interface:Structure2DOnly need to implement if the structure may contain more than Integer.MAX_VALUE elements.- Specified by:
countColumnsin interfaceStructure2D- Returns:
- The number of columns
-
countRows
public long countRows()Description copied from interface:Structure2DOnly need to implement if the structure may contain more than Integer.MAX_VALUE elements.- Specified by:
countRowsin interfaceStructure2D- Returns:
- The number of rows
-
doubleValue
public double doubleValue(int row, int col) Description copied from interface:Access2DExtracts one element of this matrix as a double.- Specified by:
doubleValuein interfaceAccess2D<Double>- Specified by:
doubleValuein interfaceMatrixStore<Double>- Parameters:
row- A row index.col- A column index.- Returns:
- One matrix element
-
fillMatching
-
floatValue
public float floatValue(int row, int col) - Specified by:
floatValuein interfaceAccess2D<Double>
-
get
- Specified by:
getin interfaceMatrixStore<Double>
-
getColDim
public int getColDim()- Specified by:
getColDimin interfaceStructure2D- Returns:
- The number of columns
-
getImage
- Returns:
- The underlying
BufferedImage
-
getRowDim
public int getRowDim()- Specified by:
getRowDimin interfaceStructure2D- Returns:
- The number of rows
-
intValue
-
physical
- Specified by:
physicalin interfaceMatrixStore<Double>
-
resample
Will create a new image - the largest possible, with the same aspect ratio, that fits within the specified number of rows/columns (pixel height and width). Works well for both down-sampling and moderate up-sampling. -
set
-
set
-
set
-
set
-
set
-
sliceAlphaChannel
-
sliceBlueChannel
-
sliceGreenChannel
-
sliceRedChannel
-
toFrequencyDomain
Transforms the spatial representation of the image to its frequency representation using the discrete Fourier transform.In addition the frequency representation is shifted so that the zero frequency is in the centre of the image.
When you're done processing the frequency representation, you can transform it back to a spatial representation using
fromFrequencyDomain(MatrixStore). -
writeTo
The file format is derived from the file name ending (png, jpg...) -
writeTo
-
doubleValue
private double doubleValue(double row, double col) -
getARGB
protected int getARGB(int row, int col) -
setARGB
protected void setARGB(int row, int col, int argb)
-