Xmipp  v3.23.11-Nereus
fringe_processing.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Authors: Javier Vargas (jvargas@cnb.csic.es)
3  *
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 #ifndef CORE_FRINGEPROCESSING_H_
27 #define CORE_FRINGEPROCESSING_H_
28 
29 #include <core/multidim_array.h>
30 #include <core/matrix2d.h>
31 #include <core/histogram.h>
32 #include <core/xmipp_fftw.h>
33 
45 
47 void simulPattern(MultidimArray<double> & im, enum FP_TYPE type, int xdim, int ydim, double noiseLevel, const double freq, Matrix1D<int> coefs);
48 
55 void SPTH(FourierTransformer &ftrans, MultidimArray<double> & im, MultidimArray< std::complex <double> > & imProc);
56 
57 //Orientation by minimun diference fit. This method computes the orientation using a window size. The default
58 //value are wSize=5.
59 //A reference to the current method can be found in:
60 //Yang, Xia; Yu, Qifeng, and Fu, Sihua. An algorithm for estimating both fringe orientation and fringe density. Optics Communications.
61 //2007 Jun 15; 274(2):286-292
62 void orMinDer(const MultidimArray<double> & im, MultidimArray<double > & orMap, MultidimArray<double > & orModMap, int wSize, MultidimArray<bool > & ROI);
63 
64 //This function computes the normalized version of the fringe pattern im = a+m*cos(phi) that it is
65 //imN = cos(phi) and computes also the modulation map m that it is called imModMap; R and S are
66 //rough estimations of the number of fringes in the image that give us the fringe frequency and S is the variance of the exponential
67 //that filter the frequency of the fringes
68 //Ref: Juan Antonio Quiroga, Manuel Servin, "Isotropic n-dimensional fringe
69 //pattern normalization", Optics Communications, 224, Pages 221-227 (2003)
71  double R, double S, MultidimArray<bool> & ROI);
72 
73 //This method is similar to the method normalize but it uses a different Fourier Filter H.
74 void normalizeWB(MultidimArray<double> & im, MultidimArray<double > & imN, MultidimArray<double > & imModMap, double rmax, double rmin, MultidimArray<bool> & ROI);
75 
76 //This method is similar to the method normalize and normalizeWB2 but it uses a different Fourier Filter H.
77 void normalizeWB2(MultidimArray<double> & im, MultidimArray<double > & imN, MultidimArray<double > & imModMap, double rmax, double rmin, MultidimArray<bool> & ROI);
78 
79 //This method obtains the phase direction map from the fringe orientation map solving the sign ambiguity problem that exists in the fringe orientation map.
80 //Once computed the phase direction map the modulating phase can be obtained from the SPTH transform.
81 //REF: Jesus Villa, Ismael De la Rosa, and Gerardo Miramontes, Juan Antonio Quiroga, Phase recovery from a single fringe pattern using an orientational
82 //vector-field-regularized estimator J. Opt. Soc. Am. A Vol. 22, No. 12, (2005)
83 void direction(const MultidimArray<double> & orMap, MultidimArray<double> & qualityMap, double lambda, int size, MultidimArray<double> & dirMap, int x, int y);
84 
85 //This method performs the phase unwrapping process obtaining the absolute phase from a wrapped phase that has 2pi jumps. The method is an improved version
86 //of the work presented in:
87 //Miguel A. Navarro, Julio C. Estrada, M. Servin, Juan A. Quiroga, and Javier Vargas,
88 //"Fast two-dimensional simultaneous phase unwrapping and low-pass filtering," Opt. Express 20, 2556-2561 (2012)
89 void unwrapping(const MultidimArray<double> & wrappedPhase, MultidimArray<double> & qualityMap, double lambda, int size, MultidimArray<double> & unwrappedPhase);
90 
91 //This method performs all the process to demodulate a CTF (im) in order to obtain the phase and the envelope that it is called mod. The method calls the rest of
92 //the methods for this purpose. R and S are rough estimations of the number of fringes in the image (R) and S is the variance of the exponential that filter the frequency of the fringes.
93 //lambda and size is the regularization parameter and the window size where the regularization it is performed. In order to see typical values of these
94 //parameters see the test: test_fringe_processing_main.cpp
95 //COMMENTS: verbose is an argument to save intermediate maps
96 //verbose == 1 saves the normalize map of the fringe pattern
97 //verbose == 2 saves the orientation map of the fringe pattern
98 //verbose == 3 saves the direction map
99 //verbose == 4 saves the wrapped phase map
100 //verbose == 5 saves all
101 void demodulate(MultidimArray<double> & im, double lambda, int size, int x, int y, int rmin, int rmax,
102  MultidimArray<double> & phase, MultidimArray<double> & mod, Matrix1D<double> & coeffs, int verbose=0);
103 
104 void demodulate2(MultidimArray<double> & im, double lambda, int size, int rmin, int rmax,
105  Matrix1D<double> & coeffs, int verbose=0);
106 
107 void firsPSDZero(MultidimArray<double> & enhancedPSD, Matrix1D<double> & xPoints,Matrix1D<double> & yPoints, double rmin,
108  double rmax, int numAngles, int verbose=0);
109 
110 void fitEllipse(Matrix1D<double> & xPts, Matrix1D<double> & yPts, double & x0, double & y0, double & majorAxis, double & minorAxis,
111  double & ellipseAngle);
112 
113 void fitEllipse(MultidimArray<double> & normImag, double & x0, double & y0, double & majorAxis, double & minorAxis,
114  double & ellipseAngle, size_t & area);
115 
116 void calculateDefocus(double & defocusU,double & defocusV, double majorAxis, double minorAxis, double Q0, double lambda, double Cs,
117  double imgSize, double Ts);
118 
120 #endif /* FRINGEPROCESSING_H_ */
void fitEllipse(Matrix1D< double > &xPts, Matrix1D< double > &yPts, double &x0, double &y0, double &majorAxis, double &minorAxis, double &ellipseAngle)
static double * y
void orMinDer(const MultidimArray< double > &im, MultidimArray< double > &orMap, MultidimArray< double > &orModMap, int wSize, MultidimArray< bool > &ROI)
void normalize(FourierTransformer &ftrans, MultidimArray< double > &im, MultidimArray< double > &imN, MultidimArray< double > &imModMap, double R, double S, MultidimArray< bool > &ROI)
void demodulate(MultidimArray< double > &im, double lambda, int size, int x, int y, int rmin, int rmax, MultidimArray< double > &phase, MultidimArray< double > &mod, Matrix1D< double > &coeffs, int verbose=0)
doublereal * x
void demodulate2(MultidimArray< double > &im, double lambda, int size, int rmin, int rmax, Matrix1D< double > &coeffs, int verbose=0)
#define y0
double * lambda
#define x0
void normalizeWB(MultidimArray< double > &im, MultidimArray< double > &imN, MultidimArray< double > &imModMap, double rmax, double rmin, MultidimArray< bool > &ROI)
viol type
void calculateDefocus(double &defocusU, double &defocusV, double majorAxis, double minorAxis, double Q0, double lambda, double Cs, double imgSize, double Ts)
void direction(const MultidimArray< double > &orMap, MultidimArray< double > &qualityMap, double lambda, int size, MultidimArray< double > &dirMap, int x, int y)
void mod(const MultidimArray< T > &x, MultidimArray< T > &m, double y)
void simulPattern(MultidimArray< double > &im, enum FP_TYPE type, int xdim, int ydim, double noiseLevel, const double freq, Matrix1D< int > coefs)
Function to simulate some test fringe patterns.
void unwrapping(const MultidimArray< double > &wrappedPhase, MultidimArray< double > &qualityMap, double lambda, int size, MultidimArray< double > &unwrappedPhase)
void normalizeWB2(MultidimArray< double > &im, MultidimArray< double > &imN, MultidimArray< double > &imModMap, double rmax, double rmin, MultidimArray< bool > &ROI)
void SPTH(FourierTransformer &ftrans, MultidimArray< double > &im, MultidimArray< std::complex< double > > &imProc)
void firsPSDZero(MultidimArray< double > &enhancedPSD, Matrix1D< double > &xPoints, Matrix1D< double > &yPoints, double rmin, double rmax, int numAngles, int verbose=0)