7 #ifndef IMPEM2D_CENTERED_MAT_H
8 #define IMPEM2D_CENTERED_MAT_H
10 #include <IMP/em2d/em2d_config.h>
17 IMPEM2D_BEGIN_NAMESPACE
34 "CenteredMat: Matrix passed is empty");
36 center_row_ =
static_cast<int>(0.5 * m.rows);
37 center_col_ =
static_cast<int>(0.5 * m.cols);
38 set_starts_and_ends();
50 if (center_row >= 0 && center_row < m.rows && center_col >= 0 &&
51 center_col < m.cols) {
52 center_row_ = center_row;
53 center_col_ = center_col;
57 set_starts_and_ends();
64 * @param i The dimension to use (0 - rows, 1 - columns)
65 * @return The starting point in the given dimension
75 int get_end(
int i)
const {
return end_[i]; }
85 if (i < get_start(0) || i > get_end(0))
return false;
86 if (j < get_start(1) || j > get_end(1))
return false;
102 return centered_.at<
double>(center_row_ + i, center_col_ + j);
109 out <<
"Matrix of size: (" << centered_.rows <<
"," << centered_.cols
110 <<
") centered mat at: (" << center_row_ <<
"," << center_col_
111 <<
") start (" << start_[0] <<
"," << start_[1] <<
") end (" << end_[0]
112 <<
"," << end_[1] <<
")" << std::endl;
122 start_[0] = -center_row_;
123 start_[1] = -center_col_;
124 end_[0] = centered_.rows - 1 - center_row_;
125 end_[1] = centered_.cols - 1 - center_col_;
128 int center_row_, center_col_;
131 int start_[2], end_[2];
134 IMPEM2D_END_NAMESPACE
void set_starts_and_ends()
Sets the starting and ending points for the object.
int get_start(int i) const
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
double & operator()(int i, int j)
Returns the element (i,j) RELATIVE to the center.
Interface with OpenCV Copyright 2007-2022 IMP Inventors. All rights reserved.
Exception definitions and assertions.
Various general useful macros for IMP.
void do_show(std::ostream &out) const
Shows information about the class.
CenteredMat(cv::Mat &m, int center_row, int center_col)
#define IMP_THROW(message, exception_name)
Throw an exception with a message.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
An exception for an invalid value being passed to IMP.
Macros to help with objects that can be printed to a stream.
bool get_is_in_range(int i, int j) const
Returns true if the indices are in the matrix.