void write_ppm()

in dedupe_estimator.cpp [472:491]


void write_ppm(const std::vector<RGB>& colors, const std::string& filename) {
  std::ofstream fout(filename.c_str());
  if (!fout.good()) {
    std::cerr <<"Unable to write to file: " << filename << std::endl;
    return;
  }
  fout << "P6\n";
  fout << IMAGE_DIM << " " << IMAGE_DIM << "\n";
  fout << "255\n";
  // each position in colors is an 1x8 block in the image
  for (size_t i = 0;i < IMAGE_DIM; ++i) {
    for (size_t j = 0;j < IMAGE_DIM; ++j) {
      size_t block_x = i / BLOCK_DIM;
      size_t block_y = j;
      size_t block_idx = block_x * IMAGE_DIM  + block_y;
      RGB color = colors[block_idx];
      fout << color.r << color.g << color.b;
    }
  }
}