Volume Cartographer 2.27.0
|
Volumetric image data. More...
#include <vc/core/types/Volume.hpp>
Public Types | |
using | Bounds = BoundingBox< double, 3 > |
using | Pointer = std::shared_ptr< Volume > |
using | SliceItem = std::pair< cv::Mat, std::optional< mmap_info > > |
using | SliceCache = Cache< int, SliceItem > |
using | DefaultCache = LRUCache< int, SliceItem, NoOpMutex > |
![]() | |
using | Identifier = std::string |
Identifier type. More... | |
using | Description = std::pair< Identifier, std::string > |
Public Member Functions | |
auto | sliceWidth () const -> int |
Get the slice width. | |
auto | sliceHeight () const -> int |
Get the slice height. | |
auto | numSlices () const -> int |
Get the number of slices. | |
auto | voxelSize () const -> double |
Get the voxel size (in microns) | |
auto | min () const -> double |
Get the minimum intensity value in the Volume. | |
auto | max () const -> double |
Get the maximum intensity value in the Volume. | |
void | setSliceWidth (int w) |
Set the expected width of the slice images. | |
void | setSliceHeight (int h) |
Set the expected height of the slice images. | |
void | setNumberOfSlices (std::size_t numSlices) |
Set the expected number of slice images. | |
void | setVoxelSize (double s) |
Set the voxel size (in microns) | |
void | setMin (double m) |
Set the minimum value in the Volume. | |
void | setMax (double m) |
Set the maximum value in the Volume. | |
auto | bounds () const -> Bounds |
Get the bounding box. | |
auto | isInBounds (double x, double y, double z) const -> bool |
Return whether a position is within the volume bounds. More... | |
auto | isInBounds (const cv::Vec3d &v) const -> bool |
void | setMemoryMapSlices (bool b) |
Whether to memory map slices rather than loading into memory. More... | |
auto | getSliceData (int index) const -> cv::Mat |
Get a slice by index number. More... | |
auto | getSliceDataCopy (int index) const -> cv::Mat |
Get a slice by index number. More... | |
void | setSliceData (int index, const cv::Mat &slice, bool compress=true) const |
Set a slice by index number. More... | |
auto | getSlicePath (int index) const -> filesystem::path |
Get the file path of a slice by index. | |
auto | intensityAt (int x, int y, int z) const -> std::uint16_t |
Get the intensity value at a voxel position. | |
auto | intensityAt (const cv::Vec3d &v) const -> std::uint16_t |
Get the intensity value at a voxel position. More... | |
auto | interpolateAt (double x, double y, double z) const -> std::uint16_t |
Get the intensity value at a subvoxel position. More... | |
auto | interpolateAt (const cv::Vec3d &v) const -> std::uint16_t |
Get the intensity value at a subvoxel position. More... | |
auto | reslice (const cv::Vec3d ¢er, const cv::Vec3d &xvec, const cv::Vec3d &yvec, int width=64, int height=64) const -> Reslice |
Create a Reslice image by intersecting the volume with a plane. More... | |
void | setCacheSlices (bool b) |
Enable slice caching. | |
void | setCache (SliceCache::Pointer c) const |
Set the slice cache. | |
void | setCacheCapacity (std::size_t newCacheCapacity) const |
Set the maximum number of cached slices. | |
void | setCacheMemoryInBytes (std::size_t nbytes) const |
Set the maximum size of the cache in bytes. | |
auto | getCacheCapacity () const -> std::size_t |
Get the maximum number of cached slices. | |
auto | getCacheSize () const -> std::size_t |
Get the current number of cached slices. | |
void | cachePurge () const |
Purge the slice cache. | |
![]() | |
DiskBasedObjectBaseClass ()=delete | |
Identifier | id () const |
Get the "unique" ID for the object. | |
auto | path () const -> filesystem::path |
Get the path to the object. | |
auto | name () const -> std::string |
Get the human-readable name for the object. | |
void | setName (std::string n) |
Set the human-readable name of the object. | |
template<typename T > | |
void | setMetadataEntry (const std::string &key, T value) |
Set a metadata entry. More... | |
template<typename T > | |
auto | getMetadataEntry (const std::string &key) const -> std::optional< T > |
Get a metadata entry. More... | |
void | saveMetadata () const |
Update metadata on disk. | |
Static Public Attributes | |
static constexpr std::size_t | DEFAULT_CAPACITY = 200 |
Protected Member Functions | |
cv::Mat | load_slice_ (int index, mmap_info *mmap_info=nullptr) const |
cv::Mat | cache_slice_ (int index) const |
![]() | |
DiskBasedObjectBaseClass (filesystem::path path) | |
DiskBasedObjectBaseClass (filesystem::path path, Identifier uuid, std::string name) | |
Protected Attributes | |
int | width_ {0} |
int | height_ {0} |
int | slices_ {0} |
int | numSliceCharacters_ {0} |
bool | cacheSlices_ {true} |
SliceCache::Pointer | cache_ {DefaultCache::New(DEFAULT_CAPACITY)} |
std::shared_mutex | cacheMutex_ |
std::vector< std::mutex > | sliceMutexes_ |
bool | memmap_ {true} |
![]() | |
Metadata | metadata_ |
filesystem::path | path_ |
Volume ()=delete | |
Volume (filesystem::path path) | |
Load the Volume from a directory path. | |
Volume (filesystem::path path, Identifier uuid, std::string name) | |
Make a new Volume at the specified path. | |
static auto | New (const filesystem::path &path) -> Pointer |
static auto | New (const filesystem::path &path, const Identifier &uuid, const std::string &name) -> Pointer |
Volumetric image data.
Provides access to a volumetric dataset, such as a CT scan. By default, slices are cached in memory using volcart::LRUCache.
Definition at line 34 of file Volume.hpp.
using volcart::Volume::Bounds = BoundingBox<double, 3> |
Bounding Box type
Definition at line 39 of file Volume.hpp.
using volcart::Volume::DefaultCache = LRUCache<int, SliceItem, NoOpMutex> |
Default slice cache type
Definition at line 51 of file Volume.hpp.
using volcart::Volume::Pointer = std::shared_ptr<Volume> |
Shared pointer type
Definition at line 42 of file Volume.hpp.
using volcart::Volume::SliceCache = Cache<int, SliceItem> |
Slice cache type
Definition at line 48 of file Volume.hpp.
using volcart::Volume::SliceItem = std::pair<cv::Mat, std::optional<mmap_info> > |
Slice item type
Definition at line 45 of file Volume.hpp.
|
delete |
Default constructor. Cannot be constructed without path.
|
protected |
Load slice from cache
auto volcart::Volume::getSliceData | ( | int | index | ) | const -> cv::Mat |
Get a slice by index number.
auto volcart::Volume::getSliceDataCopy | ( | int | index | ) | const -> cv::Mat |
Get a slice by index number.
auto volcart::Volume::intensityAt | ( | const cv::Vec3d & | v | ) | const -> std::uint16_t |
Get the intensity value at a voxel position.
auto volcart::Volume::interpolateAt | ( | const cv::Vec3d & | v | ) | const -> std::uint16_t |
Get the intensity value at a subvoxel position.
Values are trilinearly interpolated.
Trilinear interpolation equation from here.
auto volcart::Volume::interpolateAt | ( | double | x, |
double | y, | ||
double | z | ||
) | const -> std::uint16_t |
Get the intensity value at a subvoxel position.
Values are trilinearly interpolated.
Trilinear interpolation equation from here.
volcart::Volume::isInBounds | ( | double | x, |
double | y, | ||
double | z | ||
) | const -> bool |
Return whether a position is within the volume bounds.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
protected |
Load slice from disk
auto volcart::Volume::reslice | ( | const cv::Vec3d & | center, |
const cv::Vec3d & | xvec, | ||
const cv::Vec3d & | yvec, | ||
int | width = 64 , |
||
int | height = 64 |
||
) | const -> Reslice |
Create a Reslice image by intersecting the volume with a plane.
void volcart::Volume::setMemoryMapSlices | ( | bool | b | ) |
Whether to memory map slices rather than loading into memory.
When enabled, the Volume will attempt to memory map slice images rather than reading them into memory. This is currently only supported when slice caching is enabled as well.
Slices which are already cached will not be affected by this change.
void volcart::Volume::setSliceData | ( | int | index, |
const cv::Mat & | slice, | ||
bool | compress = true |
||
) | const |
Set a slice by index number.
Index must be less than the number of slices in the volume.
|
mutableprotected |
Slice cache
Definition at line 230 of file Volume.hpp.
|
mutableprotected |
Cache mutex for thread-safe access
Definition at line 232 of file Volume.hpp.
|
protected |
Whether to use slice cache
Definition at line 228 of file Volume.hpp.
|
staticconstexpr |
Default slice cache capacity
Definition at line 54 of file Volume.hpp.
|
protected |
Slice height
Definition at line 221 of file Volume.hpp.
|
protected |
Whether to memmap slices
Definition at line 238 of file Volume.hpp.
|
protected |
Slice file name padding
Definition at line 225 of file Volume.hpp.
|
mutableprotected |
Per-slice mutexes
Definition at line 235 of file Volume.hpp.
|
protected |
Number of slices
Definition at line 223 of file Volume.hpp.
|
protected |
Slice width
Definition at line 219 of file Volume.hpp.