/** * \file FFToperations.cpp * \brief operations involving FFT Copyright 2007-2010 IMP Inventors. All rights reserved. **/ #include "IMP/em2D/FFToperations.h" #include "IMP/em/Image.h" #include "IMP/em/SpiderReaderWriter.h" IMPEM2D_BEGIN_NAMESPACE void correlation2D(algebra::Matrix2D_d &m1, algebra::Matrix2D_d &m2, algebra::Matrix2D_d &corr) { IMP_LOG(IMP::VERBOSE,"Computing 2D correlation " < x1 = M1.data()[i]; std::complex x2 = M2.data()[i]; M2.data()[i] = x1*std::conj(x2); } IFFT2D ifft(M2,corr); ifft.execute(); // corr contains the correlation matrix matrix_to_image_interpretation(corr); if(IMP::get_log_level()==IMP::VERBOSE) { } } void correlation2D_no_preprocessing( algebra::Matrix2D_c &M1, algebra::Matrix2D_c &M2, algebra::Matrix2D_d &corr) { IMP_LOG(IMP::VERBOSE,"Computing 2D correlation with no preprocessing" < x1 = M1.data()[i]; std::complex x2 = M2.data()[i]; CORR.data()[i] = x1*std::conj(x2); } IFFT2D ifft(CORR,corr);ifft.execute(); //corr contains the correlation matrix matrix_to_image_interpretation(corr); } void autocorrelation2D(algebra::Matrix2D_d& m, algebra::Matrix2D_d& corr) { IMP_LOG(IMP::VERBOSE,"Computing 2D autocorrelation" < > &m, std::ostream &out) { for (int k = m.get_start(0);k <= m.get_finish(0);k++) { if (m.get_size(0) > 1) { std::cout << "Slice No. " << k << std::endl; } for (int j = m.get_start(1);j <= m.get_finish(1);j++) { for (int i = m.get_start(2);i <= m.get_finish(2);++i) { out << m(k,j,i) << ' '; } out << std::endl; } } } void Matrix2D_c_to_img(algebra::Matrix2D_c &M,String name) { em::SpiderImageReaderWriter srw; em::Image img; img.resize(M.get_size(0),M.get_size(1)); for(unsigned long i=0;i