From 53f6ce5d715768db64760fd11572d678697be829 Mon Sep 17 00:00:00 2001 From: Franco Comida Date: Wed, 31 Aug 2016 23:10:00 +0200 Subject: [PATCH] [CMAKE]: optionally enabling building of test code (-DENABLE_UNIT_TEST=ON). [DOCS]: update INSTALL README.md README.i18n [TonemappingOperators]: uniform interface (code enabled only if "Debug" is active, checking of missing pfs channels). --- CMakeLists.txt | 8 +- INSTALL | 113 +++++++++++------- README.i18n | 2 +- README.md | 2 +- .../ashikhmin02/pfstmo_ashikhmin02.cpp | 8 +- .../drago03/pfstmo_drago03.cpp | 10 +- .../fattal02/pfstmo_fattal02.cpp | 6 +- .../mantiuk06/pfstmo_mantiuk06.cpp | 9 +- .../mantiuk08/pfstmo_mantiuk08.cpp | 12 +- .../pattanaik00/pfstmo_pattanaik00.cpp | 4 +- .../reinhard02/pfstmo_reinhard02.cpp | 2 +- .../reinhard05/pfstmo_reinhard05.cpp | 4 +- 12 files changed, 117 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e478c646..d22ee33ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,10 +155,12 @@ SET(LUMINANCE_HDR_H ${LUMINANCE_HDR_H} SET(LUMINANCE_HDR_RCCS icons.qrc) QT5_ADD_RESOURCES(LUMINANCE_HDR_RCCS_SRCS ${LUMINANCE_HDR_RCCS}) -ENABLE_TESTING() - ADD_SUBDIRECTORY(src) -ADD_SUBDIRECTORY(test) + +IF(ENABLE_UNIT_TEST) + ENABLE_TESTING() + ADD_SUBDIRECTORY(test) +ENDIF(ENABLE_UNIT_TEST) # translations FILE(GLOB LUMINANCE_TS i18n/lang_*.ts) diff --git a/INSTALL b/INSTALL index 327c6db57..35a8c9bd5 100644 --- a/INSTALL +++ b/INSTALL @@ -1,34 +1,40 @@ -This is the README file for Luminance HDR +This is the INSTALL file for Luminance HDR ------------------------------------------------------------------- Copyright (C) 2006-2010, Giuseppe Rota - 2010-2014, Davide Anastasia - Franco Comida + 2010-2016, Davide Anastasia + Franco Comida + Webpage: http://qtpfsgui.sourceforge.net +GitHub: http://github.com/LuminanceHDR/LuminanceHDR Sourceforge: http://sourceforge.net/projects/qtpfsgui + + Contents --------- 1. Basic compilation of the sources -2. Dependencies -3. Compiling the sources +2. Internationalization +3. Dependencies +4. Enabling Unit Test compilation +5. Note for Packagers -Last update: 2014.01.26 +Last update: 2016.08.31 The build system is based on CMake (http://www.cmake.org/). The build description is contained in the CMakeLists.txt file. 1. Basic compilation ------------------------------------------------------------------- -To compile from source, first execute from an EMPTY folder the command: +To compile from source execute the following command from an EMPTY folder: > cmake -to generate the Makefile. We strongly suggest to use an EMPTY folder OUTSIDE of the source +to generate the Makefile. We strongly suggest to use an EMPTY folder OUTSIDE the source directory. -It is also possible to generate specific project files for well known IDE (Visual Studio, +It is also possible to generate specific project files for well known IDEs (Visual Studio, Xcode and so on). Please, refer to CMake's manual for all the available options. -CMake will also check whether all the dependecies are available or not, and it will show +CMake will also check whether all the dependecies are available or not and it will show a message accordingly. Then execute the command: @@ -42,22 +48,20 @@ Finally execute (as root) the command: > make install to install the luminance executable in /usr/local/bin (if not differently specified during -the configuration command). This last step also installs the icon, the desktop file, -the html documentation and the "qm" translation files. This last step is usually required -in order for Luminance HDR to locate the "qm" files used for internationalization. +the configuration command). This last step will also install the icon, the desktop file, +the html documentation and the "qm" translation files used for internationalization. 2. Internationalization ------------------------------------------------------------------- -Luminance HDR source are shipped with update translation files for internationalization. -These file are stored inside the folder "i18n". They are usually updated. Should you make -a change inside the source code (in particular on the UI), you need to update them. To -enable the update of the translations, you must configure CMake to do so, with the -following command: +Luminance HDR source are shipped with updated translation files for internationalization. +These file are stored inside the folder "i18n". Should you make a change inside the source code +(in particular on the UI), you need to update them. +Enabling updating of translations is performed issuing the following command: > cmake -DUPDATE_TRANSLATIONS=ON . if the current working directory (please, refer to 1. of this file) has already been -build, otherwise: +built, otherwise: > cmake -DUPDATE_TRANSLATIONS=ON @@ -77,47 +81,69 @@ and then to build correctly the whole source directory. + 3. Dependencies ------------------------------------------------------------------- -Luminance has 7 dependencies: +Luminance has 12 dependencies (eleven are mandatory, one is optional): + 1) Qt5 (http://qt-project.org) Qt5 is the heart of the the graphical user interface (GUI). In the case of the Windows version, Qt version must agree with the final building environment (Visual Studio or *** deprecated *** MinGW) 2) exiv2 (www.exiv2.org) -libexiv2 is a C/C++ library used to extract EXIF tags from LDR and RAW image files, and is +libexiv2 is a C/C++ library used to extract EXIF tags from LDR and RAW image files, and it is required in order to extract the aperture, exposure-time and ISO tags from the input images (and for other EXIF-related functionalities). 3) fftw3 (www.fftw.org) -FFTW is required by the fast implementation of Durand tonemapping algorithm. Luminance -requires the "float" version of fftw3 (usually called fftw3f or fftw3-single on MacPorts). +FFTW is required by the fast implementation of various tonemapping algorithm and anti-ghosting feature. +Luminance HDR requires the "float" version of fftw3 (usually called fftw3f or fftw3-single on MacPorts). 4) libtiff (http://www.remotesensing.org/libtiff) libtiff is required because of the tiff load/save feature. -5) OpenEXR (www.openexr.com) +5) libjpeg (http://libjpeg.sourceforge.net/) +libjpeg is required because of the jpeg load/save feature. + +6) libpng (http://libpng.org/) +libpng is required because of the png save feature. + +7) OpenEXR (www.openexr.com) OpenEXR is a high dynamic-range (HDR) image file format developed by Industrial Light & Magic for use in computer imaging applications. The package is also known as *ilmbase* in some GNU/Linux distributions. -6) Gnu Gsl (http://www.gnu.org/software/gsl/) +8) Gnu Gsl (http://www.gnu.org/software/gsl/) Gnu GSL is required because Mantiuk08 TMO uses this library. -7) LibRAW (http://www.libraw.org/) +9) LibRAW (http://www.libraw.org/) Used to read the vast majority of RAW file on the market. +10) LCMS2 (http://www.littlecms.com/) +Luminance HDR color management engine. + +11) Boost (http://www.boost.org/) +Boost provides free peer-reviewed portable C++ source libraries used inside Luminance HDR project. + +12) cfitsio (Optional) (http://heasarc.gsfc.nasa.gov/fitsio/) +CFITSIO is a library of C and Fortran subroutines for reading and writing data files in FITS +(Flexible Image Transport System) data format. +Luminance HDR can optionally support this file format commonly used by the astrophotographers community. +The build system will automatically detect the presence of the library in the system enabling proper support +for astronomical image processing. + + Windows: -Currently, Luminance HDR can be compiled using Microsoft Visual Studio. It both works +Currently, Luminance HDR can be compiled using Microsoft Visual Studio. It either works using precompiled libraries (supplied at http://sourceforge.net/projects/qtpfsgui/files/DEPs/ for different versions of -Visual Studio) or build entirely every dependency and Luminance itself using a script file +Visual Studio) or building every dependency and Luminance itself using a script file (build/msvc/getDependencies.cmd. More information can be found inside build/msvc/README.txt). -NOTE: depending on your compiler (MinGW GCC or MS Visual Studio), you must download the -proper version of Qt, or build it yourself accordingly. +NOTE: depending on your compiler (MinGW GCC or MS Visual Studio), you must either download the +proper version of Qt or build it yourself accordingly. GNU/Linux: On GNU/Linux you have to compile the code and you need the aforementioned packages @@ -125,12 +151,17 @@ On GNU/Linux you have to compile the code and you need the aforementioned packag CMake will guide you to correctly understand which dependency are missing and which are not. Mac OS X: -On Mac OS X, all the dependecies can be obtained using MacPorts, except LibRAW, which -needs to compiled straight from source, and Qt5, which must be download from the official +On Mac OS X, all the dependecies can be obtained using MacPorts, except LibRAW that +must be compiled straight from source, and Qt5 which must be downloaded from the official website of the Qt project. +4. Enabling Unit Test compilation +------------------------------------------------------------------- +In order to enable the compilation of our testing code pass -DENABLE_UNIT_TEST=ON option to cmake. +Google's framework 'gtest' must be installed in your system, the resulting test executables +will be placed under /test where is your building root directory. -4. Note for Packagers +5. Note for Packagers ------------------------------------------------------------------- Luminance's default installation prefix is "/usr/local". You can execute: @@ -138,15 +169,15 @@ Luminance's default installation prefix is "/usr/local". You can execute: before running make in order to modify the default CMAKE_INSTALL_PREFIX. -Icon luminance.png will be installed in ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/48x48/apps. +Icon luminance-hdr.png will be installed in ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/48x48/apps. You may need to run update-desktop-database in case Luminance's entry doesn't show up -in the graphical menus. Translation files will be installed inside -${CMAKE_INSTALL_PREFIX}/share/luminance/i18n. Help files will be installed inside -${CMAKE_INSTALL_PREFIX}/share/luminance/help. +in the graphical menus. +Translation files will be installed inside ${CMAKE_INSTALL_PREFIX}/share/luminance-hdr/i18n +Help files will be installed inside ${CMAKE_INSTALL_PREFIX}/share/luminance-hdr/help Running: -> qmake -DCMAKE_BUILD_TYPE={Debug,Release,RelWithDebInfo} +> cmake -DCMAKE_BUILD_TYPE={Debug,Release,RelWithDebInfo} creates a Makefile that builds Luminance with different debug levels. It is strongly suggest to use *RelWithDebInfo*: this option will leave inside the final executable all @@ -158,10 +189,10 @@ In GNU/Linux you have to compile the code and you need the packages mentioned in (and the *devel* or *dev* ones, depending on the distribution's naming convention). If you want to compile the sources in windows, you need to have a compiled version of all the dependencies. -Building Luminance from sources on Mac OS X can be performed build a Makefile or an Xcode -project using CMake. By default, CMake builds a Makefile on Mac OS X. +Building Luminance from sources on Mac OS X can be performed creating a Makefile or an Xcode +project using CMake. By default, CMake creates a Makefile on Mac OS X. -OpenMP is only available if compiling with GCC 4.3 or newer and Microsoft Visual Studio +OpenMP is only available if compiling with GCC 4.3 or newer or with Microsoft Visual Studio (CMake will correctly find the right option for OpenMP accordingly to your compiler). Optimisation note: the default compiler flags include SSE2 and [Linux only] OpenMP. diff --git a/README.i18n b/README.i18n index 90edb4071..12b27b387 100644 --- a/README.i18n +++ b/README.i18n @@ -1,4 +1,4 @@ -This is the README file for translations (i18n) for Luminance HDR +This is the README file for contributing translations (i18n) to Luminance HDR ------------------------------------------------------------------- Contents diff --git a/README.md b/README.md index 53874f69a..d0fd0ead6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Luminance HDR =============== -Copyright (C) 2010-2015 - Davide Anastasia , Franco Comida , Daniel Kaneider and many contributors and translators +Copyright (C) 2010-2016 - Davide Anastasia , Franco Comida , Daniel Kaneider and many contributors and translators Copyright (C) 2006-2010 - Giuseppe Rota diff --git a/src/TonemappingOperators/ashikhmin02/pfstmo_ashikhmin02.cpp b/src/TonemappingOperators/ashikhmin02/pfstmo_ashikhmin02.cpp index f9a51c203..d880e0907 100644 --- a/src/TonemappingOperators/ashikhmin02/pfstmo_ashikhmin02.cpp +++ b/src/TonemappingOperators/ashikhmin02/pfstmo_ashikhmin02.cpp @@ -32,9 +32,6 @@ #include #include -#include - - #include "Libpfs/frame.h" #include "Libpfs/colorspace/colorspace.h" #include "Libpfs/progress.h" @@ -76,6 +73,11 @@ void pfstmo_ashikhmin02(pfs::Frame& frame, bool simple_flag, float lc_value, int assert( Xr != NULL ); assert( Yr != NULL ); assert( Zr != NULL ); + if ( !Xr || !Yr || !Zr ) + { + throw pfs::Exception( "Missing X, Y, Z channels in the PFS stream" ); + } + pfs::transformColorSpace( pfs::CS_RGB, Xr, Yr, Zr, pfs::CS_XYZ, Xr, Yr, Zr ); float maxLum, avLum, minLum; diff --git a/src/TonemappingOperators/drago03/pfstmo_drago03.cpp b/src/TonemappingOperators/drago03/pfstmo_drago03.cpp index 914af55a4..19b117443 100644 --- a/src/TonemappingOperators/drago03/pfstmo_drago03.cpp +++ b/src/TonemappingOperators/drago03/pfstmo_drago03.cpp @@ -42,19 +42,21 @@ void pfstmo_drago03(pfs::Frame& frame, float biasValue, pfs::Progress &ph) { +#ifndef NDEBUG std::cout << "pfstmo_drago03 ("; std::cout << "bias: " << biasValue << ")" << std::endl; +#endif pfs::Channel *X, *Y, *Z; frame.getXYZChannels( X, Y, Z ); - frame.getTags().setTag("LUMINANCE", "RELATIVE"); - //--- - - if ( Y == NULL ) + if ( !X || !Y || !Z ) { throw pfs::Exception( "Missing X, Y, Z channels in the PFS stream" ); } + + frame.getTags().setTag("LUMINANCE", "RELATIVE"); + //--- pfs::Array2Df& Xr = *X; pfs::Array2Df& Yr = *Y; diff --git a/src/TonemappingOperators/fattal02/pfstmo_fattal02.cpp b/src/TonemappingOperators/fattal02/pfstmo_fattal02.cpp index d68309f10..e3153bf0d 100644 --- a/src/TonemappingOperators/fattal02/pfstmo_fattal02.cpp +++ b/src/TonemappingOperators/fattal02/pfstmo_fattal02.cpp @@ -82,7 +82,6 @@ void pfstmo_fattal02(pfs::Frame& frame, //Store RGB data temporarily in XYZ channels pfs::Channel *R, *G, *B; frame.getXYZChannels( R, G, B ); - frame.getTags().setTag("LUMINANCE", "RELATIVE"); //--- if ( !R || !G || !B ) @@ -90,9 +89,10 @@ void pfstmo_fattal02(pfs::Frame& frame, throw pfs::Exception( "Missing X, Y, Z channels in the PFS stream" ); } + frame.getTags().setTag("LUMINANCE", "RELATIVE"); // tone mapping - int w = frame.getWidth(); - int h = frame.getHeight(); + const int w = frame.getWidth(); + const int h = frame.getHeight(); pfs::Array2Df Yr(w,h); pfs::Array2Df L(w,h); diff --git a/src/TonemappingOperators/mantiuk06/pfstmo_mantiuk06.cpp b/src/TonemappingOperators/mantiuk06/pfstmo_mantiuk06.cpp index 3a1fdec2f..5c64f95b1 100644 --- a/src/TonemappingOperators/mantiuk06/pfstmo_mantiuk06.cpp +++ b/src/TonemappingOperators/mantiuk06/pfstmo_mantiuk06.cpp @@ -87,8 +87,13 @@ void pfstmo_mantiuk06(pfs::Frame& frame, float scaleFactor, pfs::Channel *inRed, *inGreen, *inBlue; frame.getXYZChannels(inRed, inGreen, inBlue); - int cols = frame.getWidth(); - int rows = frame.getHeight(); + if ( !inRed || !inGreen || !inBlue ) + { + throw pfs::Exception( "Missing X, Y, Z channels in the PFS stream" ); + } + + const int cols = frame.getWidth(); + const int rows = frame.getHeight(); pfs::Array2Df inY( cols, rows ); pfs::transformRGB2Y(inRed, inGreen, inBlue, &inY); diff --git a/src/TonemappingOperators/mantiuk08/pfstmo_mantiuk08.cpp b/src/TonemappingOperators/mantiuk08/pfstmo_mantiuk08.cpp index c1a6a6d46..568bf2db6 100644 --- a/src/TonemappingOperators/mantiuk08/pfstmo_mantiuk08.cpp +++ b/src/TonemappingOperators/mantiuk08/pfstmo_mantiuk08.cpp @@ -63,11 +63,13 @@ void pfstmo_mantiuk08(pfs::Frame& frame, float saturation_factor, float contrast if ( saturation_factor < 0.0f || saturation_factor > 2.0f ) throw pfs::Exception("incorrect saturation factor, accepted range is (0..2)"); +#ifndef NDEBUG std::cout << "pfstmo_mantiuk08 ("; std::cout << "saturation factor: " << saturation_factor; std::cout << ", contrast enhancement factor: " << contrast_enhance_factor; std::cout << ", white_y: " << white_y; std::cout << ", setluminance: " << setluminance << ")" << std::endl; +#endif DisplayFunction *df = NULL; DisplaySize *ds = NULL; @@ -83,8 +85,14 @@ void pfstmo_mantiuk08(pfs::Frame& frame, float saturation_factor, float contrast pfs::Channel *inX, *inY, *inZ; frame.getXYZChannels(inX, inY, inZ); - int cols = frame.getWidth(); - int rows = frame.getHeight(); + + if ( !inX || !inY || !inZ ) + { + throw pfs::Exception( "Missing X, Y, Z channels in the PFS stream" ); + } + + const int cols = frame.getWidth(); + const int rows = frame.getHeight(); pfs::Array2Df R( cols, rows ); pfs::transformColorSpace(pfs::CS_XYZ, inX, inY, inZ, pfs::CS_RGB, inX, &R, inZ); diff --git a/src/TonemappingOperators/pattanaik00/pfstmo_pattanaik00.cpp b/src/TonemappingOperators/pattanaik00/pfstmo_pattanaik00.cpp index 9be7b7ef7..2d591ea49 100644 --- a/src/TonemappingOperators/pattanaik00/pfstmo_pattanaik00.cpp +++ b/src/TonemappingOperators/pattanaik00/pfstmo_pattanaik00.cpp @@ -71,18 +71,19 @@ void pfstmo_pattanaik00(pfs::Frame& frame, //Arod = -1.0f; float fps = 16.0f; //not used +#ifndef NDEBUG std::cout << "pfstmo_pattanaik00 ("; std::cout << "local: " << local << ", "; std::cout << "multiplier: " << multiplier << ", "; std::cout << "Acone: " << Acone << ", "; std::cout << "Arod: " << Arod << ", "; std::cout << "autolum: " << autolum << ")" << std::endl; +#endif boost::scoped_ptr am(new VisualAdaptationModel()); pfs::Channel *X, *Y, *Z; frame.getXYZChannels( X, Y, Z ); - frame.getTags().setTag("LUMINANCE", "RELATIVE"); //--- if ( Y==NULL || X==NULL || Z==NULL) @@ -90,6 +91,7 @@ void pfstmo_pattanaik00(pfs::Frame& frame, throw pfs::Exception( "Missing X, Y, Z channels in the PFS stream" ); } + frame.getTags().setTag("LUMINANCE", "RELATIVE"); // adaptation model if ( multiplier != 1.0f ) { multiplyChannels(*X, *Y, *Z, multiplier ); diff --git a/src/TonemappingOperators/reinhard02/pfstmo_reinhard02.cpp b/src/TonemappingOperators/reinhard02/pfstmo_reinhard02.cpp index a01466385..eec511135 100644 --- a/src/TonemappingOperators/reinhard02/pfstmo_reinhard02.cpp +++ b/src/TonemappingOperators/reinhard02/pfstmo_reinhard02.cpp @@ -65,13 +65,13 @@ void pfstmo_reinhard02(pfs::Frame& frame, float key, float phi, int num, int low #endif pfs::Channel *X, *Y, *Z; frame.getXYZChannels( X, Y, Z ); - frame.getTags().setTag("LUMINANCE", "RELATIVE"); //--- if ( Y==NULL || X==NULL || Z==NULL ) { throw pfs::Exception( "Missing X, Y, Z channels in the PFS stream" ); } + frame.getTags().setTag("LUMINANCE", "RELATIVE"); // tone mapping size_t w = Y->getWidth(); size_t h = Y->getHeight(); diff --git a/src/TonemappingOperators/reinhard05/pfstmo_reinhard05.cpp b/src/TonemappingOperators/reinhard05/pfstmo_reinhard05.cpp index 1e290cde5..6fca696bf 100644 --- a/src/TonemappingOperators/reinhard05/pfstmo_reinhard05.cpp +++ b/src/TonemappingOperators/reinhard05/pfstmo_reinhard05.cpp @@ -49,6 +49,7 @@ void pfstmo_reinhard05(pfs::Frame &frame, float brightness, float chromaticadapt //float chromaticadaptation = 0.5f; //float lightadaptation = 0.75f; +#ifndef NDEBUG std::stringstream ss; ss << "pfstmo_reinhard05 ("; @@ -57,10 +58,10 @@ void pfstmo_reinhard05(pfs::Frame &frame, float brightness, float chromaticadapt ss << "light adaptation: " << lightadaptation << ") " << std::endl; std::cout << ss.str(); +#endif pfs::Channel *R, *G, *B; frame.getXYZChannels( R, G, B ); - frame.getTags().setTag("LUMINANCE", "RELATIVE"); //--- if ( !R || !G || !B ) @@ -68,6 +69,7 @@ void pfstmo_reinhard05(pfs::Frame &frame, float brightness, float chromaticadapt throw pfs::Exception( "Missing X, Y, Z channels in the PFS stream" ); } + frame.getTags().setTag("LUMINANCE", "RELATIVE"); // tone mapping const unsigned int width = frame.getWidth(); const unsigned int height = frame.getHeight();