A spatial region within an MSI dataset, in global pixel coordinates.
More...
#include <OpenMS/IMAGING/MSImagingRegion.h>
|
| const std::string & | getName () const |
| | Region name.
|
| |
| bool | contains (UInt x, UInt y) const |
| | Tests whether the global coordinate (x, y) is inside the region.
|
| |
| bool | intersects (const MSImagingRegion &other) const |
| | Tests whether this region's footprint geometrically overlaps other.
|
| |
| Shape | getShape () const |
| | Region shape (Rectangle or Mask).
|
| |
| Size | getId () const |
| | Region identifier.
|
| |
| UInt | getMinX () const |
| | Leftmost column of the global bounding box (inclusive).
|
| |
| UInt | getMinY () const |
| | Top row of the global bounding box (inclusive).
|
| |
| UInt | getMaxX () const |
| | Rightmost column of the global bounding box (inclusive).
|
| |
| UInt | getMaxY () const |
| | Bottom row of the global bounding box (inclusive).
|
| |
| UInt | getBBoxWidth () const |
| | Bounding box width in pixels (max_x - min_x + 1).
|
| |
| UInt | getBBoxHeight () const |
| | Bounding box height in pixels (max_y - min_y + 1).
|
| |
| const std::vector< bool > & | getMask () const |
| | Bbox-local row-major bitmask; empty for a Rectangle.
|
| |
| Size | area () const |
| | Number of pixels inside the region.
|
| |
|
| static MSImagingRegion | rectangle (Size id, const std::string &name, UInt min_x, UInt min_y, UInt max_x, UInt max_y) |
| | Creates a rectangular region spanning the inclusive bounding box.
|
| |
| static MSImagingRegion | fromMask (Size id, const std::string &name, UInt origin_x, UInt origin_y, UInt width, UInt height, std::vector< bool > mask) |
| | Creates a masked region from a row-major bitmask over a bounding box.
|
| |
A spatial region within an MSI dataset, in global pixel coordinates.
A region is a pure-geometry footprint, either an axis-aligned rectangular bounding box (Shape::Rectangle) or a per-pixel bitmask within a bounding box (Shape::Mask). It knows nothing about acquired pixels or spectra and is reusable as a bare footprint (e.g. a microscopy annotation). Construct via the rectangle() / fromMask() factories. Coordinates are zero-based and bounding boxes are inclusive on both ends.
◆ Shape
Discriminates how a region's footprint is represented.
| Enumerator |
|---|
| Rectangle | grid aligned bounding box (every cell inside the bbox is part of the region)
|
| Mask | per pixel bitmask inside the bounding box
|
◆ area()
Number of pixels inside the region.
- Returns
- Bounding-box area for a Rectangle, set-bit count (popcount) for a Mask.
◆ contains()
Tests whether the global coordinate (x, y) is inside the region.
- Parameters
-
| [in] | x | Column index (zero-based). |
| [in] | y | Row index (zero-based). |
- Returns
- true if (
x, y) lies within the footprint (bbox for a Rectangle, a set bit for a Mask).
◆ fromMask()
Creates a masked region from a row-major bitmask over a bounding box.
The global bounding box is [origin_x, origin_x + width - 1] x [origin_y, origin_y + height - 1]; mask is stored bbox-local.
- Parameters
-
| [in] | id | Region identifier. |
| [in] | name | Human-readable region name. |
| [in] | origin_x | Leftmost column of the bounding box (zero-based). |
| [in] | origin_y | Top row of the bounding box (zero-based). |
| [in] | width | Bounding box width in pixels. |
| [in] | height | Bounding box height in pixels. |
| [in] | mask | Row-major bitmask (true = inside), size == width * height. |
- Returns
- A region with Shape::Mask.
- Exceptions
-
◆ getBBoxHeight()
| UInt getBBoxHeight |
( |
| ) |
const |
Bounding box height in pixels (max_y - min_y + 1).
- Returns
- Bounding box height.
◆ getBBoxWidth()
| UInt getBBoxWidth |
( |
| ) |
const |
Bounding box width in pixels (max_x - min_x + 1).
- Returns
- Bounding box width.
◆ getId()
Region identifier.
- Returns
- The stored id.
◆ getMask()
| const std::vector< bool > & getMask |
( |
| ) |
const |
Bbox-local row-major bitmask; empty for a Rectangle.
- Returns
- Reference to the mask (branch on getShape() before use).
◆ getMaxX()
Rightmost column of the global bounding box (inclusive).
- Returns
- max x.
◆ getMaxY()
Bottom row of the global bounding box (inclusive).
- Returns
- max y.
◆ getMinX()
Leftmost column of the global bounding box (inclusive).
- Returns
- min x.
◆ getMinY()
Top row of the global bounding box (inclusive).
- Returns
- min y.
◆ getName()
| const std::string & getName |
( |
| ) |
const |
Region name.
- Returns
- Reference to the stored name.
◆ getShape()
Region shape (Rectangle or Mask).
- Returns
- The shape discriminator.
◆ intersects()
Tests whether this region's footprint geometrically overlaps other.
Symmetric and independent of any acquired pixels: returns true iff some global coordinate lies inside both footprints.
- Parameters
-
| [in] | other | The other region. |
- Returns
- true if the footprints share at least one coordinate.
◆ rectangle()
Creates a rectangular region spanning the inclusive bounding box.
- Parameters
-
| [in] | id | Region identifier. |
| [in] | name | Human-readable region name. |
| [in] | min_x | Leftmost column (inclusive, zero-based). |
| [in] | min_y | Top row (inclusive, zero-based). |
| [in] | max_x | Rightmost column (inclusive, zero-based). |
| [in] | max_y | Bottom row (inclusive, zero-based). |
- Returns
- A region with Shape::Rectangle.
- Exceptions
-
◆ id_
◆ mask_
◆ max_x_
◆ max_y_
◆ min_x_
◆ min_y_
◆ name_
◆ shape_