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;
41 #if !defined(DOXYGEN) && !defined(SWIG)
43 double voxelsize,
double mass = 1.0);
61 void show(std::ostream &out = std::cout)
const;
89 center[0] =
static_cast<int>(0.5 * m.rows);
90 center[1] =
static_cast<int>(0.5 * m.cols);
93 start[0] = -center[0];
94 start[1] = -center[1];
95 end[0] = m.rows - 1 - center[0];
96 end[1] = m.cols - 1 - center[1];
99 if (vi < start[0] || vi > end[0])
return;
100 if (vj < start[1] || vj > end[1])
return;
104 mcenter[0] =
static_cast<int>(0.5 * mask.rows);
105 mcenter[1] =
static_cast<int>(0.5 * mask.cols);
107 int mstart[2], mend[2];
108 mstart[0] = -mcenter[0];
109 mstart[1] = -mcenter[1];
110 mend[0] = mask.rows - 1 - mcenter[0];
111 mend[1] = mask.cols - 1 - mcenter[1];
114 int start_i = std::max(start[0] - vi, mstart[0]);
115 int start_j = std::max(start[1] - vj, mstart[1]);
116 int end_i = std::min(end[0] - vi, mend[0]);
117 int end_j = std::min(end[1] - vj, mend[1]);
119 int row = vi + center[0];
120 int col = vj + center[1];
122 for (
int i = start_i; i <= end_i; ++i) {
124 for (
int j = start_j; j <= end_j; ++j) {
125 m.at<
double>(p, j + col) +=
126 mask.at<
double>(i + mcenter[0], j + mcenter[1]);
139 setup_kernel(resolution, pixelsize);
145 pixelsize_ = pixelsize;
157 void create_mask(
double mass);
160 ProjectionMaskPtr find_mask(
double mass);
162 void show(std::ostream &out = std::cout)
const;
164 unsigned int get_number_of_masks()
const {
return mass2mask_.size(); }
170 std::map<double, ProjectionMaskPtr> mass2mask_;
180 IMPEM2D_END_NAMESPACE
A decorator for particles with mass.
Calculates and stores Gaussian kernel parameters.
void setup_kernel(double resolution, double pixelsize)
Initializes the kernel.
Calculates and stores Gaussian kernel parameters.
Interface with OpenCV Copyright 2007-2016 IMP Inventors. All rights reserved.
Exception definitions and assertions.
An approximation of the exponential function.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
int get_rounded(const T &x)
Rounds a number to next integer.
Stores and converts spherical coordinates.
Simple 3D rotation class.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.
void do_place(cv::Mat &mask, cv::Mat &m, const algebra::Vector2D &v)
Decorator for a sphere-like particle.
Management of projection masks.
Decorator for OpenCV matrix to use relative coordinates Copyright 2007-2016 IMP Inventors. All rights reserved.