当前位置: 首页>>代码示例>>C++>>正文


C++ ImageData::GetChannelData方法代码示例

本文整理汇总了C++中ImageData::GetChannelData方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageData::GetChannelData方法的具体用法?C++ ImageData::GetChannelData怎么用?C++ ImageData::GetChannelData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageData的用法示例。


在下文中一共展示了ImageData::GetChannelData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Solve

ImageData IRLSMapSolver::Solve(const ImageData& initial_estimate) {
  const int num_pixels = GetNumPixels();
  const int num_channels = GetNumChannels();
  const cv::Size image_size = GetImageSize();
  CHECK_EQ(initial_estimate.GetNumPixels(), num_pixels);
  CHECK_EQ(initial_estimate.GetNumChannels(), num_channels);
  CHECK_EQ(initial_estimate.GetImageSize(), image_size);

  // If the split_channels option is set, loop over the channels here and solve
  // them independently. Otherwise, solve all channels at once.
  const int num_channels_per_split =
      solver_options_.split_channels ? 1 : num_channels;
  const int num_solver_rounds = num_channels / num_channels_per_split;
  const int num_data_points = num_channels_per_split * num_pixels;
  if (num_channels_per_split != num_channels) {
    LOG(INFO) << "Splitting up image into " << num_solver_rounds
              << " sections with " << num_channels_per_split
              << " channel(s) in each section.";
  }

  // Scale the option stop criteria parameters based on the number of
  // parameters and strength of the regularizers.
  IRLSMapSolverOptions solver_options_scaled = solver_options_;
  solver_options_scaled.AdjustThresholdsAdaptively(
      num_data_points, GetRegularizationParameterSum());

  if (IsVerbose()) {
    solver_options_scaled.PrintSolverOptions();
  }

  ImageData estimated_image;
  for (int i = 0; i < num_solver_rounds; ++i) {
    if (num_solver_rounds > 1) {
      LOG(INFO) << "Starting solver on image subset #" << (i + 1) << ".";
    }
    const int channel_start = i * num_channels_per_split;
    const int channel_end = channel_start + num_channels_per_split;

    // Copy the initial estimate data (within the appropriate channel range) to
    // the solver's array.
    alglib::real_1d_array solver_data;
    solver_data.setlength(num_data_points);
    for (int channel = 0; channel < num_channels_per_split; ++channel) {
      double* data_ptr = solver_data.getcontent() + (num_pixels * channel);
      const double* channel_ptr = initial_estimate.GetChannelData(
          channel_start + channel);
      std::copy(channel_ptr, channel_ptr + num_pixels, data_ptr);
    }

    // Set up the base objective function (just data term). The regularization
    // term depends on the IRLS weights, so it gets added in the IRLS loop.
    ObjectiveFunction objective_function_data_term_only(num_data_points);
    std::shared_ptr<ObjectiveTerm> data_term(new ObjectiveDataTerm(
        image_model_, observations_, channel_start, channel_end, image_size));
    objective_function_data_term_only.AddTerm(data_term);

    RunIRLSLoop(
        solver_options_scaled,
        objective_function_data_term_only,
        regularizers_,
        image_size,
        channel_start,
        channel_end,
        &solver_data);

    for (int channel = 0; channel < num_channels_per_split; ++channel) {
      const double* data_ptr =
          solver_data.getcontent() + (num_pixels * channel);
      estimated_image.AddChannel(data_ptr, image_size);
    }
  }

  return estimated_image;
}
开发者ID:teammcr192,项目名称:super-resolution,代码行数:74,代码来源:irls_map_solver.cpp


注:本文中的ImageData::GetChannelData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。