7 #ifndef IMPEM2D_POLAR_RESAMPLING_PARAMETERS_H
8 #define IMPEM2D_POLAR_RESAMPLING_PARAMETERS_H
11 #include "IMP/em2d/em2d_config.h"
18 IMPEM2D_BEGIN_NAMESPACE
28 parameters_set_=
false;
52 void setup(
unsigned int rows,
unsigned int cols) {
57 ending_radius_=std::min(rows/2.,cols/2.);
58 n_rings_ = cv::getOptimalDFTSize((
int)ending_radius_);
59 radius_step_ = (ending_radius_-starting_radius_)/
60 (static_cast<double>(n_rings_));
61 parameters_set_ =
true;
63 "PolarResamplingParameters setup. Input matrix: "
64 << rows <<
" x " << cols
65 <<
" Starting radius= " << starting_radius_ <<
" Ending radius= "
66 << ending_radius_ <<
" Rings= " << n_rings_ << std::endl);
73 return starting_radius_;
79 return ending_radius_;
86 "PolarResamplingParameters: Requested ring is above the maximum number");
87 return starting_radius_+n_ring*radius_step_;
100 n_angles_ = cv::getOptimalDFTSize(aprox_value);
101 angle_step_ = (2*
PI) / static_cast<double>(n_angles_);
118 if(get_is_setup() ==
false) {
119 IMP_THROW(
"trying to get radius_step before initializing",
129 IMP_THROW(
"Number of sampling points for the angle is zero",
133 polar_map_.create(n_rings_,n_angles_,CV_32FC2);
137 for (
unsigned int i=0;i<n_rings_;++i) {
138 for (
unsigned int j=0;j<n_angles_;++j) {
139 double r = get_radius(i);
140 double theta = j*angle_step_;
142 double row =
static_cast<double>(matrix_rows_)/2.0 + r* sin(theta);
143 double col =
static_cast<double>(matrix_cols_)/2.0 + r* cos(theta);
144 polar_map_.at<cv::Vec2f>(i,j)[0] = static_cast<float>(row);
145 polar_map_.at<cv::Vec2f>(i,j)[1] = static_cast<float>(col);
150 cv::convertMaps(polar_map_,empty,map_16SC2_, map_16UC1_, CV_16SC2);
164 << polar_map_.rows <<
"x" << polar_map_.cols
165 <<
" depth " << polar_map_.depth()
166 <<
" type " << polar_map_.type() << std::endl);
171 void show(std::ostream &out)
const {
172 out <<
"starting_radius = " << starting_radius_ << std::endl;
173 out <<
"ending_radius = " << ending_radius_ << std::endl;
174 out <<
"n_rings = " << n_rings_ << std::endl;
178 bool get_is_setup()
const {
179 if(parameters_set_)
return true;
187 double starting_radius_;
188 double ending_radius_;
190 unsigned int n_rings_,n_angles_,matrix_rows_,matrix_cols_;
191 bool parameters_set_;
192 double radius_step_,angle_step_;
198 IMPEM2D_END_NAMESPACE
void create_maps_for_resampling()
static const double PI
the constant pi
Import IMP/kernel/constants.h in the namespace.
PolarResamplingParameters(const cv::Mat &m)
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
void set_estimated_number_of_angles(unsigned int aprox_value)
inteface with OpenCV Copyright 2007-2013 IMP Inventors. All rights reserved.
void get_resampling_map(cv::Mat &m1) const
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
double get_ending_radius() const
Gets the largest radius.
void get_resampling_maps(cv::Mat &m1, cv::Mat &m2) const
double get_angle_step() const
get the angular step used
double get_radius_step() const
Get the step for the radius coordinate.
double get_starting_radius() const
Gets the initial radius of the resampling.
unsigned int get_number_of_rings() const
Get the number of rings (that is, the number of radius values considered)
Various useful constants.
Exception definitions and assertions.
unsigned int get_number_of_angles() const
void setup(unsigned int rows, unsigned int cols)
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
#define IMP_THROW(message, exception_name)
Throw an exception with a message.
Logging and error reporting support.
double get_radius(unsigned int n_ring) const
Gets the current radius employed for the ring in consideration)
PolarResamplingParameters(unsigned int rows, unsigned int cols)
#define IMP_LOG_VERBOSE(expr)
An exception for an invalid value being passed to IMP.