Volume Cartographer 2.27.0
|
A raster of a UVMap that provides a per-pixel mapping between a Volume and a Texture generated from that volume. More...
#include <vc/core/types/PerPixelMap.hpp>
Classes | |
struct | Coord2D |
struct | PixelMap |
Public Types | |
using | Pointer = std::shared_ptr< PerPixelMap > |
Public Member Functions | |
auto | operator() (std::size_t y, std::size_t x) const -> const cv::Vec6d & |
Get the mapping for a pixel by x, y coordinate. | |
auto | operator() (std::size_t y, std::size_t x) -> cv::Vec6d & |
Get the mapping for a pixel by x, y coordinate. More... | |
auto | getMapping (std::size_t y, std::size_t x) const -> const cv::Vec6d & |
Get the mapping for a pixel by x, y coordinate. More... | |
auto | getMapping (std::size_t y, std::size_t x) -> cv::Vec6d & |
Get the mapping for a pixel by x, y coordinate. More... | |
auto | hasMapping (std::size_t y, std::size_t x) const -> bool |
Return whether there is a mapping for the pixel at x, y. More... | |
auto | getAsPixelMap (std::size_t y, std::size_t x) -> PixelMap |
Get the mapping for a pixel as a PixelMap. | |
auto | getMappings () const -> std::vector< PixelMap > |
Get a list of valid pixel mappings. More... | |
auto | getMappingCoords () const -> std::vector< Coord2D > |
Get a list of pixel coordinates with valid mappings. More... | |
auto | numMappings () const -> std::size_t |
Get the number of valid mappings. More... | |
void | setDimensions (std::size_t h, std::size_t w) |
Set the dimensions of the map. More... | |
void | setWidth (std::size_t w) |
Set the width of the map. More... | |
void | setHeight (std::size_t h) |
Set the height of the map. More... | |
auto | width () const -> std::size_t |
Get the width of the map. | |
auto | height () const -> std::size_t |
Get the height of the map. | |
auto | mask () const -> cv::Mat |
Get the pixel mask. | |
void | setMask (const cv::Mat &m) |
Set the pixel mask. More... | |
auto | cellMap () const -> cv::Mat |
Get the cell map image. More... | |
void | setCellMap (const cv::Mat &m) |
Set the cell map image. More... | |
Static Public Member Functions | |
static auto | Crop (const PerPixelMap &map, std::size_t originY, std::size_t originX, std::size_t height, std::size_t width) -> PerPixelMap |
Create a cropped PPM. | |
static void | WritePPM (const filesystem::path &path, const PerPixelMap &map) |
Write a PerPixelMap to disk. | |
static auto | ReadPPM (const filesystem::path &path) -> PerPixelMap |
Read a PerPixelMap from disk. | |
Private Member Functions | |
void | initialize_map_ () |
Private Attributes | |
std::size_t | height_ {0} |
std::size_t | width_ {0} |
OrderedPointSet< cv::Vec6d > | map_ |
cv::Mat | mask_ |
cv::Mat | cellMap_ |
PerPixelMap ()=default | |
Default constructor. | |
PerPixelMap (std::size_t height, std::size_t width) | |
Constructor with width and height parameters. | |
auto | initialized () const -> bool |
Return whether the PerPixelMap has been initialized. More... | |
template<typename... Args> | |
static auto | New (Args... args) -> Pointer |
A raster of a UVMap that provides a per-pixel mapping between a Volume and a Texture generated from that volume.
After a segmentation mesh is flattened, the resulting UV space is sampled at a specific resolution in order to generate a texture space (e.g. image). A texturing algorithm is responsible for filtering information from the volume and placing it into this space, the intended result being an image of a manuscript's text. The transformation that maps 2D coordinates in texture space to 3D coordinates in volume space is defined by the per-vertex transformation generated by flattening, however, there are numerous ways that the points between vertices can be mapped back into the volume. Since the calculation of this mapping can be expensive, it is often desirable to perform this operation only once.
The PerPixelMap (PPM) provides a method for storing the result of this calculation. It has the same dimensions as texture space, and each pixel holds the mapped, 3D position for that pixel in volume space. It additionally holds 3 extra double
elements, typically used to store the surface normal vector for the 3D position (calculated from the segmentation mesh).
The position and normal vector are stored in a cv::Vec6d
: {x, y, z, nx, ny, nz}
.
The texturing::PPMGenerator class generates a PerPixelMap by mapping pixels through the barycentric coordinates of the mesh's triangular faces.
Definition at line 49 of file PerPixelMap.hpp.
using volcart::PerPixelMap::Pointer = std::shared_ptr<PerPixelMap> |
Pointer type
Definition at line 84 of file PerPixelMap.hpp.
auto volcart::PerPixelMap::cellMap | ( | ) | const -> cv::Mat |
Get the cell map image.
The cell map contains the face assignment for each pixel in the PPM. This is an optional feature, and older PPMs may not make this information available.
auto volcart::PerPixelMap::getMapping | ( | std::size_t | y, |
std::size_t | x | ||
) | -> cv::Vec6d & |
Get the mapping for a pixel by x, y coordinate.
auto volcart::PerPixelMap::getMapping | ( | std::size_t | y, |
std::size_t | x | ||
) | const -> const cv::Vec6d & |
Get the mapping for a pixel by x, y coordinate.
auto volcart::PerPixelMap::getMappingCoords | ( | ) | const -> std::vector< Coord2D > |
Get a list of pixel coordinates with valid mappings.
Convenience function for accessing PPM data as pixel coordinates.
Unlike getMappings(), this function only returns the pixel coordinates which have mappings. Use this function with getMapping() or getAsPixelMap() in high-performance loops:
auto volcart::PerPixelMap::getMappings | ( | ) | const -> std::vector< PixelMap > |
Get a list of valid pixel mappings.
Convenience function for accessing PPM data as logical pixels with position and normal values. Valid mappings are determined by the PPM's mask.
auto volcart::PerPixelMap::hasMapping | ( | std::size_t | y, |
std::size_t | x | ||
) | const -> bool |
Return whether there is a mapping for the pixel at x, y.
Returns true
is the pixel mask has not been set or is empty
|
private |
Initialize the map for value assignment
Does nothing if either the height or width are 0.
auto volcart::PerPixelMap::initialized | ( | ) | const -> bool |
Return whether the PerPixelMap has been initialized.
The map is initialized as soon as its width and height have been set.
|
inlinestatic |
Static New function for all constructors of T
Definition at line 95 of file PerPixelMap.hpp.
auto volcart::PerPixelMap::numMappings | ( | ) | const -> std::size_t |
Get the number of valid mappings.
Valid mappings are determined by the number of non-zero pixels in the PPM's mask. If the mask is not set, all pixels are valid.
auto volcart::PerPixelMap::operator() | ( | std::size_t | y, |
std::size_t | x | ||
) | -> cv::Vec6d & |
Get the mapping for a pixel by x, y coordinate.
void volcart::PerPixelMap::setCellMap | ( | const cv::Mat & | m | ) |
Set the cell map image.
The cell map contains the face assignment for each pixel in the PPM. This is an optional feature, and older PPMs may not make this information available.
void volcart::PerPixelMap::setDimensions | ( | std::size_t | h, |
std::size_t | w | ||
) |
Set the dimensions of the map.
void volcart::PerPixelMap::setHeight | ( | std::size_t | h | ) |
Set the height of the map.
void volcart::PerPixelMap::setMask | ( | const cv::Mat & | m | ) |
Set the pixel mask.
If the pixel mask is not set or is empty, every pixel is assumed to have a mapping.
Not every pixel in the PerPixelMap will have a mapped value. The pixel mask is an 8bpc, single channel image that indicates which pixels do and do not have mappings. 0 = No mapping, 255 = Has mapping.
void volcart::PerPixelMap::setWidth | ( | std::size_t | w | ) |
Set the width of the map.
|
private |
Cell map
Definition at line 275 of file PerPixelMap.hpp.
|
private |
Height of the map
Definition at line 260 of file PerPixelMap.hpp.
|
private |
Map data storage
Definition at line 264 of file PerPixelMap.hpp.
|
private |
Pixel mask
The pixel mask is an 8bpc, single channel image that indicates which pixels do and do not have mappings. 0 = No mapping, 255 = Has mapping.
Definition at line 272 of file PerPixelMap.hpp.
|
private |
Width of the map
Definition at line 262 of file PerPixelMap.hpp.