/* Parsing and handling gamma arguments. */ /* Last edited on 2016-04-12 13:22:12 by stolfilocal */ #ifndef dsm_gamma_H #define dsm_gamma_H #define _GNU_SOURCE #include #include #include #define dsm_gamma_MIN 0.10 #define dsm_gamma_MAX 10.0 /* Min and max allowed values of the {gamma} parameter. */ double dsm_gamma_pick_parameter(const char *p_name, double p_given, double p_file, double p_default, bool_t verbose); /* Chooses the gamma or bias to be used for decoding an input file. The result is the client-given value {p_given} if not {NAN}, else the value {p_file} specified implicitly or implicitly in the input file if not {NAN}, else the default value {p_default}. Prints the choice if verbose, using the string {p_name} as the parameter's name. */ /* COMMAND LINE PARSING */ double dsm_gamma_arg_parse(argparser_t *pp, const char *keyword); /* Looks for a command line argument equal to {keyword} and parses the next argument as gamma argument, according to the string {dsm_gamma_arg_INFO} below. Otherwise returns {NAN}. */ #define dsm_gamma_arg_INFO \ "This argument specifies the nonlinearity" \ " exponent (\"gamma\") of the pixel encoding used in the" \ " images. It is used to convert" \ " the integer sample values in the files to" \ " fractional intensity values in memory, and vice-versa. This argument is optional for input images in PNG, PGM, or PPM" \ " format, in which case, if given, it overrides the gamma specified" \ " in the file. This argument is mandatory for the JPEG image format." #endif