Xmipp  v3.23.11-Nereus
xmipp_image_over.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Alberto Pascual Montano (pascual@cnb.csic.es)
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * Part of this module has been developed by Lorenzo Zampighi and Nelson Tang
8  * Dept. Physiology of the David Geffen School of Medicine
9  * Univ. of California, Los Angeles.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24  * 02111-1307 USA
25  *
26  * All comments concerning this program package may be sent to the
27  * e-mail address 'xmipp@cnb.csic.es'
28  ***************************************************************************/
29 
30 #include "xmipp_image_over.h"
31 
32 // Initialise an oversampled image (ready for work) ------------------------
33 void ImageOver::init(int _umin, int _umax, int _uistep,
34  int _vmin, int _vmax, int _vistep,
35  int _wmin, int _wmax, int _wistep)
36 {
37  overvmin = _vmin;
38  overumin = _umin;
39  overvmax = _vmax;
40  overumax = _umax;
41  vistep = _vistep;
42  uistep = _uistep;
43 
44  overwmin = _wmin;
45  overwmax = _wmax;
46  wistep = _wistep;
47 
48  // data.initZeros((_vmax-_vmin+1)*_vistep,(_umax-_umin+1)*_uistep);
49  data.initZeros((_wmax - _wmin)*_wistep + 1,(_vmax - _vmin)*_vistep + 1, (_umax - _umin)*_uistep + 1);
50  STARTINGZ(data) = 0;
51  STARTINGY(data) = 0;
52  STARTINGX(data) = 0;
53  // STARTINGY(img)=_vmin*_vistep - (_vistep-1)/2;
54  // STARTINGX(img)=_umin*_uistep - (_uistep-1)/2;
55 }
56 
57 void ImageOver::init(MultidimArray<double> & im, int _uistep, int _vistep, int _wistep)
58 {
59  overumin = STARTINGX(im);
60  overvmin = STARTINGY(im);
61  overwmin = STARTINGZ(im);
62  overumax = STARTINGX(im) + XSIZE(im) - 1;
63  overvmax = STARTINGY(im) + YSIZE(im) - 1;
64  overwmax = STARTINGZ(im) + ZSIZE(im) - 1;
65  uistep = _uistep;
66  vistep = (YSIZE(im) > 1) ? ((_vistep == 0) ? uistep : _vistep) : 0;
67  wistep = (ZSIZE(im) > 1) ? ((_wistep == 0) ? uistep : _wistep) : 0;
68 
69  data.initZeros(im);
70  STARTINGZ(data) = 0;
71  STARTINGY(data) = 0;
72  STARTINGX(data) = 0;
73 }
74 
75 // Window ------------------------------------------------------------------
76 void ImageOver::window(int _v0, int _u0, int _vF, int _uF)
77 {
78  overvmin = _v0;
79  overumin = _u0;
80  overvmax = _vF;
81  overumax = _uF;
82 
83  int newYdim = (_vF - _v0) * vistep + 1;
84  int newXdim = (_uF - _u0) * uistep + 1;
87  LAST_XMIPP_INDEX(newYdim), LAST_XMIPP_INDEX(newXdim));
88  STARTINGY(data) = 0;
89  STARTINGX(data) = 0;
90 }
91 
92 // Clear -------------------------------------------------------------------
94 {
95  overvmin = overvmax = 0;
96  overumin = overumax = 0;
97  overwmin = overwmax = 0;
98  wistep = vistep = uistep = 1;
100 }
101 
102 // Generate the normal image by averaging ----------------------------------
104 {
105  IMGMATRIX(*I).resize(overwmax - overwmin + 1,
106  overvmax - overvmin + 1, overumax - overumin + 1);
107 
108  double iNorm = 1./(wistep * vistep * uistep);
109 
110  for (int k = overwmin; k <= overwmax; ++k)
111  for (int i = overvmin; i <= overvmax; ++i)
112  for (int j = overumin; j <= overumax; ++j)
113  {
114  VOLVOXEL(*I, k, i, j) = 0;
115  for (int w = (k - overwmin) * wistep; w < (k + 1 - overwmin)*wistep; ++w)
116  for (int v = (i - overvmin) * vistep; v < (i + 1 - overvmin)*vistep; ++v)
117  for (int u = (j - overumin) * uistep; u < (j + 1 - overumin)*uistep; ++u)
118  {
119  VOLVOXEL(*I, k, i, j) += VOLVOXEL(*this, w, v, u);
120  }
121  VOLVOXEL(*I, k, i, j) *= iNorm;
122  }
123 }
void selfWindow(int n0, int z0, int y0, int x0, int nF, int zF, int yF, int xF, T init_value=0)
#define YSIZE(v)
#define VOLVOXEL(V, k, i, j)
doublereal * w
#define IMGMATRIX(I)
#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 STARTINGY(v)
MultidimArray< double > data
Definition: xmipp_image.h:55
#define XSIZE(v)
#define ZSIZE(v)
#define j
#define FIRST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:439
doublereal * u
void initZeros(const MultidimArray< T1 > &op)
#define LAST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:448
void downsample(Image< double > *I) const
#define STARTINGZ(v)
void window(int _v0, int _u0, int _vF, int _uF)
void clear()
Definition: xmipp_image.h:144