13 #ifndef ML_SUB_IMAGE_BOX_H
14 #define ML_SUB_IMAGE_BOX_H
104 return (v1==box.
v1) && (v2==box.
v2);
110 return (v1!=box.
v1) || (v2!=box.
v2);
118 return (v1.x>v2.x) || (v1.y>v2.y) || (v1.z>v2.z) || (v1.c>v2.c) || (v1.t>v2.t) || (v1.u>v2.u);
202 return (position >= v1) && (position <= v2);
208 v1 = v1+offsetVector;
209 v2 = v2+offsetVector;
218 for (
int c=0; c < 8; c++){ corners[c] =
ImageVector(0); }
243 template <
typename intT>
244 inline ostream&
operator<<(ostream& s,
const ML_NAMESPACE::TSubImageBox<intT> &box)
246 return s << box.v1 <<
" " << box.v2;
263 template <
typename intT>
269 if (V1.x<V2.x){ v1.x=V1.x; v2.x=V2.x; }
else{ v1.x=V2.x; v2.x=V1.x; }
270 if (V1.y<V2.y){ v1.y=V1.y; v2.y=V2.y; }
else{ v1.y=V2.y; v2.y=V1.y; }
271 if (V1.z<V2.z){ v1.z=V1.z; v2.z=V2.z; }
else{ v1.z=V2.z; v2.z=V1.z; }
272 if (V1.c<V2.c){ v1.c=V1.c; v2.c=V2.c; }
else{ v1.c=V2.c; v2.c=V1.c; }
273 if (V1.t<V2.t){ v1.t=V1.t; v2.t=V2.t; }
else{ v1.t=V2.t; v2.t=V1.t; }
274 if (V1.u<V2.u){ v1.u=V1.u; v2.u=V2.u; }
else{ v1.u=V2.u; v2.u=V1.u; }
281 template <
typename intT>
293 template <
typename intT>
296 if (loc1.
isEmpty()){
return loc2; }
else
297 if (loc2.
isEmpty()){
return loc1; }
else
309 template <
typename intT>
void set(const ComponentType v=0)
Sets all components to v or - if v is not specified - to 0.
This class defines a rectangular subimage region of standard ML dimensions.
TSubImageBox()
Constructor: creates an empty subimage region by setting v1 to (0,...,0) and v2 to (-1,...
void makeEmpty()
Makes box empty by setting v1 to (0,...,0) and v2 to (-1,...,-1), i.e., constructor state is restored...
void translate(const VectorType &offsetVector)
Shifts the entire box by an offset given by offsetVector.
VectorType v1
Corner v1 of the subimage region (included in region).
static TSubImageBox< intT > intersect(const TSubImageBox< intT > &box1, const TSubImageBox< intT > &box2)
Returns the overlapping region of subimage regions box1 and box2.
TImageVector< intT > VectorType
The vector type used for corner members v1 and v2.
static void get3DCorners(const TSubImageBox< intT > &box, VectorType corners[8])
Returns the corners of the 3D box extents of box in corners.
bool operator!=(const TSubImageBox< intT > &box) const
Returns false if box has identical components; otherwise, it returns true.
void correct()
Swaps all components where v1.
TSubImageBox(const VectorType &vector1, const VectorType &vector2)
Constructor: creates a subimage from two passed vectors vector1 and vector2.
bool contains(const VectorType &position) const
Returns true if position is inside the SubImageBox.
VectorType v2
Corner v2 of the subimage region (also included in region!).
TSubImageBox< intT > intersect(const TSubImageBox< intT > &box) const
Member function version to intersect this with a given box.
VectorType clamp(const VectorType &position) const
Clamps the position to the nearest position inside the SubImageBox.
bool operator==(const TSubImageBox< intT > &box) const
Returns true if box has identical components; otherwise, it returns false.
static TSubImageBox< intT > merge(const TSubImageBox< intT > &box1, const TSubImageBox< intT > &box2)
Returns the region containing both subimage regions box1 and box2.
TSubImageBox< intT > merge(const TSubImageBox< intT > &box) const
Member function version to merge this with a given box.
intT getNumVoxels() const
Returns number of voxels in the subimage region, i.e., the product of all extents if this is not empt...
TSubImageBox(const VectorType extent)
Constructor: creates a subimage from an extent, i.e., v1 is set to (0,...,0) and v2 is set to (extent...
bool isEmpty() const
Returns true if subimage region is empty, i.e., if any of the components of v1 is greater than the co...
VectorType getExtent() const
Returns the extents of the subimage region.
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator '<<' for stream output of Field objects.
FloatingPointVector< T, size, DataContainer > compMax(FloatingPointVector< T, size, DataContainer > buffer1, const FloatingPointVector< T, size, DataContainer > &buffer2)
Component-wise maximum of buffer1 and buffer2.
FloatingPointVector< T, size, DataContainer > clamp(FloatingPointVector< T, size, DataContainer > vec, const FloatingPointVector< T, size, DataContainer > &lower, const FloatingPointVector< T, size, DataContainer > &upper)
Returns a new vector with all components from vec clamped to range [lower, upper].
T compMul(const FloatingPointVector< T, size, DataContainer > &vec)
Returns the product of all components.
TSubImageBox< MLint > SubImageBox
Defines the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type...
TImageVector< MLint > ImageVector
Defines the standard ImageVector type that is used by the ML for indexing and coordinates.
FloatingPointVector< T, size, DataContainer > compMin(FloatingPointVector< T, size, DataContainer > buffer1, const FloatingPointVector< T, size, DataContainer > &buffer2)
Component-wise minimum of buffer1 and buffer2.