Elaboradar 0.1
|
◆ write_subimage() [1/2]
Write an image in a raw file in ${dir_env_var}, with the acquisition date as file name and the given extension. Image matrix is tranformed in out_image(x,image.cols()-1-y) = image(y, x);
Definizione alla linea 569 del file assets.cpp. 570{
571 const char* dir = getenv(dir_env_var);
572 if (!dir)
573 {
574 LOG_INFO("$%s not set", dir_env_var);
575 throw runtime_error("required env var is not set");
576 }
577
578 string fname = string(dir) + "/" + fname_from_acq_time() + "_" + std::to_string(image_side) + ext;
580
581 LOG_INFO("aperto file %s dimensione matrice %zd\n", fname.c_str(), image.size());
582
583 // Convert to south-north columns scanned west to east
584 unsigned xofs = (image.cols() - image_side) / 2;
585 unsigned yofs = (image.rows() - image_side) / 2;
586 //LOG_INFO(" Image_size %4d , Image.cols %4d Image.Rows %4d -- xofs %d yofs %d", image_side, image.cols(), image.rows(), xofs, yofs);
587 Matrix2D<unsigned char> transformed(image_side, image_side);
588 for (unsigned y = 0; y < image_side; ++y)
589 for (unsigned x = 0; x < image_side; ++x)
590 transformed(x, image_side-1-y) = image(y + yofs, x + xofs);
591
592 if (fwrite(transformed.data(), transformed.size(), 1, out) != 1)
593 {
594 LOG_WARN("cannot write to %s: %s", fname.c_str(), strerror(errno));
595 fclose(out);
596 throw std::runtime_error("cannot write to image file");
597 }
598
599 fclose(out);
600}
std::string fname_from_acq_time() const Build a basename (without extension) for a file given the current acquisition time. Definition assets.cpp:531 FILE * fopen_checked(const char *fname, const char *mode, const char *description) A wrapper of fopen that throws an exception if it cannot open the file. Definition utils.cpp:144 Referenzia fname_from_acq_time(), e radarelab::fopen_checked(). |