EMAN2
polardata.h
Go to the documentation of this file.
1/*
2 * Author: Grant Tang, 02/06/2006 (gtang@bcm.edu)
3 * Copyright (c) 2000-2006 Baylor College of Medicine
4 *
5 * This software is issued under a joint BSD/GNU license. You may use the
6 * source code in this file under either license. However, note that the
7 * complete EMAN2 and SPARX software packages have some GPL dependencies,
8 * so you are responsible for compliance with the licenses of these packages
9 * if you opt to use BSD licensing. The warranty disclaimer below holds
10 * in either instance.
11 *
12 * This complete copyright notice must be included in any revised version of the
13 * source code. Additional authorship citations may be added, but existing
14 * author citations must be preserved.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 * */
31
32#ifndef eman__polardata_h__
33#define eman__polardata_h__
34
35#include <map>
36#include <vector>
37#include "log.h"
38#include "exception.h"
39
40using std::map;
41using std::vector;
42
43namespace EMAN
44{
45 static const int MAXFFT=32768;
46 class EMData;
47
50 {
51 public:
53 printf("Welcome to UnevenMatrix\n");
54 }
55 virtual ~UnevenMatrix() {
56 if(data) {
57 delete data;
58 data = 0;
59 }
60 printf("Destructor of UnevenMatrix...\n");
61 }
62
66 inline int get_xsize(int y) {
67 int xsize = desc_data[y].x1 - desc_data[y].x0;
68 if( xsize <= 0 ) {
69 throw InvalidValueException(xsize, "xsize <= 0");
70 }
71 else {
72 return xsize;
73 }
74 }
75
79 inline int get_xmin(int y) {
80 return desc_data[y].x0;
81 }
82
86 inline int get_xmax(int y) {
87 return desc_data[y].x1 - 1;
88 }
89
92 inline int get_size() {
93 return tot_size;
94 }
95
96#ifdef DEBUG
97 void print_UnevenMatrix() {
98 printf("print function in UnevenMatrix\n");
99 }
100#endif //DEBUG
101
102 protected:
106 void alloc_data();
107
110 struct Xdim {
111 int x0;
112 int x1;
113 Xdim() {}
114 Xdim(int i0, int i1) : x0(i0), x1(i1) {
115 if( x1 <= x0 ) {
116 LOGERR("x dimension error ... x0(%d) > x1(%d)", x0, x1);
117 }
118 }
119 };
120
123 float * data;
124
126 map< int, Xdim > desc_data;
127
130 };
131
136 class PolarData : public UnevenMatrix
137 {
138 public:
139 PolarData() {printf("Welcome to PolarData class... \n");}
140
147 PolarData(EMData * image, int xcen, int ycen, string mode);
148
149 virtual ~PolarData() {
150 printf("Destructor of PolarData...\n");
151 }
152
153#ifdef DEBUG
155 void print_polar() {
156 printf("PolarData class is a specialized image class for storing the \n");
157 printf("results of a transform from EMData to polar coordinates, currently \n");
158 printf("support 2D only. Data on x dimension may be variable size, which \n");
159 printf("is defined in map< int, Xdim > desc_data\n");
160 }
161
162 int test_init_desc_data();
163#endif //DEBUG
164
165 private:
167 map< int, float > weight;
168
175 vector<int> Numrinit(int first_ring, int last_ring, int skip, string mode);
176
180 int log2(int n);
181
186 vector<float> ringwe( vector<int> numr, string mode );
187 };
188
189}
190
191
192#endif //eman__polardata_h__
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
a specialized image class for storing the results of a transform from EMData to polar coordinates,...
Definition: polardata.h:137
virtual ~PolarData()
Definition: polardata.h:149
vector< float > ringwe(vector< int > numr, string mode)
calculate ring weights for rotational alignment
map< int, float > weight
the ring weights for each radius r
Definition: polardata.h:167
int log2(int n)
Returns the smallet power by which 2 has to be raised to obtain an integer kess equal n.
vector< int > Numrinit(int first_ring, int last_ring, int skip, string mode)
calculate the number of element for each ring
a general data structure for a matrix with variable x dim size for different y
Definition: polardata.h:50
int get_size()
get the total size of the data block
Definition: polardata.h:92
float * data
store all data in one dimension float array for cache efficiency, we calculate the offset for x,...
Definition: polardata.h:123
virtual ~UnevenMatrix()
Definition: polardata.h:55
void alloc_data()
allocation memory for data array
Definition: polardata.cpp:55
int get_xmin(int y)
get the minimal x dim value for a given y
Definition: polardata.h:79
int get_xmax(int y)
get the maximal x dim value for a given y, note: x1 is one out of the max
Definition: polardata.h:86
int tot_size
the total size of the data
Definition: polardata.h:129
map< int, Xdim > desc_data
describe for each y, the x dimension's size and range
Definition: polardata.h:126
int get_xsize(int y)
get the x dim size for a given y
Definition: polardata.h:66
#define InvalidValueException(val, desc)
Definition: exception.h:285
#define LOGERR
Definition: log.h:51
E2Exception class.
Definition: aligner.h:40
static const int MAXFFT
Definition: polardata.h:45
#define y(i, j)
Definition: projector.cpp:1516
struct to define x dimension size for each y, x0 is inclusive, x1 is one after the maximum,...
Definition: polardata.h:110
Xdim(int i0, int i1)
Definition: polardata.h:114