7 #ifndef IMPEM2D_POLAR_RESAMPLING_PARAMETERS_H 
    8 #define IMPEM2D_POLAR_RESAMPLING_PARAMETERS_H 
   10 #include <IMP/em2d/em2d_config.h> 
   16 #include <cereal/access.hpp> 
   19 IMPEM2D_BEGIN_NAMESPACE
 
   27     parameters_set_ = 
false;
 
   49   void setup(
unsigned int rows, 
unsigned int cols) {
 
   50     starting_radius_ = 5.0;
 
   55         std::min(rows / 2., cols / 2.);  
 
   56     n_rings_ = cv::getOptimalDFTSize((
int)ending_radius_);
 
   58         (ending_radius_ - starting_radius_) / (static_cast<double>(n_rings_));
 
   59     parameters_set_ = 
true;
 
   61                     << rows << 
" x " << cols << 
" Starting radius= " 
   62                     << starting_radius_ << 
" Ending radius= " << ending_radius_
 
   63                     << 
" Rings= " << n_rings_ << std::endl);
 
   69     return starting_radius_;
 
   75     return ending_radius_;
 
   82                     "PolarResamplingParameters: Requested ring is above the " 
   84     return starting_radius_ + n_ring * radius_step_;
 
   97     n_angles_ = cv::getOptimalDFTSize(aprox_value);
 
   98     angle_step_ = (2 * 
PI) / static_cast<double>(n_angles_);
 
  111     if (get_is_setup() == 
false) {
 
  112       IMP_THROW(
"trying to get radius_step before initializing",
 
  121     if (n_angles_ == 0) {
 
  122       IMP_THROW(
"Number of sampling points for the angle is zero",
 
  126     polar_map_.create(n_rings_, n_angles_, CV_32FC2);  
 
  130     for (
unsigned int i = 0; i < n_rings_; ++i) {
 
  131       for (
unsigned int j = 0; j < n_angles_; ++j) {
 
  132         double r = get_radius(i);
 
  133         double theta = j * angle_step_;
 
  135         double row = 
static_cast<double>(matrix_rows_) / 2.0 + r * sin(theta);
 
  136         double col = 
static_cast<double>(matrix_cols_) / 2.0 + r * cos(theta);
 
  137         polar_map_.at<cv::Vec2f>(i, j)[0] = static_cast<float>(row);
 
  138         polar_map_.at<cv::Vec2f>(i, j)[1] = static_cast<float>(col);
 
  143     cv::convertMaps(polar_map_, empty, map_16SC2_, map_16UC1_, CV_16SC2);
 
  157                     << polar_map_.rows << 
"x" << polar_map_.cols << 
" depth " 
  158                     << polar_map_.depth() << 
" type " << polar_map_.type()
 
  163   void show(std::ostream &out)
 const {
 
  164     out << 
"starting_radius = " << starting_radius_ << std::endl;
 
  165     out << 
"ending_radius = " << ending_radius_ << std::endl;
 
  166     out << 
"n_rings = " << n_rings_ << std::endl;
 
  169   bool get_is_setup()
 const {
 
  170     if (parameters_set_) 
return true;
 
  180   double starting_radius_;  
 
  181   double ending_radius_;    
 
  183   unsigned int n_rings_, n_angles_, matrix_rows_, matrix_cols_;
 
  184   bool parameters_set_;
 
  185   double radius_step_, angle_step_;
 
  188   friend class cereal::access;
 
  190   template<
class Archive> 
void serialize(Archive &ar) {
 
  191     ar(polar_map_, map_16SC2_, map_16UC1_, starting_radius_,
 
  192        ending_radius_, n_rings_, n_angles_, matrix_rows_, matrix_cols_,
 
  193        parameters_set_, radius_step_, angle_step_);
 
  199 IMPEM2D_END_NAMESPACE
 
void create_maps_for_resampling()
 
static const double PI
the constant pi 
 
Various useful constants. 
 
PolarResamplingParameters(const cv::Mat &m)
 
void set_estimated_number_of_angles(unsigned int aprox_value)
 
Interface with OpenCV Copyright 2007-2022 IMP Inventors. All rights reserved. 
 
#define IMP_LOG_VERBOSE(expr)
 
Exception definitions and assertions. 
 
A more IMP-like version of the std::vector. 
 
void get_resampling_map(cv::Mat &m1) const 
 
double get_ending_radius() const 
Gets the largest radius. 
 
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values. 
 
void get_resampling_maps(cv::Mat &m1, cv::Mat &m2) const 
 
double get_angle_step() const 
get the angular step used 
 
Logging and error reporting support. 
 
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. 
 
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node. 
 
unsigned int get_number_of_angles() const 
 
#define IMP_THROW(message, exception_name)
Throw an exception with a message. 
 
void setup(unsigned int rows, unsigned int cols)
 
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_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method. 
 
Logging and error reporting support. 
 
An exception for an invalid value being passed to IMP.