ImagePyramid class
#include <FAST/Data/ImagePyramid.hpp>
Image pyramid data object.
Contents
Data object for storing large images as tiled image pyramids. Storage uses virtual memory enabling the images to be larger than the available RAM.
Base classes
- class SpatialDataObject
- Abstract base class for all spatial data objects.
Constructors, destructors, conversion operators
Public functions
- auto create(int width, int height, int channels, int patchWidth, int patchHeight, ImageCompression compression, int compressionQuality, DataType dataType, std::vector<float> levelDownsamples, std::vector<Vector2i> levelSizes) -> std::shared_ptr<ImagePyramid>
- Create a tiled image pyramid instance.
-
auto create(openslide_
t* fileHandle, std::vector<ImagePyramidLevel> levels) -> std::shared_ptr<ImagePyramid> - auto create(TIFF* fileHandle, std::vector<ImagePyramidLevel> levels, int channels, bool isOMETIFF) -> std::shared_ptr<ImagePyramid>
- auto getNrOfLevels() const -> int
- auto getLevelWidth(int level) const -> int
- auto getLevelHeight(int level) const -> int
- auto getLevelTileWidth(int level) -> int
- auto getLevelTileHeight(int level) -> int
- auto getLevelTilesX(int level) -> int
- auto getLevelTilesY(int level) -> int
- auto getLevelScale(int level) -> float
- auto getLevelForMagnification(float magnification) -> int
- Get level for a given magnification if it exists. Throws exception if a level for this magnification does not exist in the pyramid.
- auto getClosestLevelForMagnification(float magnification) -> std::pair<int, float>
- Get the closest level for a specific magnification.
- auto getFullWidth() -> int
- auto getFullHeight() -> int
- auto getWidth() const -> int
- auto getHeight() const -> int
- auto getLevelSizes() const -> std::vector<Vector2i>
- Get size (width and height) for each level in the image pyramid.
- auto getNrOfChannels() const -> int
- auto isBGRA() const -> bool
- auto usesTIFF() const -> bool
- auto isPyramidFullyInitialized() const -> bool
- Whether all patches in entire pyramid has been initialized.
- auto usesOpenSlide() const -> bool
- auto getTIFFPath() const -> std::string
- void setSpacing(Vector3f spacing)
- auto getSpacing() const -> Vector3f
-
auto getAccess(accessType type,
bool useTileCache = false,
int tileCacheSize = -1) -> ImagePyramidAccess::
pointer - auto getDirtyPatches() -> std::unordered_set<std::string>
- auto isDirtyPatch(const std::string& tileID) -> bool
- auto isOMETIFF() const -> bool
- void setDirtyPatch(int level, int patchIdX, int patchIdY)
- void clearDirtyPatches(std::set<std::string> patches)
-
void free(ExecutionDevice::
pointer device) override - void freeAll() override
- auto getTransformedBoundingBox() const -> DataBoundingBox override
- auto getBoundingBox() const -> DataBoundingBox override
- auto getCompression() const -> ImageCompression
- auto getCompressionQuality() const -> int
- void setCompressionModels(std::shared_ptr<NeuralNetwork> compressionModel, std::shared_ptr<NeuralNetwork> decompressionModel, float outputScaleFactor = 1.0f)
- void setCompressionModel(std::shared_ptr<NeuralNetwork> compressionModel)
- void setDecompressionModel(std::shared_ptr<NeuralNetwork> decompressionModel, float outputScaleFactor = 1.0f)
- auto getCompressionModel() const -> std::shared_ptr<NeuralNetwork>
- auto getDecompressionModel() const -> std::shared_ptr<NeuralNetwork>
- auto getDecompressionOutputScaleFactor() const -> float
- auto getDataType() const -> DataType
- auto getMagnification() const -> float
- Get magnification metadata Returns the magnification used to create the image pyramid if available. Throws exception if it is unknown. The magnification can also be set manually with ImagePyramid::
setMagnification() - void setMagnification(float magnification)
- Set magnification metadata.
Function documentation
std::shared_ptr<ImagePyramid> fast:: ImagePyramid:: create(int width,
int height,
int channels,
int patchWidth,
int patchHeight,
ImageCompression compression,
int compressionQuality,
DataType dataType,
std::vector<float> levelDownsamples,
std::vector<Vector2i> levelSizes)
Create a tiled image pyramid instance.
| Parameters | |
|---|---|
| width | Full width of image pyramid |
| height | Full height of image pyramid |
| channels | Nr of channels of image pyramid (3 == color (RGB), 1 == grayscale) |
| patchWidth | Width of each patch |
| patchHeight | Height of each patch |
| compression | Compression type to use when storing the data in the TIFF. |
| compressionQuality | Quality of compression when using lossy compression like JPEG and JPEGXL. 100 = best, 0 = worst. |
| dataType | Data type |
| levelDownsamples | If not specified an image pyramid with the default structure is used where each level is downsampled with a factor of 2 for each level until a level with smaller width or height than 1024 is reached. An alternative image pyramid structure can be achieved by specifying the downsampling factor for each level in this list. E.g. [4, 4] will create an image pyramid with 3 levels, level 0 with the original width and height. Level 1 with the size width/4, height/4, and level 2 with the size width/(4*4), height/(4*4). |
| levelSizes | If not specified an image pyramid with the default structure is used where each level is downsampled with a factor of 2 for each level until a level with smaller width or height than 1024 is reached. An alternative image pyramid structure can be achieved by specifying the exact sizes for each level in this list. If both levelDownsamples and levelSizes are provided, levelSizes is used. |
| Returns | instance |
Create a tiled image pyramid using TIFF.
int fast:: ImagePyramid:: getLevelForMagnification(float magnification)
Get level for a given magnification if it exists. Throws exception if a level for this magnification does not exist in the pyramid.
| Parameters | |
|---|---|
| magnification | Magnification amount (e.g. 40, 20, 10 etc.) |
| Returns | level |
std::pair<int, float> fast:: ImagePyramid:: getClosestLevelForMagnification(float magnification)
Get the closest level for a specific magnification.
| Parameters | |
|---|---|
| magnification | |
| Returns | pair of closest level and resampel factor |
Throws exception if image pyramid magnification is unknown. If level with this magnification does not exist in the pyramid, the closest level with a higher magnification is selected, and the resample factor is the magnification of this level divided by the target magnification. E.g. if you have an image pyramid at 40X magnification, and only levels corresponding to 40X and 10X. The closest level for 20X will be level 0, with a resample factor of 2.0, because to create 20X patches of size WxH, you have to get a patch of size resampleFactor*W x resampleFactor*H from level 0, and then resize to WxH.
std::vector<Vector2i> fast:: ImagePyramid:: getLevelSizes() const
Get size (width and height) for each level in the image pyramid.
| Returns | list of image pyramid level sizes |
|---|
float fast:: ImagePyramid:: getMagnification() const
Get magnification metadata Returns the magnification used to create the image pyramid if available. Throws exception if it is unknown. The magnification can also be set manually with ImagePyramid::
| Returns | magnification, e.g. 20 |
|---|
void fast:: ImagePyramid:: setMagnification(float magnification)
Set magnification metadata.
| Parameters | |
|---|---|
| magnification | |