htpp

htrdr-image post-processing
git clone git://git.meso-star.fr/htpp.git
Log | Files | Refs | README | LICENSE

commit 0508bdc98c9d4e91a606c93aa0f0604f5cfbd1e9
parent 63e53e4ee27f9783374484a62330c8fc57277525
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 17 Apr 2019 11:56:11 +0200

Merge branch 'release_0.1'

Diffstat:
MREADME.md | 18+++++++++++++-----
Mcmake/CMakeLists.txt | 4++--
Mdoc/htpp.1.txt | 6+++++-
Msrc/htpp.c | 61++++++++++++++++++++++++++++++++++++++++++++-----------------
4 files changed, 64 insertions(+), 25 deletions(-)

diff --git a/README.md b/README.md @@ -27,12 +27,20 @@ resulting project can be edited, built, tested and installed as any CMake project. Refer to the [CMake](https://cmake.org/documentation) for further informations on CMake. +## Release notes + +### Version 0.1 + +- Handle the update of the htrdr-image file format introduced by + [htrdr](https://gitlab.com/meso-star/htrdr/) 0.1 that adds to each pixel the + estimation of the per realisation path computation time. + ## License -htpp is a free software copyright (C) 2018 Centre National de la Recherche +htpp copyright (C) 2018-2019 Centre National de la Recherche (CNRS), [|Meso|Star>](https://www.meso-star.com) <contact@meso-star.com>, -Université Paul Sabatier <contact-edstar@laplace.univ-tlse.fr>. It is released -under the GPL v3+ license: GNU GPL version 3 or later. You are welcome to -redistribute it under certain conditions; refer to the COPYING file for -details. +Université Paul Sabatier <contact-edstar@laplace.univ-tlse.fr>. It is free +software released under the GPL v3+ license: GNU GPL version 3 or later. You +are welcome to redistribute it under certain conditions; refer to the COPYING +file for details. diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2018 CNRS, |Meso|Star>, Université Paul Sabatier +# Copyright (C) 2018-2019 CNRS, |Meso|Star>, Université Paul Sabatier # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -35,7 +35,7 @@ include_directories(${RSys_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) # Configure and define targets ################################################################################ set(VERSION_MAJOR 0) -set(VERSION_MINOR 0) +set(VERSION_MINOR 1) set(VERSION_PATCH 0) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) diff --git a/doc/htpp.1.txt b/doc/htpp.1.txt @@ -1,4 +1,4 @@ -// Copyright (C) 2018 CNRS, |Meso|Star>, Université Paul Sabatier +// Copyright (C) 2018-2019 CNRS, |Meso|Star>, Université Paul Sabatier // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -79,6 +79,10 @@ OPTIONS regular colors but no XYZ to sRGB conversion is applied on the tone mapped values. +*-T*:: + Generate an image of the per radiative path computation time rather than an + image of the estimated radiance. + *-t* _threads-count_:: Hint on the number of threads to use. By default use as many threads as CPU cores. diff --git a/src/htpp.c b/src/htpp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 CNRS, |Meso|Star>, Université Paul Sabatier +/* Copyright (C) 2018-2019 CNRS, |Meso|Star>, Université Paul Sabatier * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,18 +30,24 @@ #include <sys/stat.h> /* S_IRUSR & S_IWUSR */ #include <unistd.h> /* getopt */ +enum pixel_data { + PIXEL_RADIANCE, + PIXEL_UNCERTAINTY, + PIXEL_TIME +}; + struct args { const char* input; const char* output; double exposure; double white_scale; - int uncertainties; + enum pixel_data pixdata; int verbose; int force_overwrite; int nthreads; int quit; }; -#define ARGS_DEFAULT__ {NULL,NULL,1.0,-1.0,0,0,0,INT_MAX,0} +#define ARGS_DEFAULT__ {NULL,NULL,1.0,-1.0,PIXEL_RADIANCE,0,0,INT_MAX,0} static const struct args ARGS_DEFAULT = ARGS_DEFAULT__; struct img { @@ -77,7 +83,9 @@ print_help(const char* cmd) " -o OUTPUT write PPM image to OUTPUT. If not defined, write results\n" " to standard output.\n"); printf( -" -u dump per channel uncertainties rather than luminance.\n"); +" -u dump per channel uncertainties rather than radiance.\n"); + printf( +" -T dump per realiastion time rather than radiance.\n"); printf( " -t THREADS hint on the number of threads to use. By default use as\n" " many threads as CPU cores.\n"); @@ -90,7 +98,7 @@ print_help(const char* cmd) " --version display version information and exit.\n"); printf("\n"); printf( -"htpp (C) 2018 CNRS, |Meso|Star> <contact@meso-star.com>, Université Paul\n" +"htpp (C) 2018-2019 CNRS, |Meso|Star> <contact@meso-star.com>, Université Paul\n" "Sabatier <contact-edstar@laplace.univ-tlse.fr>. This is free software released\n" "under the GNU GPL license, version 3 or later. You are free to change or\n" "redistribute it under certain conditions <http://gnu.org/licenses/gpl.html>.\n"); @@ -122,7 +130,7 @@ args_init(struct args* args, const int argc, char** argv) } } - while((opt = getopt(argc, argv, "e:fho:t:uvw:")) != -1) { + while((opt = getopt(argc, argv, "e:fho:Tt:uvw:")) != -1) { switch(opt) { case 'e': res = cstr_to_double(optarg, &args->exposure); @@ -135,11 +143,12 @@ args_init(struct args* args, const int argc, char** argv) args->quit = 1; goto exit; case 'o': args->output = optarg; break; + case 'T': args->pixdata = PIXEL_TIME; break; case 't': res = cstr_to_int(optarg, &args->nthreads); if(res == RES_OK && args->nthreads <= 0) res = RES_BAD_ARG; break; - case 'u': args->uncertainties = 1; break; + case 'u': args->pixdata = PIXEL_UNCERTAINTY; break; case 'v': args->verbose = 1; break; case 'w': res = cstr_to_double(optarg, &args->white_scale); @@ -339,7 +348,7 @@ img_release(struct img* img) static res_T img_load (struct img* img, - const int uncertainties, /* Load uncertainties rather than color */ + const enum pixel_data pixdata, FILE* stream, const char* stream_name) { @@ -382,7 +391,7 @@ img_load FOR_EACH(y, 0, img->height) { double* row = (double*)(img->pixels + y*img->pitch); FOR_EACH(x, 0, img->width) { - double tmp[6]; + double tmp[8] = {0}; double* pixel = row + x*3; if(!read_line(&b, stream)) { fprintf(stderr, @@ -391,15 +400,31 @@ img_load res = RES_IO_ERR; goto error; } - if(cstr_to_list_double(b, ' ', tmp, 0, 6) != RES_OK) { - fprintf(stderr, "%s: invalid XYZ value for the (%lu, %lu) pixel.\n", + if(cstr_to_list_double(b, ' ', tmp, 0, 8) != RES_OK /* X, Y, Z, Time */ + && cstr_to_list_double(b, ' ', tmp, 0, 6) != RES_OK /* X, Y, Z */) { + fprintf(stderr, "%s: invalid XYZ[Time] value for the (%lu, %lu) pixel.\n", stream_name, (unsigned long)x, (unsigned long)y); res = RES_BAD_ARG; goto error; } - pixel[0] = tmp[uncertainties+0]; - pixel[1] = tmp[uncertainties+2]; - pixel[2] = tmp[uncertainties+4]; + switch(pixdata) { + case PIXEL_RADIANCE: + pixel[0] = tmp[0]; + pixel[1] = tmp[2]; + pixel[2] = tmp[4]; + break; + case PIXEL_UNCERTAINTY: + pixel[0] = tmp[1]; + pixel[1] = tmp[3]; + pixel[2] = tmp[5]; + break; + case PIXEL_TIME: + pixel[0] = tmp[6]; + pixel[1] = tmp[6]; + pixel[2] = tmp[6]; + break; + default: FATAL("Unreachable code.\n"); break; + } img->Yrange[0] = MMIN(img->Yrange[0], pixel[1]); img->Yrange[1] = MMAX(img->Yrange[1], pixel[1]); } @@ -497,6 +522,7 @@ main(int argc, char** argv) struct img img = IMG_NULL; struct args args = ARGS_DEFAULT; double Ymax; + int img_is_loaded = 0; int err = 0; int64_t i; res_T res = RES_OK; @@ -518,8 +544,9 @@ main(int argc, char** argv) fprintf(stderr, "Read image from standard input.\n"); } - res = img_load(&img, args.uncertainties, stream_in, stream_in_name); + res = img_load(&img, args.pixdata, stream_in, stream_in_name); if(res != RES_OK) goto error; + img_is_loaded = 1; if(args.white_scale > 0) { Ymax = args.white_scale; @@ -538,7 +565,7 @@ main(int argc, char** argv) double* pixel = row + x*3; filmic_tone_mapping(pixel, args.exposure, Ymax); /* Tone map the RGB pixel */ - if(!args.uncertainties) { + if(args.pixdata == PIXEL_RADIANCE) { XYZ_to_RGB(pixel); /* Convert in RGB color space */ RGB_to_sRGB(pixel); /* Convert in sRGB color space (i.e. gamma correction) */ } @@ -550,8 +577,8 @@ main(int argc, char** argv) exit: if(stream_out && stream_out != stdout) fclose(stream_out); if(stream_in && stream_in != stdin) fclose(stream_in); + if(img_is_loaded) img_release(&img); args_release(&args); - img_release(&img); return err; error: err = -1;