7 #ifndef IMPEM2D_PROJECTION_MASK_H
8 #define IMPEM2D_PROJECTION_MASK_H
10 #include "IMP/em2d/em2d_config.h"
24 #include <boost/shared_ptr.hpp>
26 IMPEM2D_BEGIN_NAMESPACE
31 typedef boost::shared_ptr<ProjectionMask> ProjectionMaskPtr;
32 typedef boost::shared_ptr<MasksManager> MasksManagerPtr;
42 #if !defined(DOXYGEN) && !defined(SWIG)
65 void apply(cv::Mat &m,
68 void show(std::ostream &out = std::cout)
const;
101 center[0] =
static_cast<int>(0.5*m.rows);
102 center[1] =
static_cast<int>(0.5*m.cols);
104 int start[2], end[2];
105 start[0] = -center[0];
106 start[1] = -center[1];
107 end[0]=m.rows - 1 - center[0];
108 end[1]=m.cols - 1 - center[1];
111 if(vi < start[0] || vi > end[0])
return;
112 if(vj < start[1] || vj > end[1])
return;
117 mcenter[0] =
static_cast<int>(0.5*mask.rows);
118 mcenter[1] =
static_cast<int>(0.5*mask.cols);
120 int mstart[2], mend[2];
121 mstart[0] = -mcenter[0];
122 mstart[1] = -mcenter[1];
123 mend[0] = mask.rows - 1 - mcenter[0];
124 mend[1] = mask.cols - 1 - mcenter[1];
127 int start_i = std::max(start[0] - vi, mstart[0]);
128 int start_j = std::max(start[1] - vj, mstart[1]);
129 int end_i = std::min(end[0] - vi, mend[0]);
130 int end_j = std::min(end[1] - vj, mend[1]);
133 int row = vi+center[0];
134 int col = vj+center[1];
136 for(
int i = start_i; i <= end_i; ++i) {
138 for(
int j = start_j; j <= end_j; ++j) {
139 m.at<
double>(p, j+col) += mask.at<
double>(i+mcenter[0], j+mcenter[1]);
165 setup_kernel(resolution,pixelsize);
171 pixelsize_=pixelsize;
177 void create_masks(
const ParticlesTemp &ps);
185 void create_mask(
double radius,
double mass);
188 ProjectionMaskPtr find_mask(
double radius);
190 void show(std::ostream &out = std::cout)
const;
192 unsigned int get_number_of_masks()
const {
193 return radii2mask_.size();
201 std::map <double,ProjectionMaskPtr > radii2mask_;
213 IMPEM2D_END_NAMESPACE