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)
44 double voxelsize,
double mass = 1.0);
64 void show(std::ostream &out = std::cout)
const;
92 center[0] =
static_cast<int>(0.5 * m.rows);
93 center[1] =
static_cast<int>(0.5 * m.cols);
96 start[0] = -center[0];
97 start[1] = -center[1];
98 end[0] = m.rows - 1 - center[0];
99 end[1] = m.cols - 1 - center[1];
102 if (vi < start[0] || vi > end[0])
return;
103 if (vj < start[1] || vj > end[1])
return;
107 mcenter[0] =
static_cast<int>(0.5 * mask.rows);
108 mcenter[1] =
static_cast<int>(0.5 * mask.cols);
110 int mstart[2], mend[2];
111 mstart[0] = -mcenter[0];
112 mstart[1] = -mcenter[1];
113 mend[0] = mask.rows - 1 - mcenter[0];
114 mend[1] = mask.cols - 1 - mcenter[1];
117 int start_i = std::max(start[0] - vi, mstart[0]);
118 int start_j = std::max(start[1] - vj, mstart[1]);
119 int end_i = std::min(end[0] - vi, mend[0]);
120 int end_j = std::min(end[1] - vj, mend[1]);
122 int row = vi + center[0];
123 int col = vj + center[1];
125 for (
int i = start_i; i <= end_i; ++i) {
127 for (
int j = start_j; j <= end_j; ++j) {
128 m.at<
double>(p, j + col) +=
129 mask.at<
double>(i + mcenter[0], j + mcenter[1]);
142 setup_kernel(resolution, pixelsize);
148 pixelsize_ = pixelsize;
161 void create_mask(
double radius,
double mass);
164 ProjectionMaskPtr find_mask(
double radius);
166 void show(std::ostream &out = std::cout)
const;
168 unsigned int get_number_of_masks()
const {
return radii2mask_.size(); }
174 std::map<double, ProjectionMaskPtr> radii2mask_;
184 IMPEM2D_END_NAMESPACE
A decorator for particles with mass.
Calculates kernel parameters as a function of a specific radius.
void setup_kernel(double resolution, double pixelsize)
Initializes the kernel.
Calculates and stores Gaussian kernel parameters.
Interface with OpenCV Copyright 2007-2015 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...
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
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-2015 IMP Inventors. All rights reserved.