OpenMS
Loading...
Searching...
No Matches
MSImagingRegion.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg$
6// $Authors: Patrick Boschmann$
7// --------------------------------------------------------------------------
8
9#pragma once
10
13
14#include <string>
15#include <vector>
16
17namespace OpenMS
18{
29class OPENMS_DLLAPI MSImagingRegion final
30{
31public:
33 enum class Shape
34 {
35 Rectangle,
36 Mask
37 };
38
50 static MSImagingRegion rectangle(Size id, const std::string& name, UInt min_x, UInt min_y, UInt max_x, UInt max_y);
51
68 static MSImagingRegion fromMask(Size id, const std::string& name, UInt origin_x, UInt origin_y, UInt width, UInt height, std::vector<bool> mask);
69
72 const std::string& getName() const;
73
81 bool contains(UInt x, UInt y) const;
82
91 bool intersects(const MSImagingRegion& other) const;
92
95 Shape getShape() const;
96
99 Size getId() const;
100
103 UInt getMinX() const;
106 UInt getMinY() const;
109 UInt getMaxX() const;
112 UInt getMaxY() const;
113
120
123 const std::vector<bool>& getMask() const;
124
127 Size area() const;
128
129private:
130 Size id_ {0};
131 Shape shape_ = Shape::Rectangle;
132 std::string name_;
133 std::vector<bool> mask_; // empty if shape_ is set, otherwise rect is bounding box
134 UInt min_x_ {0};
135 UInt min_y_ {0};
136 UInt max_x_ {0};
137 UInt max_y_ {0};
138};
139} // namespace OpenMS
A spatial region within an MSI dataset, in global pixel coordinates.
Definition MSImagingRegion.h:30
Shape getShape() const
Region shape (Rectangle or Mask).
const std::string & getName() const
Region name.
UInt getBBoxWidth() const
Bounding box width in pixels (max_x - min_x + 1).
std::string name_
Definition MSImagingRegion.h:132
Shape
Discriminates how a region's footprint is represented.
Definition MSImagingRegion.h:34
bool intersects(const MSImagingRegion &other) const
Tests whether this region's footprint geometrically overlaps other.
UInt getMinX() const
Leftmost column of the global bounding box (inclusive).
std::vector< bool > mask_
Definition MSImagingRegion.h:133
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.
Size getId() const
Region identifier.
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.
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.
UInt getMinY() const
Top row of the global bounding box (inclusive).
UInt getMaxY() const
Bottom row of the global bounding box (inclusive).
UInt getMaxX() const
Rightmost column of the global bounding box (inclusive).
bool contains(UInt x, UInt y) const
Tests whether the global coordinate (x, y) is inside the region.
unsigned int UInt
Unsigned integer type.
Definition Types.h:64
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19