Xmipp
v3.23.11-Nereus
xmipp
libraries
data
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;
85
data
.
setXmippOrigin
();
86
data
.
selfWindow
(
FIRST_XMIPP_INDEX
(newYdim),
FIRST_XMIPP_INDEX
(newXdim),
87
LAST_XMIPP_INDEX
(newYdim),
LAST_XMIPP_INDEX
(newXdim));
88
STARTINGY
(
data
) = 0;
89
STARTINGX
(
data
) = 0;
90
}
91
92
// Clear -------------------------------------------------------------------
93
void
ImageOver::clear
()
94
{
95
overvmin
=
overvmax
= 0;
96
overumin
=
overumax
= 0;
97
overwmin
=
overwmax
= 0;
98
wistep
=
vistep
=
uistep
= 1;
99
Image<double>::clear
();
100
}
101
102
// Generate the normal image by averaging ----------------------------------
103
void
ImageOver::downsample
(
Image< double >
*I)
const
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
}
MultidimArray::selfWindow
void selfWindow(int n0, int z0, int y0, int x0, int nF, int zF, int yF, int xF, T init_value=0)
Definition:
multidim_array.h:538
YSIZE
#define YSIZE(v)
Definition:
multidim_array_base.h:95
VOLVOXEL
#define VOLVOXEL(V, k, i, j)
Definition:
xmipp_image_base.h:214
MultidimArray< double >
ImageOver::overumin
int overumin
Definition:
xmipp_image_over.h:117
ImageOver::overvmax
int overvmax
Definition:
xmipp_image_over.h:116
ImageOver::vistep
int vistep
Definition:
xmipp_image_over.h:112
w
doublereal * w
Definition:
numerical_recipes.cpp:2477
IMGMATRIX
#define IMGMATRIX(I)
Definition:
xmipp_image_base.h:181
STARTINGX
#define STARTINGX(v)
Definition:
multidim_array_base.h:51
i
#define i
Definition:
numerical_recipes.cpp:2493
k
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
MultidimArrayBase::setXmippOrigin
void setXmippOrigin()
Definition:
multidim_array_base.cpp:200
ImageOver::overumax
int overumax
Definition:
xmipp_image_over.h:116
STARTINGY
#define STARTINGY(v)
Definition:
multidim_array_base.h:59
Image< double >::data
MultidimArray< double > data
Definition:
xmipp_image.h:55
ImageOver::overwmin
int overwmin
Definition:
xmipp_image_over.h:117
ImageBase::init
void init()
Definition:
xmipp_image_base.cpp:50
XSIZE
#define XSIZE(v)
Definition:
multidim_array_base.h:91
ImageOver::wistep
int wistep
Definition:
xmipp_image_over.h:112
ZSIZE
#define ZSIZE(v)
Definition:
multidim_array_base.h:99
xmipp_image_over.h
j
#define j
Definition:
numerical_recipes.cpp:2493
ImageOver::overwmax
int overwmax
Definition:
xmipp_image_over.h:116
ImageOver::overvmin
int overvmin
Definition:
xmipp_image_over.h:117
ImageOver::uistep
int uistep
Definition:
xmipp_image_over.h:112
FIRST_XMIPP_INDEX
#define FIRST_XMIPP_INDEX(size)
Definition:
xmipp_macros.h:439
Image< double >
u
doublereal * u
Definition:
numerical_recipes.cpp:2230
MultidimArray::initZeros
void initZeros(const MultidimArray< T1 > &op)
Definition:
multidim_array.h:2723
LAST_XMIPP_INDEX
#define LAST_XMIPP_INDEX(size)
Definition:
xmipp_macros.h:448
ImageOver::downsample
void downsample(Image< double > *I) const
Definition:
xmipp_image_over.cpp:103
STARTINGZ
#define STARTINGZ(v)
Definition:
multidim_array_base.h:67
ImageOver::window
void window(int _v0, int _u0, int _vF, int _uF)
Definition:
xmipp_image_over.cpp:76
ImageOver::clear
void clear()
Definition:
xmipp_image_over.cpp:93
Image::clear
void clear()
Definition:
xmipp_image.h:144
Generated by
1.8.13