https://doi.org/10.5201/ipol.2020.245
Raw File
Tip revision: 5f23fb0b6e1d50d996ac54daaa7e637e5d8decaf authored by Software Heritage on 05 May 2020, 00:00:00 UTC
ipol: Deposit 1363 in collection ipol
Tip revision: 5f23fb0
main.c
/*
* main.c
*
* Copyright (C) 2019, Tristan Dagobert, CMLA, École Normale Supérieure Paris-Saclay.
*
* This software is a computer program.
* It is a part of a code which estimates, given a satellite time series
* the visibility of each image. Given a gray level time series, it provides a
* Boolean times series indicating the visibility (mainly the opaque clouds,
* haze and shadow).
*
*
* This software is governed by the CeCILL-C license under French law and
* abiding by the rules of distribution of free software.  You can  use,
* modify and/ or redistribute the software under the terms of the CeCILL-C
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and  rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty  and the software's author,  the holder of the
* economic rights,  and the successive licensors  have only  limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading,  using,  modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean  that it is complicated to manipulate,  and  that  also
* therefore means  that it is reserved for developers  and  experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and,  more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL-C license and that you accept its terms.
*
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>

#include "iio.h"
#include "stratus.h"
#include "utilities.h"
#include "process_command.h"
/*============================================================================*/
void
get_duration(struct timeval t0, struct timeval t1, int nb_ims)
{
    double duration =
        (((t1.tv_sec - t0.tv_sec) * 1000000 + t1.tv_usec) -
         t0.tv_usec) / 1000000.0;
    printf ("[INFO ]Execution time : %5.3f sec, %5.3f sec/image\n",
            duration, duration / nb_ims);
    return;
}
/*============================================================================*/
int
main (int argc, char *argv[])
{
    struct timeval t0, t1;

    gettimeofday (&t0, NULL);

    options_t * options = malloc(sizeof(options_t));
    criteria_t * criteria = malloc(sizeof(criteria_t));

    /* load options, filenames… */
    int quit;
    quit = process_command_line (argc, argv, criteria, options);
    if (quit == 1)
    {
        free(options);
        free(criteria);
        exit(EXIT_SUCCESS);
    }

    display_options_values(*options);

    int nb_ims = criteria->nb_ims; /* number of output images */

    /* load the files of each criterion… */
    load_criteria_image_series(criteria);
    display_files_series(*criteria);

    /* main processing */
    mappes_t mappes;
    mappes = compute_cloud_maps (criteria->c, *options);

    /* output the results */
    float **maps;
    int i;

    /* retrieve the output file names */
    criterion_t * cn = get_criterion(criteria->c, PREFIXE);
    int ncol = criteria->ncol;
    int nrow = criteria->nrow;

    char * filename;
    int maxlength, length;

    for (i=0, maxlength=0; i < nb_ims; i++)
    {
        length = strlen(cn->filenames[i]);
        maxlength = maxlength < length ? length : maxlength;
    }
    filename = malloc((maxlength + 20) * sizeof(char));

    maps = mappes.sift;
    if (maps != NULL)
    {
        for (i = 0; i < nb_ims; i++)
        {
            iio_save_image_float_split (cn->filenames[i], maps[i], ncol, nrow, 1);
        }
    }

    free(filename);

    delete_mappes(mappes, nb_ims);
    delete_criteria_t(criteria);
    free(options);
    free(criteria);

    gettimeofday (&t1, NULL);
    get_duration(t0, t1, nb_ims);
    exit (EXIT_SUCCESS);
}
back to top