Class AbstractPlanePyramidSource
- All Implemented Interfaces:
PlanePyramidSource
- Direct Known Subclasses:
DefaultPlanePyramidSource,ExtendingPlanePyramidSource
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumprotected final classNested classes/interfaces inherited from interface net.algart.matrices.maps.pyramids.io.api.PlanePyramidSource
PlanePyramidSource.AveragingMode, PlanePyramidSource.FlushMode, PlanePyramidSource.SpecialImageKind -
Field Summary
Fields inherited from interface net.algart.matrices.maps.pyramids.io.api.PlanePyramidSource
DEFAULT_COMPRESSION, DEFAULT_MINIMAL_PYRAMID_SIZE, DEFAULT_TILE_DIM, DIM_BAND, DIM_HEIGHT, DIM_WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract intfinal voidcheckSubMatrixRanges(int resolutionLevel, long fromX, long fromY, long toX, long toY, boolean require31BitSize) static voidcheckSubMatrixRanges(long[] dimensions, long fromX, long fromY, long toX, long toY, boolean require31BitSize) intnet.algart.arrays.Matrix<? extends net.algart.arrays.PArray>constantMatrixSkippingFiller(Class<?> elementType, long dimX, long dimY) static List<net.algart.math.IRectangularArea>abstract longdim(int resolutionLevel, int index) Returns the dimension #index of the given pyramid level.abstract long[]dimensions(int resolutionLevel) Returns dimensions of any pyramid level.final voidClass<?>final voidenableTileCaching(AbstractPlanePyramidSource.TileDirection tileDirection) voidfillBySkippingFiller(net.algart.arrays.Matrix<? extends net.algart.arrays.UpdatablePArray> matrix, boolean fillWhenZero) voidfreeResources(PlanePyramidSource.FlushMode flushMode) This implementation frees the tile cache.final Colorfinal net.algart.arrays.MemoryModelboolean[]final doublefinal longReturns the size in bytes of the cache, used whenisTileCachingEnabled().booleanReturns true if the data at all available levels of this source are available.booleanReturns true ifPlanePyramidSource.elementType()method works properly.booleanisResolutionLevelAvailable(int resolutionLevel) final booleanEnforces some plane pyramid sources to skip (usually to stay zero) coarse data, which should not be processed by image processing algorithms, likePlanePyramidSource.SpecialImageKind.WHOLE_SLIDE.booleanReturns true if this special image kind is provided by current format.final booleanvoidThis implementation does nothing.protected final net.algart.arrays.Matrix<? extends net.algart.arrays.PArray>protected final net.algart.arrays.Matrix<net.algart.arrays.UpdatablePArray>newFilledResultMatrix(long dimX, long dimY, Color backgroundColor) protected final net.algart.arrays.Matrix<net.algart.arrays.UpdatablePArray>newResultMatrix(long dimX, long dimY) abstract intnet.algart.arrays.Matrix<? extends net.algart.arrays.PArray>readFullMatrix(int resolutionLevel) protected intReturns the size (width and height) of a tile, used for cache (whenisTileCachingEnabled()and for splitting large submatrix for reading into smaller tiles, read byreadLittleSubMatrix(int, long, long, long, long).protected abstract net.algart.arrays.Matrix<? extends net.algart.arrays.PArray>readLittleSubMatrix(int resolutionLevel, long fromX, long fromY, long toX, long toY) Optional<net.algart.arrays.Matrix<? extends net.algart.arrays.PArray>>Reads special image according specified kind.net.algart.arrays.Matrix<? extends net.algart.arrays.PArray>readSubMatrix(int resolutionLevel, long fromX, long fromY, long toX, long toY) final voidsetLabelRotation(RotatingPlanePyramidSource.RotationMode labelRotation) final voidsetLabelRotationBackground(Color labelRotationBackground) final voidsetMemoryModel(net.algart.arrays.MemoryModel memoryModel) final voidsetSkipCoarseData(boolean skipCoarseData) final voidsetSkippingFiller(double skippingFiller) final voidsetTileCachingMemory(long tileCachingMemory) static longwholeSlideDimX(long mapDimX, long mapDimY, long labelDimX, long labelDimY) Returns a set of all areas, filled by actual data, at the zero level, in a form of a list of polygons, represented by their consecutive vertices.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.algart.matrices.maps.pyramids.io.api.PlanePyramidSource
height, isFullMatrixSupported, magnification, metadata, pixelSizeInMicrons, width, zeroLevelActualRectangles
-
Constructor Details
-
AbstractPlanePyramidSource
protected AbstractPlanePyramidSource()
-
-
Method Details
-
getMemoryModel
public final net.algart.arrays.MemoryModel getMemoryModel() -
setMemoryModel
public final void setMemoryModel(net.algart.arrays.MemoryModel memoryModel) -
isSkipCoarseData
public final boolean isSkipCoarseData()Enforces some plane pyramid sources to skip (usually to stay zero) coarse data, which should not be processed by image processing algorithms, likePlanePyramidSource.SpecialImageKind.WHOLE_SLIDE.- Returns:
- the flag; false by default.
-
setSkipCoarseData
public final void setSkipCoarseData(boolean skipCoarseData) -
getSkippingFiller
public final double getSkippingFiller() -
setSkippingFiller
public final void setSkippingFiller(double skippingFiller) -
numberOfResolutions
public abstract int numberOfResolutions()- Specified by:
numberOfResolutionsin interfacePlanePyramidSource
-
compression
public int compression()- Specified by:
compressionin interfacePlanePyramidSource
-
bandCount
public abstract int bandCount()- Specified by:
bandCountin interfacePlanePyramidSource
-
isResolutionLevelAvailable
public boolean isResolutionLevelAvailable(int resolutionLevel) - Specified by:
isResolutionLevelAvailablein interfacePlanePyramidSource
-
getResolutionLevelsAvailability
public boolean[] getResolutionLevelsAvailability()- Specified by:
getResolutionLevelsAvailabilityin interfacePlanePyramidSource
-
dimensions
Description copied from interface:PlanePyramidSourceReturns dimensions of any pyramid level. Number of elements in the result arrays is always 3:
- first element result[0] is always equal to
PlanePyramidSource.bandCount(); - the element result[
PlanePyramidSource.DIM_WIDTH] is the x-dimension of the level in pixels; - the element result[
PlanePyramidSource.DIM_HEIGHT] is the y-dimension of the level in pixels.
This method always returns a new Java array and never returns a reference to an internal field.
- Specified by:
dimensionsin interfacePlanePyramidSource- Parameters:
resolutionLevel- the level of pyramid; zero level (resolutionLevel=0) corresponds to the best resolution.- Returns:
- dimensions of the specified pyramid level.
- Throws:
NoSuchElementException- if !isResolutionLevelAvailable(resolutionLevel)
- first element result[0] is always equal to
-
dim
public abstract long dim(int resolutionLevel, int index) Description copied from interface:PlanePyramidSourceReturns the dimension #index of the given pyramid level. Equivalent todimensions(resolutionLevel)[index], but works faster.- Specified by:
dimin interfacePlanePyramidSourceindex- the index of dimension.- Returns:
- the dimension #index of this level.
-
isElementTypeSupported
public boolean isElementTypeSupported()Description copied from interface:PlanePyramidSourceReturns true ifPlanePyramidSource.elementType()method works properly. In other case, that method throws UnsupportedOperationException. In particular, returns true inDefaultPlanePyramidSource.- Specified by:
isElementTypeSupportedin interfacePlanePyramidSource- Returns:
- whether
PlanePyramidSource.elementType()is supported.
-
elementType
- Specified by:
elementTypein interfacePlanePyramidSource- Throws:
UnsupportedOperationException
-
zeroLevelActualAreaBoundaries
Description copied from interface:PlanePyramidSourceReturns a set of all areas, filled by actual data, at the zero level, in a form of a list of polygons, represented by their consecutive vertices. All other areas should be considered to be a background and may be not passed to image analysis algorithms.
More precisely, each element P of the returned list, i.e. List<List<IPoint>>, corresponds to one connected 2D polygon. The structure of this element P is the following:
- P.get(0) is the list of sequential vertices of the polygon; each vertex appears in this list only once;
- P.get(1), P.get(2), ..., P.get(m), where m=P.size() describe sequential vertices of all polygonal holes, that may appear in the polygon. If the polygon has no holes (very probable case) or if their detection is not supported, the list P contains only 1 element (m=1).
The default implementation in
AbstractPlanePyramidSourcecallsPlanePyramidSource.zeroLevelActualRectangles()and converts each rectangle to the list P, containing only 1 element, and this element is the list of 4 vertices of the rectangle. IfPlanePyramidSource.zeroLevelActualRectangles()returns null, the default implementation also returns null.- Specified by:
zeroLevelActualAreaBoundariesin interfacePlanePyramidSource- Returns:
- the list of all polygonal areas, filled by actual data, at the level #0, and their holes (if they exist), or null if this ability is not supported.
-
readSubMatrix
public net.algart.arrays.Matrix<? extends net.algart.arrays.PArray> readSubMatrix(int resolutionLevel, long fromX, long fromY, long toX, long toY) throws NoSuchElementException, NotYetConnectedException - Specified by:
readSubMatrixin interfacePlanePyramidSource- Throws:
NoSuchElementExceptionNotYetConnectedException
-
readFullMatrix
public net.algart.arrays.Matrix<? extends net.algart.arrays.PArray> readFullMatrix(int resolutionLevel) throws NoSuchElementException, NotYetConnectedException, UnsupportedOperationException - Specified by:
readFullMatrixin interfacePlanePyramidSource- Throws:
NoSuchElementExceptionNotYetConnectedExceptionUnsupportedOperationException
-
isSpecialMatrixSupported
Description copied from interface:PlanePyramidSourceReturns true if this special image kind is provided by current format.Default implementation in AbstractPlanePyramidSource return false.
- Specified by:
isSpecialMatrixSupportedin interfacePlanePyramidSource- Parameters:
kind- the kind of special image.- Returns:
- whether this kind is supported; false by default.
-
readSpecialMatrix
public Optional<net.algart.arrays.Matrix<? extends net.algart.arrays.PArray>> readSpecialMatrix(PlanePyramidSource.SpecialImageKind kind) throws NotYetConnectedException Description copied from interface:PlanePyramidSourceReads special image according specified kind.If the argument is
PlanePyramidSource.SpecialImageKind.NONE, return null. In all other cases returns some non-null result.If there is no appropriate image, returns
Optional.empty()..- Specified by:
readSpecialMatrixin interfacePlanePyramidSource- Parameters:
kind- what special image is requested.- Returns:
- special image or
Optional.empty()if this kind is not supported. - Throws:
NotYetConnectedException
-
isDataReady
public boolean isDataReady()Description copied from interface:PlanePyramidSourceReturns true if the data at all available levels of this source are available. In other case,PlanePyramidSource.readSubMatrix(int, long, long, long, long)andPlanePyramidSource.readFullMatrix(int)method can throw NotYetConnectedException (but also, maybe, work properly),Note: all other methods, including
PlanePyramidSource.dimensions(int), must work without NotYetConnectedException even if this method returns false.- Specified by:
isDataReadyin interfacePlanePyramidSource- Returns:
- whether the data at all available levels of this source are available.
-
loadResources
public void loadResources()This implementation does nothing.If your implementation overrides this method, it must call super.loadResources at the end — because it is possible that future version will do something useful.
- Specified by:
loadResourcesin interfacePlanePyramidSource
-
freeResources
This implementation frees the tile cache.- Specified by:
freeResourcesin interfacePlanePyramidSource- Parameters:
flushMode- possible strategy of freeing resources (ignored by this implementation).
-
fillBySkippingFiller
public void fillBySkippingFiller(net.algart.arrays.Matrix<? extends net.algart.arrays.UpdatablePArray> matrix, boolean fillWhenZero) -
constantMatrixSkippingFiller
public net.algart.arrays.Matrix<? extends net.algart.arrays.PArray> constantMatrixSkippingFiller(Class<?> elementType, long dimX, long dimY) -
isTileCachingEnabled
public final boolean isTileCachingEnabled() -
getTileCacheDirection
-
enableTileCaching
-
disableTileCaching
public final void disableTileCaching() -
getTileCachingMemory
public final long getTileCachingMemory()Returns the size in bytes of the cache, used whenisTileCachingEnabled(). The real amount memory, used by this instance of this class, can me little greater (approximately by the size of 1 tile).The initial value is retrieved from the system property "net.algart.matrices.maps.pyramids.io.maxNonTiledReadingDim", if it exists and contains a valid integer number. If there is no such property, or if it contains not a number, or if some exception occurred while calling Long.getLong, the default value 67108864 (64 MB) is used.
- Returns:
- the amount of memory in bytes, which is allowed to use for caching by this instance.
-
setTileCachingMemory
public final void setTileCachingMemory(long tileCachingMemory) -
getLabelRotation
-
setLabelRotation
-
getLabelRotationBackground
-
setLabelRotationBackground
-
checkSubMatrixRanges
public final void checkSubMatrixRanges(int resolutionLevel, long fromX, long fromY, long toX, long toY, boolean require31BitSize) -
readingTileDim
protected int readingTileDim()Returns the size (width and height) of a tile, used for cache (whenisTileCachingEnabled()and for splitting large submatrix for reading into smaller tiles, read byreadLittleSubMatrix(int, long, long, long, long).The default implementation retrieves the value from the system property "net.algart.matrices.maps.pyramids.io.tileCachingMemory", if it exists and contains a valid integer number. If there is no such property, or if it contains not a number, or if some exception occurred while calling Long.getLong, this method returns the default value 4096.
The result must be positive.
The result must be stable (constant) for the given instance.
This method must work quickly.
- Returns:
- the width/height of tiles for caching and splitting large read submatrix.
-
readLittleSubMatrix
protected abstract net.algart.arrays.Matrix<? extends net.algart.arrays.PArray> readLittleSubMatrix(int resolutionLevel, long fromX, long fromY, long toX, long toY) throws NoSuchElementException, NotYetConnectedException -
makeWholeSlideFromLabelAndMap
protected final net.algart.arrays.Matrix<? extends net.algart.arrays.PArray> makeWholeSlideFromLabelAndMap(AbstractPlanePyramidSource.LabelPosition labelPosition) -
newResultMatrix
protected final net.algart.arrays.Matrix<net.algart.arrays.UpdatablePArray> newResultMatrix(long dimX, long dimY) -
newFilledResultMatrix
protected final net.algart.arrays.Matrix<net.algart.arrays.UpdatablePArray> newFilledResultMatrix(long dimX, long dimY, Color backgroundColor) -
defaultZeroLevelActualRectangles
public static List<net.algart.math.IRectangularArea> defaultZeroLevelActualRectangles(PlanePyramidSource source) -
checkSubMatrixRanges
public static void checkSubMatrixRanges(long[] dimensions, long fromX, long fromY, long toX, long toY, boolean require31BitSize) -
wholeSlideDimX
public static long wholeSlideDimX(long mapDimX, long mapDimY, long labelDimX, long labelDimY)
-