Xmipp  v3.23.11-Nereus
Macros
Collaboration diagram for Wavelets:

Macros

#define HAAR   2
 
#define DAUB4   4
 
#define DAUB12   12
 
#define DAUB20   20
 

Wavelet transform

void Bilib_DWT (const MultidimArray< double > &input, MultidimArray< double > &result, int iterations, int isign=1)
 
void set_DWT_type (int DWT_type)
 
int Get_Max_Scale (int size)
 
template<typename T >
void DWT (const MultidimArray< T > &v, MultidimArray< double > &result, int isign=1)
 
void IDWT (const MultidimArray< double > &v, MultidimArray< double > &result)
 

Wavelet related functions

void DWT_lowpass2D (const MultidimArray< double > &v, MultidimArray< double > &result)
 
template<typename T >
void SelectDWTBlock (int scale, const MultidimArray< T > &I, const std::string &quadrant, int &x1, int &x2)
 
template<typename T >
void SelectDWTBlock (int scale, const MultidimArray< T > &I, const std::string &quadrant, int &x1, int &x2, int &y1, int &y2)
 
template<typename T >
void SelectDWTBlock (int scale, const MultidimArray< T > &I, const std::string &quadrant, int &x1, int &x2, int &y1, int &y2, int &z1, int &z2)
 
std::string Quadrant2D (int q)
 
std::string Quadrant3D (int q)
 
void Get_Scale_Quadrant (int size_x, int x, int &scale, std::string &quadrant)
 
void Get_Scale_Quadrant (int size_x, int size_y, int x, int y, int &scale, std::string &quadrant)
 
void Get_Scale_Quadrant (int size_x, int size_y, int size_z, int x, int y, int z, int &scale, std::string &quadrant)
 
#define DWT_Imin(s, smax, l)
 
#define DWT_Imax(s, smax, l)
 

Wavelet Denoising

void clean_quadrant2D (MultidimArray< double > &I, int scale, const std::string &quadrant)
 
void clean_quadrant3D (MultidimArray< double > &I, int scale, const std::string &quadrant)
 
void soft_thresholding (MultidimArray< double > &I, double th)
 
void adaptive_soft_thresholding2D (MultidimArray< double > &I, int scale)
 
void DWT_keep_central_part (MultidimArray< double > &I, double R)
 
Matrix1D< double > bayesian_wiener_filtering2D (MultidimArray< double > &WI, int allowed_scale, double SNR0=0.1, double SNRF=0.2, bool white_noise=false, int tell=0, bool denoise=true)
 
void bayesian_wiener_filtering2D (MultidimArray< double > &WI, int allowed_scale, Matrix1D< double > &estimatedS)
 
Matrix1D< double > bayesian_wiener_filtering3D (MultidimArray< double > &WI, int allowed_scale, double SNR0=0.1, double SNRF=0.2, bool white_noise=false, int tell=0, bool denoise=true)
 
void bayesian_wiener_filtering3D (MultidimArray< double > &WI, int allowed_scale, Matrix1D< double > &estimatedS)
 
void phaseCongMono (MultidimArray< double > &I, MultidimArray< double > &PC, MultidimArray< double > &FT, MultidimArray< double > &Energy, MultidimArray< double > &lowPass, MultidimArray< double > &Radius, MultidimArray< std::complex< double > > &H, int nScale, double minWaveLength, double mult, double sigmaOnf)
 

Detailed Description

Macro Definition Documentation

◆ DAUB12

#define DAUB12   12

Definition at line 39 of file wavelet.h.

◆ DAUB20

#define DAUB20   20

Definition at line 40 of file wavelet.h.

◆ DAUB4

#define DAUB4   4

Definition at line 38 of file wavelet.h.

◆ DWT_Imax

#define DWT_Imax (   s,
  smax,
 
)
Value:
static_cast< int>(((l == '0') ? \
pow(2.0, smax - s - 1) - 1 : pow(2.0, smax - s) - 1))

Definition at line 124 of file wavelet.h.

◆ DWT_Imin

#define DWT_Imin (   s,
  smax,
 
)
Value:
static_cast< int >(((l == '0') ? 0 : \
pow(2.0, smax - s - 1)))

Definition at line 122 of file wavelet.h.

◆ HAAR

#define HAAR   2

Definition at line 37 of file wavelet.h.

Function Documentation

◆ adaptive_soft_thresholding2D()

void adaptive_soft_thresholding2D ( MultidimArray< double > &  I,
int  scale 
)

Adaptive soft thresholding 2D.

Chang, Yu, Betterli. IEEE Int. Conf. Image Processing

Definition at line 384 of file wavelet.cpp.

385 {
386  double sigma = compute_noise_power(I);
387  for (int s = 0; s <= scale; s++)
388  {
389  adaptive_soft_thresholding_block2D(I, s, "01", sigma);
390  adaptive_soft_thresholding_block2D(I, s, "10", sigma);
391  adaptive_soft_thresholding_block2D(I, s, "11", sigma);
392  }
393 }
void adaptive_soft_thresholding_block2D(MultidimArray< double > &I, int scale, const std::string &quadrant, double sigma)
Definition: wavelet.cpp:321
double compute_noise_power(MultidimArray< double > &I)
Definition: wavelet.cpp:346

◆ bayesian_wiener_filtering2D() [1/2]

Matrix1D< double > bayesian_wiener_filtering2D ( MultidimArray< double > &  WI,
int  allowed_scale,
double  SNR0 = 0.1,
double  SNRF = 0.2,
bool  white_noise = false,
int  tell = 0,
bool  denoise = true 
)

Bayesian, Wiener filtering.

Bijaoui, Signal Processing 2002, 82: 709-712. The Denoising procedure is applied up to the scale given. SNR0 is the smallest SNR and SNRF is the largest SNR.

This function returns the estimated coefficients for S and N at each scale. If denoise is set to false, then S and N coefficients are estimated but they are not applied to the image.

Definition at line 603 of file wavelet.cpp.

605 {
606  /*Calculate the power of the wavelet transformed image */
607  double powerI = WI.sum2();
608 
609  /*Number of pixels and some constraints on SNR*/
610  int Xdim = XSIZE(WI);
611  int max_scale = ROUND(log(double(Xdim)) / log(2.0));
612 
613 #ifdef DEBUG
614 
615  std::cout << "powerI= " << powerI << std::endl;
616  double powerWI = WI.sum2();
617  std::cout << "powerWI= " << powerWI << std::endl;
618  std::cout << "Ydim = " << Ydim << " Xdim = " << Xdim << "\n";
619  std::cout << "Ncoef_total= " << Ncoef_total << std::endl;
620  std::cout << "max_scale = " << max_scale << "\n";
621 #endif
622 
623  /*Calculate the power at each band*/
624  //init the scale vector
625  Matrix1D<int> scale(XMIPP_MIN(allowed_scale + 1, max_scale - 1));
626  FOR_ALL_ELEMENTS_IN_MATRIX1D(scale) scale(i) = i;
627  int scale_dim = scale.size();
628 
629  //define some vectors
630  Matrix1D<double> power(scale_dim), average(scale_dim), Ncoefs(scale_dim);
631  Matrix1D<int> x0(2), xF(2), r(2);
632  std::vector<std::string> orientation;
633  orientation.push_back("01");
634  orientation.push_back("10");
635  orientation.push_back("11");
636  int orientationSize=orientation.size();
637  int jmax=scale.size();
638  for (int j = 0;j < jmax;j++)
639  {
640  for (size_t k = 0; k < orientation.size(); k++)
641  {
642  SelectDWTBlock(scale(j), WI, orientation[k],
643  XX(x0), XX(xF), YY(x0), YY(xF));
645  {
646  double aux=DIRECT_A2D_ELEM(WI,YY(r),XX(r));
647  VEC_ELEM(power,j) += aux*aux;
648  VEC_ELEM(average,j) += aux;
649  }
650  }
651  VEC_ELEM(Ncoefs,j) = (int)pow(2.0, 2 * (max_scale - VEC_ELEM(scale,j) - 1)) * orientationSize;
652  VEC_ELEM(average,j) = VEC_ELEM(average,j) / VEC_ELEM(Ncoefs,j);
653  }
654 
655  /*Evaluate the power of the unconsidered part of the image */
656  double power_rest = 0.0;
657  int Ncoefs_rest = 0;
658  SelectDWTBlock(scale(scale_dim - 1), WI, "00", XX(x0), XX(xF), YY(x0), YY(xF));
660  {
661  double aux=DIRECT_A2D_ELEM(WI,YY(r),XX(r));
662  power_rest += aux*aux;
663  }
664  Ncoefs_rest = (int)pow(2.0, 2 * (max_scale - 1 - scale(scale_dim - 1)));
665 
666  if (tell)
667  {
668  std::cout << "scale = " << std::endl << scale << std::endl;
669  std::cout << "power= " << std::endl << power << "\n";
670  std::cout << "average= " << std::endl << average << "\n";
671  std::cout << "Ncoefs= " << std::endl << Ncoefs << "\n";
672  std::cout << "power_rest= " << power_rest << "\n";
673  std::cout << "Ncoefs_rest= " << Ncoefs_rest << "\n";
674  std::cout << "powerI= " << powerI << std::endl;
675  std::cout << "Total sum of powers = " << power.sum() + power_rest << std::endl;
676  std::cout << "Difference powers = " << powerI - power.sum() - power_rest << std::endl;
677  }
678 
679  /*Solve the Equation System*/
680  Matrix1D<double> estimatedS;
681  bayesian_solve_eq_system(power, Ncoefs,
682  SNR0, SNRF, powerI, power_rest, white_noise, estimatedS);
683 
684  if (tell)
685  {
686  std::cout << "estimatedS =\n" << estimatedS << std::endl;
687  double S = 0, N = 0;
688  for (int i = 0; i < scale_dim; i++)
689  {
690  N += Ncoefs(i) * estimatedS(i);
691  S += Ncoefs(i) * estimatedS(scale_dim + i);
692  }
693  std::cout << "SNR value=" << S / N << std::endl << std::endl;
694  }
695 
696  /* Apply the Bijaoui denoising to all scales >= allowed_scale */
697  if (denoise)
698  bayesian_wiener_filtering2D(WI, allowed_scale, estimatedS);
699 
700  return estimatedS;
701 }
#define VEC_ELEM(v, i)
Definition: matrix1d.h:245
#define DIRECT_A2D_ELEM(v, i, j)
void bayesian_solve_eq_system(const Matrix1D< double > &power, const Matrix1D< double > &Ncoefs, double SNR0, double SNRF, double powerI, double power_rest, bool white_noise, Matrix1D< double > &estimatedS)
Definition: wavelet.cpp:476
#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
Matrix1D< double > bayesian_wiener_filtering2D(MultidimArray< double > &WI, int allowed_scale, double SNR0, double SNRF, bool white_noise, int tell, bool denoise)
Definition: wavelet.cpp:603
#define FOR_ALL_ELEMENTS_IN_MATRIX1D(v)
Definition: matrix1d.h:72
void log(Image< double > &op)
#define x0
#define XX(v)
Definition: matrix1d.h:85
#define XSIZE(v)
#define ROUND(x)
Definition: xmipp_macros.h:210
#define xF
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
#define j
#define YY(v)
Definition: matrix1d.h:93
void power(Image< double > &op)
double sum2() const
void SelectDWTBlock(int scale, const MultidimArray< T > &I, const std::string &quadrant, int &x1, int &x2)
Definition: wavelet.h:134
#define FOR_ALL_ELEMENTS_IN_ARRAY2D_BETWEEN(corner1, corner2)

◆ bayesian_wiener_filtering2D() [2/2]

void bayesian_wiener_filtering2D ( MultidimArray< double > &  WI,
int  allowed_scale,
Matrix1D< double > &  estimatedS 
)

Bayesian, Wiener filtering.

This is the function that really denoise.

Definition at line 704 of file wavelet.cpp.

706 {
707  std::vector<std::string> orientation;
708  orientation.push_back("01");
709  orientation.push_back("10");
710  orientation.push_back("11");
711 
712  int max_scale = ROUND(log(double(XSIZE(WI))) / log(2.0));
713  Matrix1D<int> scale(XMIPP_MIN(allowed_scale + 1, max_scale - 1));
714  FOR_ALL_ELEMENTS_IN_MATRIX1D(scale) scale(i) = i;
715 
716  for (size_t i = 0;i < scale.size();i++)
717  {
718  double N = estimatedS(i);
719  double S = estimatedS(i + scale.size());
720  for (size_t k = 0; k < orientation.size(); k++)
721  DWT_Bijaoui_denoise_LL2D(WI, scale(i), orientation[k], 0, S, N);
722  }
723 }
#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 FOR_ALL_ELEMENTS_IN_MATRIX1D(v)
Definition: matrix1d.h:72
void log(Image< double > &op)
void DWT_Bijaoui_denoise_LL2D(MultidimArray< double > &WI, int scale, const std::string &orientation, double mu, double S, double N)
Definition: wavelet.cpp:414
#define XSIZE(v)
#define ROUND(x)
Definition: xmipp_macros.h:210
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181

◆ bayesian_wiener_filtering3D() [1/2]

Matrix1D< double > bayesian_wiener_filtering3D ( MultidimArray< double > &  WI,
int  allowed_scale,
double  SNR0 = 0.1,
double  SNRF = 0.2,
bool  white_noise = false,
int  tell = 0,
bool  denoise = true 
)

Bayesian, Wiener filtering.

Bijaoui, Signal Processing 2002, 82: 709-712. The denoising procedure is applied up to the scale given. SNR0 is the smallest SNR and SNRF is the largest SNR.

This function returns the estimated coefficients for S and N at each scale. If denoise is set to false, then S and N coefficients are estimated but they are not applied to the image.

Definition at line 726 of file wavelet.cpp.

729 {
730  /*Calculate the power of the wavelet transformed image */
731  double powerI = WI.sum2();
732 
733  /*Number of pixels and some constraints on SNR*/
734  size_t Xdim=ZSIZE(WI);
735  int max_scale = ROUND(log(double(Xdim)) / log(2.0));
736 
737 #ifdef DEBUG
738 
739  std::cout << "powerI= " << powerI << std::endl;
740  double powerWI = WI.sum2();
741  std::cout << "powerWI= " << powerWI << std::endl;
742  std::cout << "Zdim= " << Zdim << " Ydim = " << Ydim << " Xdim = " << Xdim << "\n";
743  std::cout << "Ncoef_total= " << Ncoef_total << std::endl;
744  std::cout << "max_scale = " << max_scale << "\n";
745 #endif
746 
747  /*Calculate the power at each band*/
748  //init the scale vector
749  Matrix1D<int> scale(allowed_scale + 1);
750  FOR_ALL_ELEMENTS_IN_MATRIX1D(scale) scale(i) = i;
751  int scale_dim = scale.size();
752 
753  //define some vectors
754  Matrix1D<double> power(scale_dim), average(scale_dim), Ncoefs(scale_dim);
755  Matrix1D<int> x0(3), xF(3), r(3);
756  std::vector<std::string> orientation;
757  orientation.push_back("001");
758  orientation.push_back("010");
759  orientation.push_back("011");
760  orientation.push_back("100");
761  orientation.push_back("101");
762  orientation.push_back("110");
763  orientation.push_back("111");
764  for (size_t j = 0;j < scale.size();j++)
765  {
766  for (size_t k = 0; k < orientation.size(); k++)
767  {
768  SelectDWTBlock(scale(j), WI, orientation[k],
769  XX(x0), XX(xF), YY(x0), YY(xF), ZZ(x0), ZZ(xF));
771  {
772  power(j) += WI(r) * WI(r);
773  average(j) += WI(r);
774  }
775  }
776  Ncoefs(j) = (int)pow(2.0, 3 * (max_scale - scale(j) - 1)) * orientation.size();
777  average(j) = average(j) / Ncoefs(j);
778  }
779 
780  /*Evaluate the power of the unconsidered part of the image */
781  double power_rest = 0.0;
782  int Ncoefs_rest = 0;
783  SelectDWTBlock(scale(scale_dim - 1), WI, "000", XX(x0), XX(xF), YY(x0), YY(xF),
784  ZZ(x0), ZZ(xF));
786  power_rest += WI(r) * WI(r);
787  Ncoefs_rest = (int)pow(2.0, 3 * (max_scale - 1 - scale(scale_dim - 1)));
788 
789  if (tell)
790  {
791  std::cout << "scale = " << std::endl << scale << std::endl;
792  std::cout << "power= " << std::endl << power << "\n";
793  std::cout << "average= " << std::endl << average << "\n";
794  std::cout << "Ncoefs= " << std::endl << Ncoefs << "\n";
795  std::cout << "power_rest= " << power_rest << "\n";
796  std::cout << "Ncoefs_rest= " << Ncoefs_rest << "\n";
797  std::cout << "powerI= " << powerI << std::endl;
798  std::cout << "Total sum of powers = " << power.sum() + power_rest << std::endl;
799  std::cout << "Difference powers = " << powerI - power.sum() - power_rest << std::endl;
800  }
801 
802  /*Solve the Equation System*/
803  Matrix1D<double> estimatedS;
804  bayesian_solve_eq_system(power, Ncoefs,
805  SNR0, SNRF, powerI, power_rest, white_noise, estimatedS);
806  if (tell)
807  {
808  std::cout << "estimatedS =\n" << estimatedS << std::endl;
809  double S = 0, N = 0;
810  for (int i = 0; i < scale_dim; i++)
811  {
812  N += Ncoefs(i) * estimatedS(i);
813  S += Ncoefs(i) * estimatedS(scale_dim + i);
814  }
815  std::cout << "SNR value=" << S / N << std::endl << std::endl;
816  }
817 
818  /* Apply the Bijaoui denoising to all scales >= allowed_scale */
819  if (denoise)
820  bayesian_wiener_filtering3D(WI, allowed_scale, estimatedS);
821  return estimatedS;
822 }
void bayesian_solve_eq_system(const Matrix1D< double > &power, const Matrix1D< double > &Ncoefs, double SNR0, double SNRF, double powerI, double power_rest, bool white_noise, Matrix1D< double > &estimatedS)
Definition: wavelet.cpp:476
#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 FOR_ALL_ELEMENTS_IN_MATRIX1D(v)
Definition: matrix1d.h:72
void log(Image< double > &op)
#define x0
#define XX(v)
Definition: matrix1d.h:85
#define ZSIZE(v)
#define ROUND(x)
Definition: xmipp_macros.h:210
#define xF
#define j
#define YY(v)
Definition: matrix1d.h:93
void power(Image< double > &op)
double sum2() const
void SelectDWTBlock(int scale, const MultidimArray< T > &I, const std::string &quadrant, int &x1, int &x2)
Definition: wavelet.h:134
Matrix1D< double > bayesian_wiener_filtering3D(MultidimArray< double > &WI, int allowed_scale, double SNR0, double SNRF, bool white_noise, int tell, bool denoise)
Definition: wavelet.cpp:726
#define ZZ(v)
Definition: matrix1d.h:101
#define FOR_ALL_ELEMENTS_IN_ARRAY3D_BETWEEN(corner1, corner2)

◆ bayesian_wiener_filtering3D() [2/2]

void bayesian_wiener_filtering3D ( MultidimArray< double > &  WI,
int  allowed_scale,
Matrix1D< double > &  estimatedS 
)

Bayesian, Wiener filtering.

This is the function that really denoise.

Definition at line 825 of file wavelet.cpp.

827 {
828  std::vector<std::string> orientation;
829  orientation.push_back("001");
830  orientation.push_back("010");
831  orientation.push_back("011");
832  orientation.push_back("100");
833  orientation.push_back("101");
834  orientation.push_back("110");
835  orientation.push_back("111");
836 
837  int max_scale = ROUND(log(double(XSIZE(WI))) / log(2.0));
838  MultidimArray<int> scale(XMIPP_MIN(allowed_scale + 1, max_scale - 1));
839  FOR_ALL_ELEMENTS_IN_ARRAY1D(scale) scale(i) = i;
840 
841  for (size_t i = 0;i < XSIZE(scale);i++)
842  {
843  double N = estimatedS(i);
844  double S = estimatedS(i + XSIZE(scale));
845  for (size_t k = 0; k < orientation.size(); k++)
846  DWT_Bijaoui_denoise_LL3D(WI, scale(i), orientation[k], 0, S, N);
847  }
848 }
#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
void log(Image< double > &op)
#define XSIZE(v)
#define ROUND(x)
Definition: xmipp_macros.h:210
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
#define FOR_ALL_ELEMENTS_IN_ARRAY1D(v)
void DWT_Bijaoui_denoise_LL3D(MultidimArray< double > &WI, int scale, const std::string &orientation, double mu, double S, double N)
Definition: wavelet.cpp:446

◆ Bilib_DWT()

void Bilib_DWT ( const MultidimArray< double > &  input,
MultidimArray< double > &  result,
int  iterations,
int  isign = 1 
)

B-spline Wavelet transform of a vector.

The B-spline wavelet transform of the input array is computed. The size of the array must be so as to allow the downsampling by 2 as many times as the number of iterations. For instance, if iterations is 1, then it must be a multiple of 2. If iterations is 2, then it must be a multiple of 4. If iterations if 3, then it must be a multiple of 8. And so on.

If the isign=-1 then the inverse wavelet transform is performed.

Definition at line 43 of file wavelet.cpp.

45 {
46  if (iterations < 1)
47  REPORT_ERROR(ERR_INDEX_OUTOFBOUNDS, "Bilib_DWT: iterations must be >=1");
48  auto size_multiple = (int)pow(2.0, (double) iterations);
49  if (XSIZE(input) % size_multiple != 0)
51  (std::string)"Bilib_DWT: Xsize must be a multiple of " +
52  integerToString(size_multiple));
53  if (YSIZE(input) > 1 && YSIZE(input) % size_multiple != 0)
55  (std::string)"Bilib_DWT 2D: Ysize must be a multiple of " +
56  integerToString(size_multiple));
57  if (ZSIZE(input) > 1 && ZSIZE(input) % size_multiple != 0)
59  (std::string)"Bilib_DWT 3D: Zsize must be a multiple of " +
60  integerToString(size_multiple));
61 
62  result.initZeros(input);
63  TWaveletStruct TW;
64  if (isign == 1)
65  TW.Operation = "Analysis";
66  else if (isign == -1)
67  TW.Operation = "Synthesis";
68  else
69  REPORT_ERROR(ERR_VALUE_INCORRECT, (std::string)"waveletTransform: unrecognized isign");
70  TW.Filter = "Orthonormal Spline";
71  TW.BoundaryConditions = "Mirror";
72  TW.Order = "1";
73  TW.Alpha = 0;
74 
75  if (isign == 1)
76  {
77  // First iteration
78  TW.Input = MULTIDIM_ARRAY(input);
79  TW.NxOutput = TW.NxInput = XSIZE(input);
80  TW.NyOutput = TW.NyInput = YSIZE(input);
81  TW.NzOutput = TW.NzInput = ZSIZE(input);
82  TW.Output = MULTIDIM_ARRAY(result);
83  Wavelet(&TW);
84 
85  // Subsequent iterations
86  for (int i = 1; i < iterations; i++)
87  {
88  // Size of the Lowest subband
89  int xsize = XMIPP_MAX(1, XSIZE(input) / (int)pow(2.0, (double)i));
90  int ysize = XMIPP_MAX(1, YSIZE(input) / (int)pow(2.0, (double)i));
91  int zsize = XMIPP_MAX(1, ZSIZE(input) / (int)pow(2.0, (double)i));
92 
93  // Pick the Lowest subband
94  MultidimArray<double> input_aux, result_aux;
95  input_aux.resize(zsize, ysize, xsize);
96  result_aux.resize(zsize, ysize, xsize);
98  DIRECT_A3D_ELEM(input_aux, k, i, j) = DIRECT_A3D_ELEM(result, k, i, j);
99 
100  // DWT
101  TW.Input = MULTIDIM_ARRAY(input_aux);
102  TW.NxOutput = TW.NxInput = XSIZE(input_aux);
103  TW.NyOutput = TW.NyInput = YSIZE(input_aux);
104  TW.NzOutput = TW.NzInput = ZSIZE(input_aux);
105  TW.Output = MULTIDIM_ARRAY(result_aux);
106  Wavelet(&TW);
107 
108  // Return the subband to the output
110  DIRECT_A3D_ELEM(result, k, i, j) = DIRECT_A3D_ELEM(result_aux, k, i, j);
111  }
112  }
113  else if (isign == -1)
114  {
115  // Subsequent iterations
116  for (int i = iterations - 1; i >= 1; i--)
117  {
118  // Size of the Lowest subband
119  int xsize = XMIPP_MAX(1, XSIZE(input) / (int)pow(2.0, (double)i));
120  int ysize = XMIPP_MAX(1, YSIZE(input) / (int)pow(2.0, (double)i));
121  int zsize = XMIPP_MAX(1, ZSIZE(input) / (int)pow(2.0, (double)i));
122 
123  // Pick the Lowest subband
124  MultidimArray<double> input_aux, result_aux;
125  input_aux.resize(zsize, ysize, xsize);
126  result_aux.resize(zsize, ysize, xsize);
128  DIRECT_A3D_ELEM(input_aux, k, i, j) = DIRECT_A3D_ELEM(input, k, i, j);
129 
130  // DWT
131  TW.Input = MULTIDIM_ARRAY(input_aux);
132  TW.NxOutput = TW.NxInput = XSIZE(input_aux);
133  TW.NyOutput = TW.NyInput = YSIZE(input_aux);
134  TW.NzOutput = TW.NzInput = ZSIZE(input_aux);
135  TW.Output = MULTIDIM_ARRAY(result_aux);
136  Wavelet(&TW);
137 
138  // Return the subband to the output
140  DIRECT_A3D_ELEM(input, k, i, j) = DIRECT_A3D_ELEM(result_aux, k, i, j);
141  }
142 
143  // First iteration
144  TW.Input = MULTIDIM_ARRAY(input);
145  TW.NxOutput = TW.NxInput = XSIZE(input);
146  TW.NyOutput = TW.NyInput = YSIZE(input);
147  TW.NzOutput = TW.NzInput = ZSIZE(input);
148  TW.Output = MULTIDIM_ARRAY(result);
149  Wavelet(&TW);
150  }
151 }
Index out of bounds.
Definition: xmipp_error.h:132
long NzInput
Definition: wavelet.h:37
#define YSIZE(v)
void resize(size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim, bool copy=true)
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double * Input
Definition: wavelet.h:31
#define MULTIDIM_ARRAY(v)
String integerToString(int I, int _width, char fill_with)
#define FOR_ALL_DIRECT_ELEMENTS_IN_ARRAY3D(V)
Incorrect MultidimArray size.
Definition: xmipp_error.h:174
const char * Filter
Definition: wavelet.h:52
#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
double * Output
Definition: wavelet.h:39
const char * Operation
Definition: wavelet.h:47
#define XSIZE(v)
long NzOutput
Definition: wavelet.h:45
#define ZSIZE(v)
long NyInput
Definition: wavelet.h:35
int Wavelet(struct TWaveletStruct *Data)
#define DIRECT_A3D_ELEM(v, k, i, j)
#define j
double Alpha
Definition: wavelet.h:58
const char * BoundaryConditions
Definition: wavelet.h:54
long NxOutput
Definition: wavelet.h:41
long NxInput
Definition: wavelet.h:33
void initZeros(const MultidimArray< T1 > &op)
Incorrect value received.
Definition: xmipp_error.h:195
long NyOutput
Definition: wavelet.h:43
const char * Order
Definition: wavelet.h:56

◆ clean_quadrant2D()

void clean_quadrant2D ( MultidimArray< double > &  I,
int  scale,
const std::string &  quadrant 
)

Remove all information within a quadrant and scale.

Definition at line 288 of file wavelet.cpp.

289 {
290  Matrix1D<int> corner1(2), corner2(2);
291  Matrix1D<double> r(2);
292  SelectDWTBlock(scale, I, quadrant, XX(corner1), XX(corner2), YY(corner1), YY(corner2));
293  FOR_ALL_ELEMENTS_IN_ARRAY2D_BETWEEN(corner1, corner2)
294  I(r) = 0;
295 }
#define XX(v)
Definition: matrix1d.h:85
#define YY(v)
Definition: matrix1d.h:93
void SelectDWTBlock(int scale, const MultidimArray< T > &I, const std::string &quadrant, int &x1, int &x2)
Definition: wavelet.h:134
#define FOR_ALL_ELEMENTS_IN_ARRAY2D_BETWEEN(corner1, corner2)

◆ clean_quadrant3D()

void clean_quadrant3D ( MultidimArray< double > &  I,
int  scale,
const std::string &  quadrant 
)

Remove all information within a quadrant and scale.

Definition at line 297 of file wavelet.cpp.

298 {
299  int x1, y1, z1, x2, y2, z2;
300  SelectDWTBlock(scale, I, quadrant, x1, x2, y1, y2, z1, z2);
301  Matrix1D<int> corner1(3), corner2(3);
302  Matrix1D<double> r(3);
303  SelectDWTBlock(scale, I, quadrant, XX(corner1), XX(corner2),
304  YY(corner1), YY(corner2), ZZ(corner1), ZZ(corner2));
305  FOR_ALL_ELEMENTS_IN_ARRAY3D_BETWEEN(corner1, corner2) I(r) = 0;
306 }
#define XX(v)
Definition: matrix1d.h:85
#define YY(v)
Definition: matrix1d.h:93
void SelectDWTBlock(int scale, const MultidimArray< T > &I, const std::string &quadrant, int &x1, int &x2)
Definition: wavelet.h:134
#define ZZ(v)
Definition: matrix1d.h:101
#define FOR_ALL_ELEMENTS_IN_ARRAY3D_BETWEEN(corner1, corner2)

◆ DWT()

template<typename T >
void DWT ( const MultidimArray< T > &  v,
MultidimArray< double > &  result,
int  isign = 1 
)

DWT of a MultidimArray

The output vector can be the same as the input one. Previously the type of DWT must be set with set_DWT_type. If isign=1 the direct DWT is performed, if isign=-1 the inverse DWT is done.

Definition at line 83 of file wavelet.h.

84 {
85  unsigned long int nn[3];
86  unsigned long int *ptr_nn = nn - 1;
87  int dim;
88  nn[2] = ZSIZE(v);
89  nn[1] = YSIZE(v);
90  nn[0] = XSIZE(v);
91 
92  if (YSIZE(v) == 1 && ZSIZE(v) == 1)
93  dim = 1;
94  else if (ZSIZE(v) == 1)
95  dim = 2;
96  else
97  dim = 3;
98 
99  typeCast(v, result);
100  double* ptr_result = MULTIDIM_ARRAY(result) - 1;
101  wtn(ptr_result, ptr_nn, dim, isign, pwt);
102 }
#define YSIZE(v)
void wtn(double a[], unsigned long nn[], int ndim, int isign, void(*wtstep)(double [], unsigned long, int))
#define MULTIDIM_ARRAY(v)
#define XSIZE(v)
#define ZSIZE(v)
void typeCast(const Matrix1D< T1 > &v1, Matrix1D< T2 > &v2)
Definition: matrix1d.h:1227
void pwt(double a[], unsigned long n, int isign)

◆ DWT_keep_central_part()

void DWT_keep_central_part ( MultidimArray< double > &  I,
double  R 
)

Keep central part 2D.

Keep those coefficients in a certain radius.

Definition at line 396 of file wavelet.cpp.

397 {
398  Mask mask(INT_MASK);
399  mask.type = BINARY_DWT_CIRCULAR_MASK;
400  if (R == -1)
401  mask.R1 = (double)XSIZE(I) / 2 + 1;
402  else
403  mask.R1 = R;
404  mask.smin = 0;
405  mask.smax = Get_Max_Scale(XSIZE(I));
406  mask.quadrant = "xx";
407  mask.resize(I);
408  mask.generate_mask();
409  mask.apply_mask(I, I);
410 }
int Get_Max_Scale(int size)
Definition: wavelet.h:71
Definition: mask.h:360
#define XSIZE(v)
#define BINARY_DWT_CIRCULAR_MASK
Definition: mask.h:377
#define INT_MASK
Definition: mask.h:385

◆ DWT_lowpass2D()

void DWT_lowpass2D ( const MultidimArray< double > &  v,
MultidimArray< double > &  result 
)

DWT Low pass versions.

This function returns the low pass versions at different scales. The low pass version of the image at scale s is stored in the 01 quadrant of that scale.

Definition at line 165 of file wavelet.cpp.

166 {
167  MultidimArray<double> dwt, aux;
168  result.initZeros(YSIZE(v), XSIZE(v) / 2);
169  DWT(v, dwt);
170  int Nx = Get_Max_Scale(XSIZE(v));
171  for (int s = 0; s < Nx; s++)
172  {
173  // Perform the inverse DWT transform of the low pass
174  dwt.resize(XSIZE(dwt) / 2, YSIZE(dwt) / 2);
175  IDWT(dwt, aux);
176  // Copy the result to the 01 quadrant of the result
177  int x1, y1, x2, y2, x, y, i, j;
178  SelectDWTBlock(s, v, "01", x1, x2, y1, y2);
179  for (y = y1, i = 0; y <= y2; y++, i++)
180  for (x = x1, j = 0; x <= x2; x++, j++)
181  A2D_ELEM(result, y, x) = A2D_ELEM(aux, i, j);
182  }
183 }
#define YSIZE(v)
#define A2D_ELEM(v, i, j)
void resize(size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim, bool copy=true)
int Get_Max_Scale(int size)
Definition: wavelet.h:71
static double * y
doublereal * x
#define i
void DWT(const MultidimArray< T > &v, MultidimArray< double > &result, int isign=1)
Definition: wavelet.h:83
#define XSIZE(v)
#define j
void SelectDWTBlock(int scale, const MultidimArray< T > &I, const std::string &quadrant, int &x1, int &x2)
Definition: wavelet.h:134
void IDWT(const MultidimArray< double > &v, MultidimArray< double > &result)
Definition: wavelet.cpp:159
void initZeros(const MultidimArray< T1 > &op)

◆ Get_Max_Scale()

int Get_Max_Scale ( int  size)
inline

Get maximum scale.

This function returns the maximum scale achievable by the DWT transform of a given size.

Definition at line 71 of file wavelet.h.

72 {
73  return ROUND(log10(static_cast< double >(size)) / log10(2.0));
74 }
#define ROUND(x)
Definition: xmipp_macros.h:210
void log10(Image< double > &op)

◆ Get_Scale_Quadrant() [1/3]

void Get_Scale_Quadrant ( int  size_x,
int  x,
int &  scale,
std::string &  quadrant 
)

Get scale and quadrant 1D.

Given a point and the maximum size of the image, this routine returns the scale and quadrant it belongs.

Definition at line 248 of file wavelet.cpp.

250 {
251  double Nx = Get_Max_Scale(size_x);
252  quadrant = "x";
253  scale = DWT_Scale(x, Nx);
254  quadrant[0] = DWT_Quadrant1D(x, scale, Nx);
255 }
int Get_Max_Scale(int size)
Definition: wavelet.h:71
doublereal * x
#define DWT_Quadrant1D(i, s, smax)
Definition: wavelet.cpp:243
#define DWT_Scale(i, smax)
Definition: wavelet.cpp:242

◆ Get_Scale_Quadrant() [2/3]

void Get_Scale_Quadrant ( int  size_x,
int  size_y,
int  x,
int  y,
int &  scale,
std::string &  quadrant 
)

Get scale and quadrant 2D.

Given a point and the maximum size of the image, this routine returns the scale and quadrant it belongs.

Definition at line 257 of file wavelet.cpp.

259 {
260  double Nx = Get_Max_Scale(size_x);
261  double Ny = Get_Max_Scale(size_y);
262  quadrant = "xy";
263  double scalex = DWT_Scale(x, Nx);
264  double scaley = DWT_Scale(y, Ny);
265  scale = (int)(XMIPP_MIN(scalex, scaley));
266  quadrant[1] = DWT_QuadrantnD(y, scaley, scale, Ny);
267  quadrant[0] = DWT_QuadrantnD(x, scalex, scale, Nx);
268 }
int Get_Max_Scale(int size)
Definition: wavelet.h:71
static double * y
doublereal * x
#define DWT_QuadrantnD(i, s, sp, smax)
Definition: wavelet.cpp:244
#define DWT_Scale(i, smax)
Definition: wavelet.cpp:242
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181

◆ Get_Scale_Quadrant() [3/3]

void Get_Scale_Quadrant ( int  size_x,
int  size_y,
int  size_z,
int  x,
int  y,
int  z,
int &  scale,
std::string &  quadrant 
)

Get scale and quadrant 3D.

Given a point and the maximum size of the image, this routine returns the scale and quadrant it belongs.

Definition at line 270 of file wavelet.cpp.

273 {
274  double Nx = Get_Max_Scale(size_x);
275  double Ny = Get_Max_Scale(size_y);
276  double Nz = Get_Max_Scale(size_z);
277  quadrant = "xyz";
278  double scalex = DWT_Scale(x, Nx);
279  double scaley = DWT_Scale(y, Ny);
280  double scalez = DWT_Scale(z, Nz);
281  scale = (int)(XMIPP_MIN(scalez, XMIPP_MIN(scalex, scaley)));
282  quadrant[2] = DWT_QuadrantnD(z, scalez, scale, Nz);
283  quadrant[1] = DWT_QuadrantnD(y, scaley, scale, Ny);
284  quadrant[0] = DWT_QuadrantnD(x, scalex, scale, Nx);
285 }
int Get_Max_Scale(int size)
Definition: wavelet.h:71
static double * y
doublereal * x
#define DWT_QuadrantnD(i, s, sp, smax)
Definition: wavelet.cpp:244
#define DWT_Scale(i, smax)
Definition: wavelet.cpp:242
double z
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181

◆ IDWT()

void IDWT ( const MultidimArray< double > &  v,
MultidimArray< double > &  result 
)

IDWT of a MultidimArray.

The output volume can be the same as the input one. Previously the type of DWT must be set with set_DWT_type.

Definition at line 159 of file wavelet.cpp.

160 {
161  DWT(v, result, -1);
162 }
void DWT(const MultidimArray< T > &v, MultidimArray< double > &result, int isign=1)
Definition: wavelet.h:83

◆ phaseCongMono()

void phaseCongMono ( MultidimArray< double > &  I,
MultidimArray< double > &  PC,
MultidimArray< double > &  FT,
MultidimArray< double > &  Energy,
MultidimArray< double > &  lowPass,
MultidimArray< double > &  Radius,
MultidimArray< std::complex< double > > &  H,
int  nScale,
double  minWaveLength,
double  mult,
double  sigmaOnf 
)

Phase congruency filtering.

Phase congruency of an image using monogenic filters.

   I                     - Image to be processed
   PC                    - Phase congruency indicating edge significance
   FT                    - Local weighted mean phase angle at every point in the
                           image.  A value of pi/2 corresponds to a bright line, 0
                         corresponds to a step and -pi/2 is a dark line.
nscale            5    - Number of wavelet scales, try values 3-6
 minWaveLength    3    - Wavelength of smallest scale filter.
 mult             2.1  - Scaling factor between successive filters.
 sigmaOnf         0.55 - Ratio of the standard deviation of the Gaussian
                         describing the log Gabor filter's transfer function
                         in the frequency domain to the filter center frequency.

References:

Peter Kovesi, "Image Features From Phase Congruency". Videre: A Journal of Computer Vision Research. MIT Press. Volume 1, Number 3, Summer 1999 http://mitpress.mit.edu/e-journals/Videre/001/v13.html

Michael Felsberg and Gerald Sommer, "A New Extension of Linear Signal Processing for Estimating Local Properties and Detecting Features". DAGM Symposium 2000, Kiel

Michael Felsberg and Gerald Sommer. "The Monogenic Signal" IEEE Transactions on Signal Processing, 49(12):3136-3144, December 2001

Peter Kovesi, "Phase Congruency Detects Corners and Edges". Proceedings DICTA 2003, Sydney Dec 10-12

Definition at line 850 of file wavelet.cpp.

861 {
862 
863 // #define DEBUG
864  double epsilon= .0001; // Used to prevent division by zero.
865  //First we set the image origin in the image center
866  I.setXmippOrigin();
867  //Image size
868  size_t NR, NC,NZ, NDim;
869  I.getDimensions(NC,NR,NZ,NDim);
870 
871  if ( (NZ!=1) || (NDim!=1) )
872  REPORT_ERROR(ERR_MULTIDIM_DIM,(std::string)"ZDim and NDim has to be equals to one");
873 
875  // Fourier Transformer
876  FourierTransformer ftrans(FFTW_BACKWARD);//, ftransh(FFTW_BACKWARD), ftransf(FFTW_BACKWARD);
877  ftrans.FourierTransform(I, fftIm, false);
878 
879  if ( (lowPass.xinit == 0) & (lowPass.yinit == 0) & (Radius.xinit == 0) & (Radius.yinit == 0)
880  & (H.xinit == 0) & (H.yinit == 0) )
881  {
882 
883  H.resizeNoCopy(I);
884  lowPass.resizeNoCopy(I);
885  Radius.resizeNoCopy(I);
886 
887  double cutoff = .4;
888  double n = 10;
889  double wx,wy;
890 
891  for (int i=STARTINGY(I); i<=FINISHINGY(I); ++i)
892  {
893  FFT_IDX2DIGFREQ(i,YSIZE(I),wy);
894  double wy2=wy*wy;
895  for (int j=STARTINGX(I); j<=FINISHINGX(I); ++j)
896  {
897  FFT_IDX2DIGFREQ(j,XSIZE(I),wx);
898 
899  double wx2=wx*wx;
900  double radius=sqrt(wy2+wx2);
901  if (radius < 1e-10) radius=1;
902  A2D_ELEM(Radius,i,j)=radius;
903  auto *ptr=(double*)&A2D_ELEM(H,i,j);
904  *ptr=wy/radius;
905  *(ptr+1)=wx/radius;
906  A2D_ELEM(lowPass,i,j)= 1.0/(1.0+std::pow(radius/cutoff,n));
907  }
908 
909  }
910 
911  }
912 
913  MultidimArray<double> logGabor;
914  logGabor.resizeNoCopy(I);
915  //Bandpassed image in the frequency domain and in the spatial domain.
916  //h is a Bandpassed monogenic filtering, real part of h contains
917  //convolution result with h1, imaginary part
918  //contains convolution result with h2.
919  MultidimArray< std::complex <double> > fftImF, fullFftIm, f,Hc,h;
920 
921  fftImF.resizeNoCopy(I);
922  Hc.resizeNoCopy(I);
923  f.resizeNoCopy(I);
924  h.resizeNoCopy(I);
925 
926  MultidimArray<double> An,AnTemp;
931  MultidimArray<double> tempMat;
932 
933  temp.resizeNoCopy(I);
934  An.resizeNoCopy(I);
935  F.resizeNoCopy(I);
936  h1.resizeNoCopy(I);
937  h2.resizeNoCopy(I);
938  AnTemp.resizeNoCopy(I);
939  ftrans.getCompleteFourier(fullFftIm);
940  CenterFFT(fullFftIm,false);
941 
942  for (int num = 0; num < nScale; ++num)
943  {
944  double waveLength = minWaveLength;
945 
946  for(int numMult=0; numMult < num;numMult++)
947  waveLength*=mult;
948 
949  double fo = 1.0/waveLength;
950  FOR_ALL_ELEMENTS_IN_ARRAY2D(fullFftIm)
951  {
952  double temp1 =(std::log(A2D_ELEM(Radius,i,j)/fo));
953  double temp2 = std::log(sigmaOnf);
954  A2D_ELEM(logGabor,i,j) = std::exp(-(temp1*temp1) /(2 * temp2*temp2))*A2D_ELEM(lowPass,i,j);
955  if (A2D_ELEM(Radius,i,j)<=1e-10) (A2D_ELEM(logGabor,i,j)=0);
956 
957  auto *ptr= (double*)&A2D_ELEM(fullFftIm,i,j);
958  temp1 = *ptr;
959  temp2 = *(ptr+1);
960  ptr= (double*)&A2D_ELEM(fftImF,i,j);
961  *ptr=temp1*A2D_ELEM(logGabor,i,j);
962  *(ptr+1)=temp2*A2D_ELEM(logGabor,i,j);
963  }
964 
965  CenterFFT(fftImF,true);
966  Hc = fftImF*H;
967  ftrans.inverseFourierTransform(fftImF,f);
968  ftrans.inverseFourierTransform(Hc,h);
969 
970  //ftransf.setFourier(fftImF);
971  //ftransf.inverseFourierTransform();
972  //ftransh.setFourier(Hc);
973  //ftransh.inverseFourierTransform();
974 
975  f.getReal(temp);
976  F += temp;
977  AnTemp = temp*temp;
978 
979  h.getReal(temp);
980  h1 += temp;
981  AnTemp += temp*temp;
982 
983  h.getImag(temp);
984  h2 += temp;
985  AnTemp += temp*temp;
986 
987  AnTemp.selfSQRT();
988  An += AnTemp;
989  }
990 
991  Or.resizeNoCopy(I);
992  Or.setXmippOrigin();
993 
994  Ph.resizeNoCopy(I);
995  Ph.setXmippOrigin();
996 
997  Energy.resizeNoCopy(I);
998  Energy.setXmippOrigin();
999 
1001  {
1002  double temph1 = A2D_ELEM(h1,i,j);
1003  double temph2 = A2D_ELEM(h2,i,j);
1004  double tempF = A2D_ELEM(F,i,j);
1005 
1006  A2D_ELEM(Or,i,j) = std::atan2(temph1,temph2);
1007  A2D_ELEM(Ph,i,j)= std::atan2(tempF, std::sqrt(temph1*temph1+
1008  temph2*temph2));
1009  A2D_ELEM(Energy,i,j) = std::sqrt(tempF*tempF+temph1*temph1
1010  + temph2*temph2)+epsilon;
1011  }
1012 
1013 #ifdef DEBUG
1014 
1015  FileName fpName1 = "test1.txt";
1016  FileName fpName2 = "test2.txt";
1017  FileName fpName3 = "test3.txt";
1018  FileName fpName4 = "test4.txt";
1019 
1020  Or.write(fpName1);
1021  Ph.write(fpName2);
1022  Energy.write(fpName3);
1023 
1024  #endif
1025 }
#define YSIZE(v)
#define A2D_ELEM(v, i, j)
#define FINISHINGX(v)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
void resizeNoCopy(const MultidimArray< T1 > &v)
void sqrt(Image< double > &op)
i<=ncnstr;i++) cs[i].mult=0.e0;if(nfsip) for(i=1;i<=nob;i++) { ob[i].mult=0.e0;ob[i].mult_L=0.e0;} for(i=1;i<=nqpram;i++) { ii=k+i;if(clamda[ii]==0.e0 &&clamda[ii+nqpram]==0.e0) continue;else if(clamda[ii] !=0.e0) clamda[ii]=-clamda[ii];else clamda[ii]=clamda[ii+nqpram];} nqnp=nqpram+ncnstr;for(i=1;i<=nqpram;i++) param-> mult[i]
#define STARTINGX(v)
#define i
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
double temp2
#define STARTINGY(v)
void CenterFFT(MultidimArray< T > &v, bool forward)
Definition: xmipp_fft.h:291
void log(Image< double > &op)
double * f
#define XSIZE(v)
void write(const FileName &fn) const
__device__ float FFT_IDX2DIGFREQ(int idx, int size)
#define j
#define FINISHINGY(v)
void getReal(MultidimArray< double > &realImg) const
Incorrect MultidimArray dimensions.
Definition: xmipp_error.h:173
void getImag(MultidimArray< double > &imagImg) const
double epsilon
double radius
Spatial radius in Universal System units.
Definition: blobs.h:115
int * n
double temp1
void getDimensions(size_t &Xdim, size_t &Ydim, size_t &Zdim, size_t &Ndim) const

◆ Quadrant2D()

std::string Quadrant2D ( int  q)

Given a quadrant number it returns the string associated to it.

That is nothing more than its corresponding binary representation.

Definition at line 187 of file wavelet.cpp.

188 {
189  switch (q)
190  {
191  case 0:
192  return "00";
193  break;
194  case 1:
195  return "01";
196  break;
197  case 2:
198  return "10";
199  break;
200  case 3:
201  return "11";
202  break;
203  default:
204  REPORT_ERROR(ERR_ARG_INCORRECT,"Unknown quadrant");
205  }
206 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
Incorrect argument received.
Definition: xmipp_error.h:113

◆ Quadrant3D()

std::string Quadrant3D ( int  q)

Given a quadrant number it returns the string associated to it.

That is nothing more than its corresponding binary representation.

Definition at line 208 of file wavelet.cpp.

209 {
210  switch (q)
211  {
212  case 0:
213  return "000";
214  break;
215  case 1:
216  return "001";
217  break;
218  case 2:
219  return "010";
220  break;
221  case 3:
222  return "011";
223  break;
224  case 4:
225  return "100";
226  break;
227  case 5:
228  return "101";
229  break;
230  case 6:
231  return "110";
232  break;
233  case 7:
234  return "111";
235  break;
236  default:
237  REPORT_ERROR(ERR_ARG_INCORRECT,"Unknown quadrant");
238  }
239 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
Incorrect argument received.
Definition: xmipp_error.h:113

◆ SelectDWTBlock() [1/3]

template<typename T >
void SelectDWTBlock ( int  scale,
const MultidimArray< T > &  I,
const std::string &  quadrant,
int &  x1,
int &  x2 
)

Select Block 1D.

Given the scale (s=0 is the finest) and the quadrant "0" (Lower frequencies) or "1"(Higher frequencies) this routine returns the indices that should be explored for this block (x1 and x2 should be included in the for).

Definition at line 134 of file wavelet.h.

139 {
140  double Nx = Get_Max_Scale(XSIZE(I));
141  I.toLogical(DWT_Imin(scale, Nx, quadrant[0]), x1);
142  I.toLogical(DWT_Imax(scale, Nx, quadrant[0]), x2);
143 }
int Get_Max_Scale(int size)
Definition: wavelet.h:71
#define DWT_Imax(s, smax, l)
Definition: wavelet.h:124
#define DWT_Imin(s, smax, l)
Definition: wavelet.h:122
#define XSIZE(v)
void toLogical(int k_phys, int i_phys, int j_phys, int &k_log, int &i_log, int &j_log) const

◆ SelectDWTBlock() [2/3]

template<typename T >
void SelectDWTBlock ( int  scale,
const MultidimArray< T > &  I,
const std::string &  quadrant,
int &  x1,
int &  x2,
int &  y1,
int &  y2 
)

Select Block 2D.

Given the scale (s=0 is the finest) and the quadrant "xy"="00" (Upper left), "01" (Upper right), "10" (Lower left), "11" (Lower right). This routine returns the indices that should be explored for this block (the extremes should be included in the for).

Definition at line 153 of file wavelet.h.

160 {
161  double Nx = Get_Max_Scale(XSIZE(I));
162  double Ny = Get_Max_Scale(YSIZE(I));
163 
164  x1 = DWT_Imin(scale, Nx, quadrant[0]);
165  y1 = DWT_Imin(scale, Ny, quadrant[1]);
166  x2 = DWT_Imax(scale, Nx, quadrant[0]);
167  y2 = DWT_Imax(scale, Ny, quadrant[1]);
168 
169  I.toLogical(y1, x1, y1, x1);
170  I.toLogical(y2, x2, y2, x2);
171 }
#define YSIZE(v)
int Get_Max_Scale(int size)
Definition: wavelet.h:71
#define DWT_Imax(s, smax, l)
Definition: wavelet.h:124
#define DWT_Imin(s, smax, l)
Definition: wavelet.h:122
#define XSIZE(v)
void toLogical(int k_phys, int i_phys, int j_phys, int &k_log, int &i_log, int &j_log) const

◆ SelectDWTBlock() [3/3]

template<typename T >
void SelectDWTBlock ( int  scale,
const MultidimArray< T > &  I,
const std::string &  quadrant,
int &  x1,
int &  x2,
int &  y1,
int &  y2,
int &  z1,
int &  z2 
)

Select Block 3D.

Given the scale (s=0 is the finest) and the quadrant "xyz"="000", "001", "010", "011", "100", "101", "110", "111". This routine returns the indices that should be explored for this block (the extremes should be included in the for).

Definition at line 182 of file wavelet.h.

191 {
192  double Nx = Get_Max_Scale(XSIZE(I));
193  double Ny = Get_Max_Scale(YSIZE(I));
194  double Nz = Get_Max_Scale(ZSIZE(I));
195 
196  x1 = DWT_Imin(scale, Nx, quadrant[0]);
197  y1 = DWT_Imin(scale, Ny, quadrant[1]);
198  z1 = DWT_Imin(scale, Nz, quadrant[2]);
199  x2 = DWT_Imax(scale, Nx, quadrant[0]);
200  y2 = DWT_Imax(scale, Ny, quadrant[1]);
201  z2 = DWT_Imax(scale, Nz, quadrant[2]);
202 
203  I.toLogical(z1, y1, x1, z1, y1, x1);
204  I.toLogical(z2, y2, x2, z2, y2, x2);
205 }
#define YSIZE(v)
int Get_Max_Scale(int size)
Definition: wavelet.h:71
#define DWT_Imax(s, smax, l)
Definition: wavelet.h:124
#define DWT_Imin(s, smax, l)
Definition: wavelet.h:122
#define XSIZE(v)
#define ZSIZE(v)
void toLogical(int k_phys, int i_phys, int j_phys, int &k_log, int &i_log, int &j_log) const

◆ set_DWT_type()

void set_DWT_type ( int  DWT_type)

Set DWT type.

The DWT type should be set before starting making transforms. Valid types are: HAAR, DAUB4, DAUB12, DAUB20

Definition at line 154 of file wavelet.cpp.

155 {
156  pwtset(DWT_type);
157 }
void pwtset(int n)

◆ soft_thresholding()

void soft_thresholding ( MultidimArray< double > &  I,
double  th 
)

Soft thresholding .

Subtract a value from all coefficients, if the the value is greater than the absolute value of the coefficient, that coefficient is set to 0.

Definition at line 308 of file wavelet.cpp.

309 {
311  if (ABS(A3D_ELEM(I, k, i, j)) > th)
312  if (A3D_ELEM(I, k, i, j) > 0)
313  A3D_ELEM(I, k, i, j) -= th;
314  else
315  A3D_ELEM(I, k, i, j) += th;
316  else
317  A3D_ELEM(I, k, i, j) = 0;
318 }
#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 A3D_ELEM(V, k, i, j)
#define FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
#define ABS(x)
Definition: xmipp_macros.h:142
#define j