示例#1
0
文件: align2D.cpp 项目: salilab/imp
ResultAlign2D get_complete_alignment_no_preprocessing(
    const cv::Mat &input, const cv::Mat &INPUT, const cv::Mat &POLAR1,
    cv::Mat &m_to_align, const cv::Mat &POLAR2, bool apply) {

  IMP_LOG_TERSE("starting complete 2D alignment with no preprocessing"
                << std::endl);

  cv::Mat aux1, aux2, aux3, aux4;  // auxiliary matrices
  cv::Mat AUX1, AUX2, AUX3;        // ffts
  algebra::Transformation2D transformation1, transformation2;
  double angle1 = 0, angle2 = 0;
  ResultAlign2D RA = get_rotational_alignment_no_preprocessing(POLAR1, POLAR2);
  angle1 = RA.first.get_rotation().get_angle();
  get_transformed(m_to_align, aux1, RA.first);  // rotate
  get_fft_using_optimal_size(aux1, AUX1);
  RA = get_translational_alignment_no_preprocessing(INPUT, AUX1);
  algebra::Vector2D shift1 = RA.first.get_translation();
  transformation1.set_rotation(angle1);
  transformation1.set_translation(shift1);
  get_transformed(m_to_align, aux2, transformation1);  // rotate
  double ccc1 = get_cross_correlation_coefficient(input, aux2);
  // Check the opposed angle
  if (angle1 < PI) {
    angle2 = angle1 + PI;
  } else {
    angle2 = angle1 - PI;
  }
  algebra::Rotation2D R2(angle2);
  algebra::Transformation2D tr(R2);
  get_transformed(m_to_align, aux3, tr);  // rotate
  get_fft_using_optimal_size(aux3, AUX3);

  RA = get_translational_alignment_no_preprocessing(INPUT, AUX3);
  algebra::Vector2D shift2 = RA.first.get_translation();
  transformation2.set_rotation(angle2);
  transformation2.set_translation(shift2);
  get_transformed(m_to_align, aux3, transformation2);
  double ccc2 = get_cross_correlation_coefficient(input, aux3);

  if (ccc2 > ccc1) {
    if (apply) {
      aux3.copyTo(m_to_align);
    }
    IMP_LOG_VERBOSE(" Align2D complete Transformation= "
                    << transformation2 << " cross_correlation = " << ccc2
                    << std::endl);
    return ResultAlign2D(transformation2, ccc2);
  } else {
    if (apply) {
      aux3.copyTo(m_to_align);
    }
    IMP_LOG_VERBOSE(" Align2D complete Transformation= "
                    << transformation1 << " cross_correlation = " << ccc1
                    << std::endl);
    return ResultAlign2D(transformation1, ccc1);
  }
}
示例#2
0
void ProjectionFinder::do_preprocess_subject(unsigned int i) {
  IMP_LOG_TERSE("ProjectionFinder: Preprocessing subject " << i << std::endl);

  if (params_.coarse_registration_method == ALIGN2D_PREPROCESSING) {
    cv::Mat autoc, polar_autoc;
    get_fft_using_optimal_size(subjects_[i]->get_data(), SUBJECTS_[i]);
    get_autocorrelation2d(subjects_[i]->get_data(), autoc);
    do_resample_polar(autoc, polar_autoc, polar_params_);
    get_fft_using_optimal_size(polar_autoc, SUBJECTS_POLAR_AUTOC_[i]);
  }
  if (params_.coarse_registration_method == ALIGN2D_WITH_CENTERS) {
    do_preprocess_for_fast_coarse_registration(
        subjects_[i]->get_data(), subjects_cog_[i], SUBJECTS_POLAR_AUTOC_[i]);
  }
}
示例#3
0
void ProjectionFinder::do_preprocess_projection(unsigned int j) {
  IMP_LOG_TERSE("ProjectionFinder: Preprocessing projection " << j
          << std::endl);
  // FFT PREPROCESSING
  if(params_.coarse_registration_method == ALIGN2D_PREPROCESSING) {
    cv::Mat autoc,polar_autoc;
    em2d::get_autocorrelation2d(projections_[j]->get_data(),autoc);
    em2d::do_resample_polar(autoc,polar_autoc,polar_params_);
    get_fft_using_optimal_size(polar_autoc,PROJECTIONS_POLAR_AUTOC_[j]);
  }
  // CENTERS OF GRAVITY AND ROTATIONAL FFT PREPROCESSING
  if(params_.coarse_registration_method == ALIGN2D_WITH_CENTERS) {
    do_preprocess_for_fast_coarse_registration(projections_[j]->get_data(),
                                           projections_cog_[j],
                                           SUBJECTS_POLAR_AUTOC_[j]);
  }
}