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)
64 void apply(cv::Mat &m,
67 void show(std::ostream &out = std::cout)
const;
100 center[0] =
static_cast<int>(0.5*m.rows);
101 center[1] =
static_cast<int>(0.5*m.cols);
103 int start[2], end[2];
104 start[0] = -center[0];
105 start[1] = -center[1];
106 end[0]=m.rows - 1 - center[0];
107 end[1]=m.cols - 1 - center[1];
110 if(vi < start[0] || vi > end[0])
return;
111 if(vj < start[1] || vj > end[1])
return;
116 mcenter[0] =
static_cast<int>(0.5*mask.rows);
117 mcenter[1] =
static_cast<int>(0.5*mask.cols);
119 int mstart[2], mend[2];
120 mstart[0] = -mcenter[0];
121 mstart[1] = -mcenter[1];
122 mend[0] = mask.rows - 1 - mcenter[0];
123 mend[1] = mask.cols - 1 - mcenter[1];
126 int start_i = std::max(start[0] - vi, mstart[0]);
127 int start_j = std::max(start[1] - vj, mstart[1]);
128 int end_i = std::min(end[0] - vi, mend[0]);
129 int end_j = std::min(end[1] - vj, mend[1]);
132 int row = vi+center[0];
133 int col = vj+center[1];
135 for(
int i = start_i; i <= end_i; ++i) {
137 for(
int j = start_j; j <= end_j; ++j) {
138 m.at<
double>(p, j+col) += mask.at<
double>(i+mcenter[0], j+mcenter[1]);
164 setup_kernel(resolution,pixelsize);
170 pixelsize_=pixelsize;
183 void create_mask(
double radius,
double mass);
186 ProjectionMaskPtr find_mask(
double radius);
188 void show(std::ostream &out = std::cout)
const;
190 unsigned int get_number_of_masks()
const {
191 return radii2mask_.size();
199 std::map <double,ProjectionMaskPtr > radii2mask_;
211 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.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
Calculates and stores gaussian kernel parameters.
inteface with OpenCV Copyright 2007-2013 IMP Inventors. All rights reserved.
An approximation of the exponential function.
int get_rounded(const T &x)
Rounds a number to next integer.
Stores and converts spherical coordinates.
Simple 3D rotation class.
Exception definitions and assertions.
Import IMP/kernel/Particle.h in the namespace.
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.
Manage of projection masks.
Decorator for OpenCV matrix to use relative coordinates Copyright 2007-2013 IMP Inventors. All rights reserved.