Xmipp  v3.23.11-Nereus
radon.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Carlos Oscar S. Sorzano (coss@cnb.csic.es)
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 
26 #include "radon.h"
27 #include "core/transformations.h"
28 #include <core/geometry.h>
29 
30 void Radon_Transform(const MultidimArray<double> &vol, double rot, double tilt,
32 {
34 
35  // Align the Radon direction with the Z axis
36  if (rot != 0 || tilt != 0) Euler_rotate(vol, rot, tilt, 0.0F, Rvol);
37  else Rvol = vol;
38 
39  // Project onto one line
40  RT.initZeros(Rvol.zdim);
41  STARTINGX(RT) = STARTINGZ(Rvol);
42 
43  for (int k = STARTINGZ(Rvol); k <= FINISHINGZ(Rvol); k++)
44  for (int i = STARTINGY(Rvol); i <= FINISHINGY(Rvol); i++)
45  for (int j = STARTINGX(Rvol); j <= FINISHINGX(Rvol); j++)
46  A1D_ELEM(RT, k) += A3D_ELEM(Rvol, k, i, j);
47 }
48 
49 // The number of voxels in each layer is a double to make easier some
50 // computations outside
51 void Local_Radon_Transform(const MultidimArray<double> &vol, double rot, double tilt,
52  int label, const MultidimArray<double> &vol_label,
55 {
58 
59  // Align the Radon direction with the Z axis
60  if (rot != 0 || tilt != 0)
61  {
62  Euler_rotate(vol, rot, tilt, 0.0F, Rvol);
63  Euler_rotate(vol_label, rot, tilt, 0.0F, Lvol);
64  }
65  else
66  {
67  Rvol = vol;
68  Lvol = vol_label;
69  }
70 
71  // Project onto one line
72  RT.initZeros(Rvol.zdim);
73  STARTINGX(RT) = STARTINGZ(Rvol);
74  RT_n = RT;
75 
76  for (int k = STARTINGZ(Rvol); k <= FINISHINGZ(Rvol); k++)
77  for (int i = STARTINGY(Rvol); i <= FINISHINGY(Rvol); i++)
78  for (int j = STARTINGX(Rvol); j <= FINISHINGX(Rvol); j++)
79  if (A3D_ELEM(Lvol, k, i, j) == label)
80  {
81  A1D_ELEM(RT, k) += A3D_ELEM(Rvol, k, i, j);
82  A1D_ELEM(RT_n, k)++;
83  }
84 }
85 
86 /* Radon Transform of an image --------------------------------------------- */
87 void Radon_Transform(const MultidimArray<double> &I, double rot_step,
89 {
91  RT.initZeros(CEIL(360.0 / rot_step), XSIZE(I));
92  STARTINGX(RT) = STARTINGX(I);
93  int iterRot = static_cast<int>(360.0 / rot_step);
94  for (int l=0; l<iterRot; l++)
95  {
96  double rot = l*rot_step;
97  // Rotate image
98  rotate(xmipp_transformation::LINEAR, rot_I, I, rot);
99  // Sum by columns
100  FOR_ALL_ELEMENTS_IN_ARRAY2D(rot_I) RT(l, j) += rot_I(i, j);
101  }
102 }
#define FINISHINGX(v)
#define A1D_ELEM(v, i)
#define FINISHINGZ(v)
#define STARTINGX(v)
#define i
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
#define rotate(a, i, j, k, l)
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
#define STARTINGY(v)
void Radon_Transform(const MultidimArray< double > &vol, double rot, double tilt, MultidimArray< double > &RT)
Definition: radon.cpp:30
void Local_Radon_Transform(const MultidimArray< double > &vol, double rot, double tilt, int label, const MultidimArray< double > &vol_label, MultidimArray< double > &RT, MultidimArray< double > &RT_n)
Definition: radon.cpp:51
#define A3D_ELEM(V, k, i, j)
#define CEIL(x)
Definition: xmipp_macros.h:225
#define XSIZE(v)
void Euler_rotate(const MultidimArray< double > &V, double rot, double tilt, double psi, MultidimArray< double > &result)
Definition: geometry.cpp:1061
#define j
#define FINISHINGY(v)
void initZeros(const MultidimArray< T1 > &op)
#define STARTINGZ(v)