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;
55 IMP_THROW(
"CenteredMat: Center index out of range ",ValueException);
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
89 if(i < get_start(0) || i > get_end(0))
return false;
90 if(j < get_start(1) || j > get_end(1))
return false;
106 return centered_.at<
double>(center_row_+i,center_col_+j);
114 out <<
"Matrix of size: (" << centered_.rows <<
","<< centered_.cols
115 <<
") centered mat at: (" << center_row_ <<
","<< center_col_ <<
") start ("
116 << start_[0] <<
","<< start_[1] <<
") end (" << end_[0] <<
","<< end_[1]
129 start_[0] = -center_row_;
130 start_[1] = -center_col_;
131 end_[0]=centered_.rows - 1 - center_row_;
132 end_[1]=centered_.cols - 1 - center_col_;
136 int center_row_,center_col_;
139 int start_[2],end_[2];
142 IMPEM2D_END_NAMESPACE
void set_starts_and_ends()
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)
inteface with OpenCV Copyright 2007-2013 IMP Inventors. All rights reserved.
Import IMP/kernel/macros.h in the namespace.
void do_show(std::ostream &out) const
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
CenteredMat(cv::Mat &m, int center_row, int center_col)
Exception definitions and assertions.
#define IMP_THROW(message, exception_name)
Throw an exception with a message.
Various general useful macros for IMP.
bool get_is_in_range(int i, int j) const