Class BasicConvolution
- All Implemented Interfaces:
Cloneable
,ArrayProcessor
,ArrayProcessorWithContextSwitching
,Convolution
-
Field Summary
Fields inherited from class net.algart.matrices.linearfiltering.AbstractConvolution
incrementByHalfForInteger, incrementForUnsigned
-
Method Summary
Modifier and TypeMethodDescriptionasConvolution
(Class<? extends T> requiredType, Matrix<? extends PArray> src, WeightedPattern pattern) Returns an immutable view of the passed source matrix, such that any reading data from it calculates and returns the convolution of the source matrix by the specified pattern.static BasicConvolution
Returns new instance of this class, correcting unsigned convolutions results.static BasicConvolution
getInstance
(ArrayContext context, boolean incrementByHalfForInteger) Returns new instance of this class.boolean
Returns true, if this class works in the defaultpseudo-cyclic continuation mode
.Methods inherited from class net.algart.matrices.linearfiltering.AbstractConvolution
asConvolution, context, convolution, convolution, convolution, increment
Methods inherited from class net.algart.arrays.AbstractArrayProcessorWithContextSwitching
context, contextPart, memoryModel
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.algart.arrays.ArrayProcessor
context
Methods inherited from interface net.algart.matrices.linearfiltering.Convolution
asConvolution, context, convolution, convolution, convolution, increment
-
Method Details
-
getInstance
Returns new instance of this class.- Parameters:
context
- thecontext
that will be used by this object; may be null, then it will be ignored.incrementByHalfForInteger
- if true, when the type of the convolution result is integer, the precise result is automatically increments by 0.5 before casting.- Returns:
- new instance of this class.
-
getCorrectingUnsignedInstance
Returns new instance of this class, correcting unsigned convolutions results. If the type of the convolution result is an unsigned number in terms of AlgART libraries — byte, short, char — it is automatically incremented by 128 (byte) or 32768 (short and char).- Parameters:
context
- thecontext
that will be used by this object; may be null, then it will be ignored.- Returns:
- new instance of this class.
-
isPseudoCyclic
public boolean isPseudoCyclic()Description copied from interface:Convolution
Returns true, if this class works in the defaultpseudo-cyclic continuation mode
.More precisely, it means that when the value in some element of the processed matrix, returned by a method of this class, depends on elements of the source matrix, lying outside its bounds, then it is supposed that the values outside the source matrix are calculated as described in
Matrix.ContinuationMode.PSEUDO_CYCLIC
. Exactly such behaviour is specified in the comments to theConvolution.convolution(Matrix, WeightedPattern)
method as the default definition of convolution.This method returns true in
BasicConvolution
implementation. However, it usually returns false inContinuedConvolution
class — excepting the only degenerated case when the usedcontinuation mode
isPSEUDO_CYCLIC
.- Specified by:
isPseudoCyclic
in interfaceConvolution
- Specified by:
isPseudoCyclic
in classAbstractConvolution
- Returns:
- whether this class works in the pseudo-cyclic continuation mode.
-
asConvolution
public <T extends PArray> Matrix<T> asConvolution(Class<? extends T> requiredType, Matrix<? extends PArray> src, WeightedPattern pattern) Description copied from interface:Convolution
Returns an immutable view of the passed source matrix, such that any reading data from it calculates and returns the convolution of the source matrix by the specified pattern. SeeConvolution.convolution(Class, Matrix, WeightedPattern)
method about the "convolution" term.The matrix, returned by this method, is immutable, and the class of its built-in array implements one of the basic interfaces
BitArray
,CharArray
,ByteArray
,ShortArray
,IntArray
,LongArray
,FloatArray
orDoubleArray
. The class of desired interface (one of 8 possible classes) must be passed as requiredType argument. So, it defines the element type of the returned matrix. For example, if requiredType=ByteArray
.class, the returned matrix consists of byte elements. The rules of casting the real numbers, results of the convolution, to the desired element type are the same as inArrays.asFuncArray(boolean, net.algart.math.functions.Func, Class, PArray...)
method with the argument truncateOverflows=true.The result is usually "lazy", that means that this method finishes immediately and all actual calculations are performed while getting elements of the returned matrix. It is true for all implementations provided by this package. However, some implementations may not support lazy dilation; then this method will be equivalent to
Convolution.convolution(Class, Matrix, WeightedPattern)
.Please note: this method does not require time, but the resulting matrix can work slowly! for example, reading all its content than work much slower than
Convolution.convolution(Class, Matrix, WeightedPattern)
method for some complex patterns. Usually you should use it only for very little patterns, or if you know that the implementation of this interface does not provide better algorithm for non-"lazy"Convolution.convolution(Class, Matrix, WeightedPattern)
method.- Specified by:
asConvolution
in interfaceConvolution
- Specified by:
asConvolution
in classAbstractConvolution
- Parameters:
requiredType
- desired type of the built-in array in the returned matrix.src
- the source matrix.pattern
- the pattern.- Returns:
- the "lazy" matrix containing the convolution of the source matrix with the given pattern.
-