View | Details | Raw Unified | Return to bug 226185 | Differences between
and this patch

Collapse All | Expand All

(-)graphics/pfstools/Makefile (-42 / +87 lines)
Lines 2-9 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	pfstools
4
PORTNAME=	pfstools
5
PORTVERSION=	1.8.5
5
DISTVERSION=	2.1.0
6
PORTREVISION=	5
7
CATEGORIES=	graphics
6
CATEGORIES=	graphics
8
MASTER_SITES=	SF
7
MASTER_SITES=	SF
9
8
Lines 11-69 Link Here
11
COMMENT=	Tools for manipulating HDR images and video frames
10
COMMENT=	Tools for manipulating HDR images and video frames
12
11
13
LICENSE=	LGPL21
12
LICENSE=	LGPL21
13
LICENSE_FILE=	${WRKSRC}/COPYING
14
14
15
RUN_DEPENDS+=	bash:shells/bash
15
BUILD_DEPENDS=	bash:shells/bash
16
RUN_DEPENDS=	bash:shells/bash
16
17
17
PFS_BUILD=	${MACHINE_ARCH}-portbld-freebsd${OSREL}
18
CONFLICTS=	pfstmo-1.* pfscalibration-1.*
18
PLIST_SUB+=	PFS_BASE=${PREFIX}
19
19
20
USES=		gmake libtool pathfix pkgconfig
20
LDFLAGS+=	-lthr
21
GNU_CONFIGURE=	yes
21
22
CONFIGURE_TARGET=	${PFS_BUILD}
22
USES=		cmake:outsource tar:tgz dos2unix perl5 jpeg
23
CONFIGURE_ARGS+=	--disable-jpeghdr --disable-matlab \
23
USE_PERL5=	run
24
		--with-bash=${LOCALBASE}/bin/bash
25
CPPFLAGS+=	-I${LOCALBASE}/include
26
LDFLAGS+=	-L${LOCALBASE}/lib
27
USE_LDCONFIG=	yes
24
USE_LDCONFIG=	yes
28
25
29
OPTIONS_DEFINE=	NETPBM OPENEXR TIFF QT IMAGEMAGICK GDAL OCTAVE OPENGL
26
CMAKE_VERBOSE=	yes
30
QT_DESC=	Compile programs that use QT library
27
CMAKE_ARGS+=	-DBUILD_SHARED_LIBS=ON \
31
GDAL_DESC=	Compile programs that use GDAL library
28
		-DWITH_MATLAB=OFF \
29
		-DBASH_EXECUTABLE:STRING=${LOCALBASE}/bin/bash
30
31
DOS2UNIX_GLOB=	*.txt *.cmake \
32
		*.h *.c *.cpp \
33
		*.1
34
35
MANCOMPRESSED=	yes
36
37
OPTIONS_DEFINE=	TIFF OPENEXR IMAGEMAGICK NETPBM \
38
		OCTAVE FFTW GSL \
39
		ALIGN GLVIEW VIEW \
40
		OPENMP
41
OPTIONS_DEFAULT=TIFF FFTW GSL
42
NO_OPTIONS_SORT=yes
43
OPTIONS_SUB=	yes
32
OCTAVE_DESC=	Compile octave interface functions
44
OCTAVE_DESC=	Compile octave interface functions
45
GSL_DESC=	Use Gnu Scientific Libarary required for some TMOs
46
ALIGN_DESC=	Compile pfsalign, requires OpenCV and libexif
47
VIEW_DESC=	Compile pfsview, requires QT5
48
GLVIEW_DESC=	Compile pfsglview, requires GLUT
33
49
34
OPTIONS_DEFAULT=	TIFF
50
TIFF_CMAKE_ON=		-DWITH_TIFF=ON
35
OPTIONS_SUB=		yes
51
TIFF_CMAKE_OFF=		-DWITH_TIFF=OFF
52
TIFF_LIB_DEPENDS=	libtiff.so:graphics/tiff
36
53
37
NETPBM_CONFIGURE_ENABLE=	netpbm
54
OPENEXR_CMAKE_ON=	-DWITH_OpenEXR=ON
38
NETPBM_LIB_DEPENDS=		libnetpbm.so:graphics/netpbm
55
OPENEXR_CMAKE_OFF=	-DWITH_OpenEXR=OFF
56
OPENEXR_LIB_DEPENDS=	libIlmImf.so:graphics/OpenEXR
39
57
40
OPENEXR_CONFIGURE_ENABLE=	openexr
58
IMAGEMAGICK_CMAKE_ON=	-DWITH_ImageMagick=ON
41
OPENEXR_CONFIGURE_ON=		--with-exrdir=${LOCALBASE}/include/OpenEXR
59
IMAGEMAGICK_CMAKE_OFF=	-DWITH_ImageMagick=OFF
42
OPENEXR_LIB_DEPENDS=		libIlmImf.so:graphics/OpenEXR
60
IMAGEMAGICK_LIB_DEPENDS=libMagick++-6.so:graphics/ImageMagick
43
61
44
TIFF_CONFIGURE_ENABLE=		tiff
62
NETPBM_CMAKE_ON=	-DWITH_NetPBM=ON
45
TIFF_LIB_DEPENDS=		libtiff.so:graphics/tiff
63
NETPBM_CMAKE_OFF=	-DWITH_NetPBM=OFF
64
NETPBM_LIB_DEPENDS=	libnetpbm.so:graphics/netpbm
46
65
47
QT_CONFIGURE_ENABLE=		qt
66
OCTAVE_CMAKE_ON=	-DWITH_Octave=ON
48
QT_USE=				QT4=moc_build,corelib,gui
67
OCTAVE_CMAKE_OFF=	-DWITH_Octave=OFF
68
OCTAVE_PATCH_DEPENDS=	octave-config:math/octave
69
OCTAVE_BUILD_DEPENDS=	mkoctfile:math/octave
70
OCTAVE_RUN_DEPENDS=	octave:math/octave
49
71
50
IMAGEMAGICK_CONFIGURE_ENABLE=	imagemagick
72
FFTW_CMAKE_ON=		-DWITH_FFTW=ON \
51
IMAGEMAGICK_LIB_DEPENDS=	libMagick++-6.so:graphics/ImageMagick
73
			-DFFTW_INCLUDE_DIRS=${LOCALBASE}/include
74
FFTW_CMAKE_OFF=		-DWITH_FFTW=OFF
75
FFTW_LIB_DEPENDS=	libfftw3.so:math/fftw3 \
76
			libfftw3f.so:math/fftw3-float
52
77
53
GDAL_CONFIGURE_ENABLE=		gdal
78
GSL_CMAKE_ON=		-DWITH_GSL=ON
54
GDAL_LIB_DEPENDS=		libgdal.so:graphics/gdal
79
GSL_CMAKE_OFF=		-DWITH_GSL=OFF
80
GSL_LIB_DEPENDS=	libgsl.so:math/gsl
55
81
56
OPENGL_CONFIGURE_ENABLE=	opengl
82
ALIGN_CMAKE_ON=		-DWITH_OpenCV=ON
57
OPENGL_USE=			GL=glut
83
ALIGN_CMAKE_OFF=	-DWITH_OpenCV=OFF
84
ALIGN_LIB_DEPENDS=	libopencv_nonfree.so:graphics/opencv \
85
			libexif.so:graphics/libexif
58
86
59
OCTAVE_CONFIGURE_ENABLE=	octave
87
GLVIEW_CMAKE_ON=	-DWITH_pfsglview=ON \
60
OCTAVE_PATCH_DEPENDS=		octave-config:math/octave
88
			-DGLUT_INCLUDE_DIRS=${LOCALBASE}/include
61
OCTAVE_BUILD_DEPENDS=		mkoctfile:math/octave
89
GLVIEW_CMAKE_OFF=	-DWITH_pfsglview=OFF
62
OCTAVE_RUN_DEPENDS=		octave:math/octave
90
GLVIEW_USE=		GL=glut
63
OCTAVE_USES=			shebangfix
64
91
92
VIEW_CMAKE_ON=		-DWITH_QT=ON
93
VIEW_CMAKE_OFF=		-DWITH_QT=OFF
94
VIEW_USE=		QT5=buildtools_build,qmake_build,widgets
95
96
OPENMP_USES=		compiler:openmp
97
65
.include <bsd.port.options.mk>
98
.include <bsd.port.options.mk>
66
99
100
.if ${PORT_OPTIONS:MNETPBM} && !${PORT_OPTIONS:MTIFF}
101
WARNING+=	"NETPBM is unusable without TIFF"
102
.endif
103
104
.if ${PORT_OPTIONS:MIMAGEMAGICK} && !${PORT_OPTIONS:MOPENMP}
105
USES+=	compiler:c++11-lib
106
.endif
107
67
.if ${PORT_OPTIONS:MOCTAVE}
108
.if ${PORT_OPTIONS:MOCTAVE}
68
OCTAVE_BASE?=	${LOCALBASE}
109
OCTAVE_BASE?=	${LOCALBASE}
69
OCTAVE_VERSION!=${OCTAVE_BASE}/bin/octave-config -v 2>&1 || ${ECHO} "0"
110
OCTAVE_VERSION!=${OCTAVE_BASE}/bin/octave-config -v 2>&1 || ${ECHO} "0"
Lines 73-83 Link Here
73
		OCTAVE_BASE=${OCTAVE_BASE} \
114
		OCTAVE_BASE=${OCTAVE_BASE} \
74
		OCTAVE_SITE_M=${OCTAVE_SITE_M:S|^${OCTAVE_BASE}/||} \
115
		OCTAVE_SITE_M=${OCTAVE_SITE_M:S|^${OCTAVE_BASE}/||} \
75
		OCTAVE_SITE_OCT=${OCTAVE_SITE_OCT:S|^${OCTAVE_BASE}/||}
116
		OCTAVE_SITE_OCT=${OCTAVE_SITE_OCT:S|^${OCTAVE_BASE}/||}
76
SHEBANG_FILES=	src/octave/*
117
SHEBANG_FILES+=	src/octave/pfs*
77
SHEBANG_LANG+=	octave
118
SHEBANG_LANG+=	octave 
119
octave_OLD_CMD?=/usr/bin/octave
120
octave_CMD?=	${OCTAVE_BASE}/bin/octave-cli
78
.endif
121
.endif
79
122
80
post-install:
123
.include <bsd.port.pre.mk>
81
	${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib//libpfs-1.2.so.0.0.0
82
124
83
.include <bsd.port.mk>
125
post-extract:
126
		@${TAR} cfC - ${FILESDIR}/port . | ${TAR} xpfC - ${WRKSRC}
127
128
.include <bsd.port.post.mk>
(-)graphics/pfstools/distinfo (-2 / +3 lines)
Lines 1-2 Link Here
1
SHA256 (pfstools-1.8.5.tar.gz) = 2cf958d39ee3b65b034796b0abeea727590561936e295461de6365a750167306
1
TIMESTAMP = 1515923190
2
SIZE (pfstools-1.8.5.tar.gz) = 846001
2
SHA256 (pfstools-2.1.0.tgz) = 3dea4248e41bf433fe4760b0a11d138ad2d240f62db9e519bcb1d557c0593413
3
SIZE (pfstools-2.1.0.tgz) = 596136
(-)graphics/pfstools/files/patch-CMakeLists.txt (+30 lines)
Line 0 Link Here
1
--- CMakeLists.txt.orig	2018-02-24 22:34:23 UTC
2
+++ CMakeLists.txt
3
@@ -29,7 +29,7 @@ set (pfstools_VERSION_MINOR ${CPACK_PACK
4
 set (pfslib_version 1.2)
5
 set(CMAKE_LEGACY_CYGWIN_WIN32 0)
6
  
7
-set (MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man/man1" CACHE PATH "The directory where the man pages are")
8
+set (MAN_DIR "${CMAKE_INSTALL_PREFIX}/man/man1" CACHE PATH "The directory where the man pages are")
9
 
10
 include( CheckCXXSourceCompiles )
11
 
12
@@ -57,7 +57,7 @@ endif( HAS_BRANCH_PREDICTION )
13
 # ======== Find bash =======
14
 
15
 # TODO: What if the check fails
16
-find_program (BASH_EXECUTABLE bash)
17
+#find_program (BASH_EXECUTABLE bash)
18
 message( "Using bash: ${BASH_EXECUTABLE}" )
19
 
20
 # ======== Find perl =======
21
@@ -250,6 +250,9 @@ if( WITH_FFTW )
22
   else( NOT FFTW_FOUND )
23
     set( HAVE_FFTW3F 1 )
24
     set( HAVE_FFTW3 1 )
25
+    if( NOT "${FFTW_INCLUDE_DIRS}" STREQUAL "" )
26
+      include_directories ("${FFTW_INCLUDE_DIRS}")
27
+    endif( NOT "${FFTW_INCLUDE_DIRS}" STREQUAL "" )
28
   endif( NOT FFTW_FOUND )
29
 
30
 else( WITH_FFTW )
(-)graphics/pfstools/files/patch-config.h.in (-19 lines)
Lines 1-19 Link Here
1
--- config.h.in.orig	2011-10-27 08:40:42 UTC
2
+++ config.h.in
3
@@ -99,13 +99,13 @@
4
 
5
 /* Output stream for debug messages. */
6
 #ifdef DEBUG
7
-#define DEBUG_STR cerr
8
+#define DEBUG_STR std::cerr
9
 #else
10
-#define DEBUG_STR if(1); else cerr
11
+#define DEBUG_STR if(1); else std::cerr
12
 #endif
13
 /* Output stream for verbose messages */        
14
 #define VERBOSE_STR if(verbose) std::cerr << PROG_NAME << ": "        
15
 
16
 
17
 /* On some systems iostream, string etc are in 'std' namespace */
18
-using namespace std; 
19
+//using namespace std; 
(-)graphics/pfstools/files/patch-configure (-11 lines)
Lines 1-11 Link Here
1
--- configure.orig	2011-10-27 08:40:31 UTC
2
+++ configure
3
@@ -15411,7 +15411,7 @@ fi #end of PKG_CHECK_MODULES
4
 if test -z "$QTDIR"; then
5
   MOC="moc-qt4"
6
 else
7
-  MOC="$QTDIR/bin/moc"
8
+  MOC="$QTDIR/bin/moc-qt4"
9
 fi
10
 
11
 # Check whether --with-moc was given.
(-)graphics/pfstools/files/patch-src-fileformat-exrio.cpp (-28 lines)
Lines 1-28 Link Here
1
--- src/fileformat/exrio.cpp.orig	2005-06-15 13:36:54 UTC
2
+++ src/fileformat/exrio.cpp
3
@@ -54,14 +54,14 @@ OpenEXRReader::OpenEXRReader( const char
4
   }
5
 
6
   DEBUG_STR << "OpenEXR file \"" << filename << "\" ("
7
-	    << width << "x" << height << ")" << endl;
8
+	    << width << "x" << height << ")" << std::endl;
9
 }
10
 
11
 void OpenEXRReader::readImage( pfs::Array2D *R, pfs::Array2D *G,
12
 			       pfs::Array2D *B )
13
 {
14
   assert(file!=NULL);
15
-  DEBUG_STR << "Reading OpenEXR file... " << endl;
16
+  DEBUG_STR << "Reading OpenEXR file... " << std::endl;
17
   
18
   Imf::Rgba* tmp_img = new Imf::Rgba[width*height];
19
 
20
@@ -93,7 +93,7 @@ void OpenEXRReader::readImage( pfs::Arra
21
 OpenEXRReader::~OpenEXRReader()
22
 {
23
   delete file;
24
-  file==NULL;
25
+  file=NULL;
26
 }
27
 
28
 OpenEXRWriter::OpenEXRWriter(const char* filename)
(-)graphics/pfstools/files/patch-src-fileformat-hdrtiffio.cpp (-96 lines)
Lines 1-96 Link Here
1
--- src/fileformat/hdrtiffio.cpp.orig	2011-10-27 08:39:07 UTC
2
+++ src/fileformat/hdrtiffio.cpp
3
@@ -66,7 +66,7 @@ HDRTiffReader::HDRTiffReader( const char
4
   }
5
 
6
   DEBUG_STR << "TIFF file \"" << filename << "\" ("
7
-	    << width << "x" << height << ")" << endl;
8
+	    << width << "x" << height << ")" << std::endl;
9
 
10
 	//--- image parameters
11
   if(!TIFFGetField(tif, TIFFTAG_COMPRESSION, &comp)) // compression type
12
@@ -81,7 +81,7 @@ HDRTiffReader::HDRTiffReader( const char
13
   switch(phot)
14
   {
15
     case PHOTOMETRIC_LOGLUV:
16
-      DEBUG_STR << "Photometric data: LogLuv" << endl;
17
+      DEBUG_STR << "Photometric data: LogLuv" << std::endl;
18
       if (comp != COMPRESSION_SGILOG && comp != COMPRESSION_SGILOG24)
19
       {
20
 	TIFFClose(tif);
21
@@ -96,7 +96,7 @@ HDRTiffReader::HDRTiffReader( const char
22
       relative_values=true;
23
       break;
24
     case PHOTOMETRIC_RGB:
25
-      DEBUG_STR << "Photometric data: RGB" << endl;
26
+      DEBUG_STR << "Photometric data: RGB" << std::endl;
27
      // read extra samples (# of alpha channels)
28
       if (TIFFGetField( tif, TIFFTAG_EXTRASAMPLES,
29
                         &extra_samples_per_pixel, &extra_sample_types )!=1)
30
@@ -121,36 +121,36 @@ HDRTiffReader::HDRTiffReader( const char
31
       if( bps==8 )
32
       {
33
 	TypeOfData = BYTE;
34
-	DEBUG_STR << "8bit per channel" << endl;
35
+	DEBUG_STR << "8bit per channel" << std::endl;
36
         strcpy(format_string,"linear 8bit RGB");
37
         relative_values=false; //!! TODO: verify if 8bit is always gamma corrected
38
       }
39
       else if( bps==16 )
40
       {
41
 	TypeOfData = WORD;
42
-	DEBUG_STR << "16bit per channel" << endl;
43
+	DEBUG_STR << "16bit per channel" << std::endl;
44
         strcpy(format_string,"linear 16bit RGB");
45
         relative_values=true;   //!! TODO: verify this case!!
46
       }
47
       else
48
       {
49
 	TypeOfData = FLOAT;
50
-	DEBUG_STR << "32bit float per channel" << endl;
51
+	DEBUG_STR << "32bit float per channel" << std::endl;
52
         strcpy(format_string,"linear 32bit float RGB");
53
         relative_values=true; 
54
       }
55
       break;
56
     case PHOTOMETRIC_MINISBLACK: // HDR video camera format (grayscale)
57
-      DEBUG_STR << "Photometric data: MINISBLACK (hdrv camera)" << endl;
58
+      DEBUG_STR << "Photometric data: MINISBLACK (hdrv camera)" << std::endl;
59
       if (!TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &bps) || !bps==1)
60
       {
61
 	TIFFClose(tif);
62
 	throw pfs::Exception("TIFF: Unsupported samples per pixel for "
63
 			     "grayscale image");
64
       }
65
-      if (!TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bps) || !bps==16)
66
+      if (!TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bps) || !(bps==16))
67
       {
68
-	DEBUG_STR << "Detected bits per sample: " << bps << endl;
69
+	DEBUG_STR << "Detected bits per sample: " << bps << std::endl;
70
 	TIFFClose(tif);
71
 	throw pfs::Exception("TIFF: unsupported bits per sample for "
72
 			     "grayscale image.");
73
@@ -160,7 +160,7 @@ HDRTiffReader::HDRTiffReader( const char
74
       relative_values=true;
75
       break;
76
     default:
77
-      DEBUG_STR << "Unsupported photometric type: " << phot << endl;
78
+      DEBUG_STR << "Unsupported photometric type: " << phot << std::endl;
79
       TIFFClose(tif);
80
       strcpy(format_string,"unknown");
81
       relative_values=false;
82
@@ -184,12 +184,12 @@ void HDRTiffReader::readImage( pfs::Arra
83
   //--- image length
84
   uint32 imagelength;
85
   TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength);
86
-  DEBUG_STR << "Image length: " << imagelength << endl;
87
+  DEBUG_STR << "Image length: " << imagelength << std::endl;
88
 
89
   //--- image scanline size
90
   uint32 scanlinesize = TIFFScanlineSize(tif);
91
   buf.vp = _TIFFmalloc(scanlinesize);
92
-//    DEBUG_STR << "Scanline size: " << scanlinesize << endl;
93
+//    DEBUG_STR << "Scanline size: " << scanlinesize << std::endl;
94
 
95
 
96
   //--- read scan lines
(-)graphics/pfstools/files/patch-src-fileformat-pfsinexr.cpp (-11 lines)
Lines 1-11 Link Here
1
--- src/fileformat/pfsinexr.cpp.orig	2008-01-01 13:01:21 UTC
2
+++ src/fileformat/pfsinexr.cpp
3
@@ -234,7 +234,7 @@ void readFrames( int argc, char* argv[] 
4
     }
5
     
6
     file.setFrameBuffer( frameBuffer );
7
-    file.readPixels( dw.min.y, dw.max.y );
8
+    file.readPixels( dtw.min.y, dtw.max.y );
9
 
10
     VERBOSE_STR << "reading file (linear) '" << ff.fileName << "'" << std::endl;
11
     
(-)graphics/pfstools/files/patch-src-fileformat-pfsinimgmagick.cpp (-19 lines)
Lines 1-19 Link Here
1
--- src/fileformat/pfsinimgmagick.cpp.orig	2008-10-03 19:07:34 UTC
2
+++ src/fileformat/pfsinimgmagick.cpp
3
@@ -108,6 +108,7 @@ void readFrames( int argc, char* argv[] 
4
     if( ff.fh == NULL ) break; // No more frames
5
     it.closeFrameFile( ff );
6
 
7
+    Magick::InitializeMagick(*argv);
8
     VERBOSE_STR << "reading file '" << ff.fileName << "'" << std::endl;
9
     Magick::Image imImage( ff.fileName );
10
 
11
@@ -172,7 +173,7 @@ void readFrames( int argc, char* argv[] 
12
     frame->getTags()->setString( "FILE_NAME", fileNameTag );
13
  
14
     char strbuf[3];
15
-    snprintf( strbuf, 3, "%d", imImage.depth() );
16
+    snprintf( strbuf, 3, "%lu", imImage.depth() );
17
     frame->getTags()->setString("BITDEPTH", strbuf );    
18
    
19
     pfsio.writeFrame( frame, stdout );
(-)graphics/pfstools/files/patch-src-fileformat-pfsinjpeghdr.cpp (-22 lines)
Lines 1-22 Link Here
1
--- src/fileformat/pfsinjpeghdr.cpp.orig	2005-11-04 08:54:27 UTC
2
+++ src/fileformat/pfsinjpeghdr.cpp
3
@@ -123,8 +123,8 @@ void readFrames( int argc, char* argv[] 
4
     case JPEG_HEADER_HDR:  // HDR image          
5
       jpeghdr_start_decompress(&jhinf);
6
       frame = pfsio.createFrame( jhinf.cinfo.output_width, jhinf.cinfo.output_height );
7
-      hdrscan = (JHSAMPLE *)malloc(jhinf.cinfo.output_width * jhinf.cinfo.output_height *
8
-        sizeof(JHSAMPLE)*3);
9
+      hdrscan = 
10
+        new JHSAMPLE[jhinf.cinfo.output_width * jhinf.cinfo.output_height * 3];
11
       // Important: test jhinf.output_scanline, not jhinf.cinfo
12
       int index ;
13
       index = 0;
14
@@ -144,7 +144,7 @@ void readFrames( int argc, char* argv[] 
15
         (Z->getRawData())[i] = hdrscan[3*i + 2];
16
       }       
17
       pfs::transformColorSpace( pfs::CS_RGB, X, Y, Z, pfs::CS_XYZ, X, Y, Z );	  
18
-      free((void *)hdrscan);
19
+      delete[] hdrscan;
20
       break;
21
     case JPEG_HEADER_OK:  // LDR image
22
     case JPEG_SUSPENDED:
(-)graphics/pfstools/files/patch-src-fileformat-pfsoutimgmagick.cpp (-10 lines)
Lines 1-10 Link Here
1
--- src/fileformat/pfsoutimgmagick.cpp.orig	2011-03-15 08:47:24 UTC
2
+++ src/fileformat/pfsoutimgmagick.cpp
3
@@ -190,6 +190,7 @@ void writeFrames( int argc, char* argv[]
4
         if( alpha != NULL )
5
           imgBuffer[i++] = (unsigned short)(maxValue-clamp((*alpha)(pix),0.f,1.f)*maxValue);
6
       }
7
+      Magick::InitializeMagick(*argv);
8
       Magick::Image imImage( frame->getWidth(), frame->getHeight(),
9
         (alpha == NULL ? "RGB" : "RGBA"), Magick::ShortPixel, imgBuffer );
10
       imImage.quality( quality );
(-)graphics/pfstools/files/patch-src-fileformat-pfsoutjpeghdr.cpp (-40 lines)
Lines 1-40 Link Here
1
--- src/fileformat/pfsoutjpeghdr.cpp.orig	2005-11-04 08:54:27 UTC
2
+++ src/fileformat/pfsoutjpeghdr.cpp
3
@@ -69,8 +69,7 @@ void writeHDRJPEGGray( FILE *fh, int wid
4
    jhinf.correction = correction;
5
    jpeg_stdio_dest(&jhinf.cinfo, fh);
6
    
7
-   image = (JHSAMPLE *)malloc(width * height *
8
-          sizeof(JHSAMPLE)*3);
9
+   image = new JHSAMPLE[width * height * 3];
10
    
11
    for(int i=0;i<width * height;i++)
12
    {
13
@@ -91,7 +90,7 @@ void writeHDRJPEGGray( FILE *fh, int wid
14
    // Or, assign jhinf.tmi 8-bit grayscale values in scanline order
15
    jpeghdr_do_compress(&jhinf);
16
    jpeghdr_destroy_compress(&jhinf);
17
-   fclose(fh);
18
+   delete[] image;
19
 }
20
 
21
 void writeHDRJPEGRGB( FILE *fh, int width, int height,
22
@@ -111,8 +110,7 @@ void writeHDRJPEGRGB( FILE *fh, int widt
23
    jhinf.beta = beta;
24
    jpeg_stdio_dest(&jhinf.cinfo, fh);
25
    
26
-   image = (JHSAMPLE *)malloc(width * height *
27
-          sizeof(JHSAMPLE)*3);
28
+   image = new JHSAMPLE[width * height * 3];
29
    
30
    for(int i=0;i<width * height;i++)
31
    {
32
@@ -135,7 +133,7 @@ void writeHDRJPEGRGB( FILE *fh, int widt
33
    jpeghdr_do_compress(&jhinf);
34
    jpeghdr_destroy_compress(&jhinf);
35
 
36
-   free( image );
37
+   delete[] image;
38
 }
39
 
40
 void writeFrames( int argc, char* argv[] )
(-)graphics/pfstools/files/patch-src-fileformat-pfsoutpfm.cpp (-20 lines)
Lines 1-20 Link Here
1
--- src/fileformat/pfsoutpfm.cpp.orig	2005-06-15 13:36:54 UTC
2
+++ src/fileformat/pfsoutpfm.cpp
3
@@ -74,7 +74,7 @@ void writePFMFileColor( FILE *fh, int wi
4
     }
5
     int written = fwrite( line, sizeof( float ), lineSize, fh );
6
     if( written != lineSize )
7
-      throw new pfs::Exception( "Unable to write data" );
8
+      throw pfs::Exception( "Unable to write data" );
9
   }
10
   delete[] line;  
11
 }
12
@@ -94,7 +94,7 @@ void writePFMFileGrayscale( FILE *fh, in
13
     }
14
     int written = fwrite( line, sizeof( float ), lineSize, fh );
15
     if( written != lineSize )
16
-      throw new pfs::Exception( "Unable to write data" );
17
+      throw pfs::Exception( "Unable to write data" );
18
   }
19
   delete[] line;  
20
 }
(-)graphics/pfstools/files/patch-src-fileformat-ppmio.cpp (-11 lines)
Lines 1-11 Link Here
1
--- src/fileformat/ppmio.cpp.orig	2009-05-25 19:24:49 UTC
2
+++ src/fileformat/ppmio.cpp
3
@@ -34,6 +34,8 @@ extern "C" {
4
 #include <math.h>
5
 #include <assert.h>
6
 
7
+#define log2(x)	((float)log(x)/log(2))
8
+
9
 struct PPMData
10
 {
11
     pixval maxPV;
(-)graphics/pfstools/files/patch-src-fileformat-rgbeio.cpp (-29 lines)
Lines 1-29 Link Here
1
--- src/fileformat/rgbeio.cpp.orig	2007-12-06 11:00:49 UTC
2
+++ src/fileformat/rgbeio.cpp
3
@@ -141,7 +141,7 @@ void rgb2rgbe( float r, float g, float b
4
 // Reading RGBE files
5
 void readRadianceHeader( FILE *file, int &width, int &height, float &exposure )
6
 {
7
-  DEBUG_STR << "RGBE: reading header..." << endl;
8
+  DEBUG_STR << "RGBE: reading header..." << std::endl;
9
 
10
   // read header information
11
   char head[255];
12
@@ -208,7 +208,7 @@ void readRadianceHeader( FILE *file, int
13
 	height = height - width;
14
 	}
15
 */
16
-  DEBUG_STR << "RGBE: image size " << width << "x" << height << endl;
17
+  DEBUG_STR << "RGBE: image size " << width << "x" << height << std::endl;
18
 }
19
 
20
 
21
@@ -389,7 +389,7 @@ void writeRadiance( FILE *file, pfs::Arr
22
   int width = X->getCols();
23
   int height = X->getRows();
24
 
25
-  DEBUG_STR << "RGBE: writing image " << width << "x" << height << endl;
26
+  DEBUG_STR << "RGBE: writing image " << width << "x" << height << std::endl;
27
 
28
   if( Y->getCols() != width || Y->getRows() != height ||
29
       Z->getCols() != width || Z->getRows() != height )
(-)graphics/pfstools/files/patch-src-filter-Makefile.am (-20 lines)
Lines 1-20 Link Here
1
--- src/filter/Makefile.am.orig	2009-05-30 06:59:10 UTC
2
+++ src/filter/Makefile.am
3
@@ -1,6 +1,7 @@
4
 ###
5
 bin_PROGRAMS = pfsgamma pfsclamp pfstag pfssize pfsextractchannels pfspanoramic \
6
-	pfsrotate pfsflip pfscut pfspad pfscat pfsabsolute pfsdisplayfunction
7
+	pfsrotate pfsflip pfscut pfspad pfscat pfsabsolute pfsdisplayfunction \
8
+	pfswb
9
 
10
 man_MANS = pfsgamma.1 pfsclamp.1 pfstag.1 pfssize.1 pfsextractchannels.1 \
11
 	pfspanoramic.1 pfsrotate.1 pfsflip.1 pfscut.1 pfspad.1 pfscat.1 \
12
@@ -34,6 +35,8 @@ pfscat_SOURCES = pfscat.cpp
13
 
14
 pfsabsolute_SOURCES = pfsabsolute.cpp
15
 
16
+pfswb_SOURCES = pfswb.cpp
17
+
18
 LIBS += ../pfs/libpfs-1.2.la
19
 INCLUDES = -I${srcdir}/../pfs
20
 
(-)graphics/pfstools/files/patch-src-filter-Makefile.in (-58 lines)
Lines 1-58 Link Here
1
--- src/filter/Makefile.in.orig	2011-10-27 08:40:29 UTC
2
+++ src/filter/Makefile.in
3
@@ -38,7 +38,8 @@ bin_PROGRAMS = pfsgamma$(EXEEXT) pfsclam
4
 	pfssize$(EXEEXT) pfsextractchannels$(EXEEXT) \
5
 	pfspanoramic$(EXEEXT) pfsrotate$(EXEEXT) pfsflip$(EXEEXT) \
6
 	pfscut$(EXEEXT) pfspad$(EXEEXT) pfscat$(EXEEXT) \
7
-	pfsabsolute$(EXEEXT) pfsdisplayfunction$(EXEEXT)
8
+	pfsabsolute$(EXEEXT) pfsdisplayfunction$(EXEEXT) \
9
+	pfswb$(EXEEXT)
10
 subdir = src/filter
11
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
12
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
13
@@ -54,6 +55,9 @@ CONFIG_CLEAN_FILES =
14
 CONFIG_CLEAN_VPATH_FILES =
15
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
16
 PROGRAMS = $(bin_PROGRAMS)
17
+am_pfswb_OBJECTS = pfswb.$(OBJEXT)
18
+pfswb_OBJECTS = $(am_pfswb_OBJECTS)
19
+pfswb_LDADD = $(LDADD)
20
 am_pfsabsolute_OBJECTS = pfsabsolute.$(OBJEXT)
21
 pfsabsolute_OBJECTS = $(am_pfsabsolute_OBJECTS)
22
 pfsabsolute_LDADD = $(LDADD)
23
@@ -120,13 +124,15 @@ SOURCES = $(pfsabsolute_SOURCES) $(pfsca
24
 	$(pfscut_SOURCES) $(pfsdisplayfunction_SOURCES) \
25
 	$(pfsextractchannels_SOURCES) $(pfsflip_SOURCES) \
26
 	$(pfsgamma_SOURCES) $(pfspad_SOURCES) $(pfspanoramic_SOURCES) \
27
-	$(pfsrotate_SOURCES) $(pfssize_SOURCES) $(pfstag_SOURCES)
28
+	$(pfsrotate_SOURCES) $(pfssize_SOURCES) $(pfstag_SOURCES) \
29
+	$(pfswb_SOURCES)
30
 DIST_SOURCES = $(pfsabsolute_SOURCES) $(pfscat_SOURCES) \
31
 	$(pfsclamp_SOURCES) $(pfscut_SOURCES) \
32
 	$(pfsdisplayfunction_SOURCES) $(pfsextractchannels_SOURCES) \
33
 	$(pfsflip_SOURCES) $(pfsgamma_SOURCES) $(pfspad_SOURCES) \
34
 	$(pfspanoramic_SOURCES) $(pfsrotate_SOURCES) \
35
-	$(pfssize_SOURCES) $(pfstag_SOURCES)
36
+	$(pfssize_SOURCES) $(pfstag_SOURCES) \
37
+	$(pfswb_SOURCES)
38
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
39
 am__vpath_adj = case $$p in \
40
     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
41
@@ -314,6 +320,7 @@ pfscut_SOURCES = pfscut.cpp
42
 pfspad_SOURCES = pfspad.cpp
43
 pfscat_SOURCES = pfscat.cpp
44
 pfsabsolute_SOURCES = pfsabsolute.cpp
45
+pfswb_SOURCES = pfswb.cpp
46
 INCLUDES = -I${srcdir}/../pfs
47
 all: all-am
48
 
49
@@ -392,6 +399,9 @@ clean-binPROGRAMS:
50
 	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
51
 	echo " rm -f" $$list; \
52
 	rm -f $$list
53
+pfswb$(EXEEXT): $(pfswb_OBJECTS) $(pfswb_DEPENDENCIES) 
54
+	@rm -f pfswb$(EXEEXT)
55
+	$(CXXLINK) $(pfswb_LDFLAGS) $(pfswb_OBJECTS) $(pfswb_LDADD) $(LIBS)
56
 pfsabsolute$(EXEEXT): $(pfsabsolute_OBJECTS) $(pfsabsolute_DEPENDENCIES) 
57
 	@rm -f pfsabsolute$(EXEEXT)
58
 	$(CXXLINK) $(pfsabsolute_OBJECTS) $(pfsabsolute_LDADD) $(LIBS)
(-)graphics/pfstools/files/patch-src-filter-pfscat.cpp (-37 lines)
Lines 1-37 Link Here
1
--- src/filter/pfscat.cpp.orig	2008-01-01 13:01:21 UTC
2
+++ src/filter/pfscat.cpp
3
@@ -27,6 +27,7 @@
4
 #include <pfs.h>
5
 #include <climits>
6
 #include <iostream>
7
+#include <vector>
8
 #include <getopt.h>
9
 #include <fcntl.h>
10
 #include <stdlib.h>
11
@@ -202,16 +203,12 @@ if (alignment==UNSP) throw pfs::Exceptio
12
 
13
 pfs::FrameFileIterator it ( argc, argv, "rb", NULL, NULL, optString, cmdLineOptions);
14
 int pipe_no = 0;
15
-pfs::FrameFile * ff;
16
-ff = (pfs::FrameFile *) malloc ((pipe_no+1) * sizeof(pfs::FrameFile));
17
-
18
+std::vector<pfs::FrameFile> ff;
19
 while (1) {
20
-    ff[pipe_no] = it.getNextFrameFile();
21
+    ff.push_back(it.getNextFrameFile());
22
     if (ff[pipe_no].fh == NULL) break; // no more files
23
     pipe_no++;
24
-    ff=(pfs::FrameFile *) realloc(ff, (pipe_no+1)*sizeof(pfs::FrameFile));
25
     }
26
-    
27
 if(pipe_no == 0) { // no named pipes
28
     pipe_no = 1;
29
     pipes = false;
30
@@ -408,7 +405,6 @@ if(!pipes) {
31
     }
32
 
33
 for (int i=0; i<pipe_no; i++) it.closeFrameFile(ff[i]);
34
-free(ff);
35
 }
36
 
37
 
(-)graphics/pfstools/files/patch-src-filter-pfsclamp.cpp (-13 lines)
Lines 1-13 Link Here
1
--- src/filter/pfsclamp.cpp.orig	2005-11-02 13:35:42 UTC
2
+++ src/filter/pfsclamp.cpp
3
@@ -151,8 +151,8 @@ void clampFrames( int argc, char* argv[]
4
   }
5
   else
6
   {
7
-    clampMin = (clampMin>1e-4) ? clampMin : 1e-4;
8
-    clampMax = (clampMax<1e8) ? clampMax : 1e8;
9
+    clampMin = (clampMin>1e-20) ? clampMin : 1e-20;
10
+    clampMax = (clampMax<1e+20) ? clampMax : 1e+20;
11
     if( clampMin >= clampMax )
12
       throw pfs::Exception("incorrect clamping range");
13
   }
(-)graphics/pfstools/files/patch-src-filter-pfsextractchannels.cpp (-11 lines)
Lines 1-11 Link Here
1
--- src/filter/pfsextractchannels.cpp.orig	2005-06-15 13:36:54 UTC
2
+++ src/filter/pfsextractchannels.cpp
3
@@ -46,7 +46,7 @@ void printHelp()
4
     "See man page for more information.\n" );
5
 }
6
 
7
-static void errorCheck( bool condition, char *string )
8
+static void errorCheck( bool condition, char const *string )
9
 {
10
     if( !condition ) {
11
 	fprintf( stderr, PROG_NAME " error: %s\n", string );
(-)graphics/pfstools/files/patch-src-filter-pfspanoramic.cpp (-38 lines)
Lines 1-38 Link Here
1
--- src/filter/pfspanoramic.cpp.orig	2010-02-18 11:27:03 UTC
2
+++ src/filter/pfspanoramic.cpp
3
@@ -93,7 +93,7 @@ class Vector3D
4
   }
5
 
6
   //TODO: optimize rotations by precomputing sines and cosines
7
-  Vector3D rotateX(double angle)
8
+  void rotateX(double angle)
9
   {
10
     angle *= (M_PI / 180);
11
 
12
@@ -107,7 +107,7 @@ class Vector3D
13
     z = z2;
14
   }
15
 
16
-  Vector3D rotateY(double angle)
17
+  void rotateY(double angle)
18
   {
19
     angle *= (M_PI / 180);
20
 
21
@@ -121,7 +121,7 @@ class Vector3D
22
     z = z2;
23
   }
24
 
25
-  Vector3D rotateZ(double angle)
26
+  void rotateZ(double angle)
27
   {
28
     angle *= (M_PI / 180);
29
 
30
@@ -195,7 +195,7 @@ class ProjectionFactory
31
     {
32
       char *opts;
33
       
34
-      if(opts = strchr(name, '/'))
35
+      if ((opts = strchr(name, '/')))
36
       {
37
         *opts++ = '\0';
38
       }
(-)graphics/pfstools/files/patch-src-filter-pfstag.cpp (-23 lines)
Lines 1-23 Link Here
1
--- src/filter/pfstag.cpp.orig	2005-06-15 13:36:54 UTC
2
+++ src/filter/pfstag.cpp
3
@@ -58,7 +58,7 @@ struct TagOperation
4
   string channel;
5
 };
6
 
7
-typedef list<TagOperation> ListOfTags;
8
+typedef std::list<TagOperation> ListOfTags;
9
 
10
 TagOperation parseTagOperation( const char *tag, bool remove )
11
 {
12
@@ -133,9 +133,9 @@ void setTagsOnFrames( int argc, char* ar
13
     for( it = setTags.begin(); it != setTags.end(); it++ ) {
14
       TagOperation &tagop = *it;
15
       if( tagop.remove )       
16
-        cerr << PROG_NAME ": remove tag '" << tagop.name << "'\n";
17
+        std::cerr << PROG_NAME ": remove tag '" << tagop.name << "'\n";
18
       else
19
-        cerr << PROG_NAME ": set tag '" << tagop.name << "' to '" << tagop.value << "'\n";
20
+        std::cerr << PROG_NAME ": set tag '" << tagop.name << "' to '" << tagop.value << "'\n";
21
     }
22
     
23
   }
(-)graphics/pfstools/files/patch-src-filter-pfswb.cpp (-302 lines)
Lines 1-302 Link Here
1
--- src/filter/pfswb.cpp.orig	2016-08-12 19:10:44 UTC
2
+++ src/filter/pfswb.cpp
3
@@ -0,0 +1,299 @@
4
+/**
5
+ * @file pfswb.cpp
6
+ * @brief Adjust white balance in RGB color space
7
+ *
8
+ * This file is a part of PFSTOOLS package.
9
+ * ---------------------------------------------------------------------- 
10
+ * Copyright (C) 2008 Iouri V. Ivliev
11
+ * 
12
+ *  This program is free software; you can redistribute it and/or modify
13
+ *  it under the terms of the GNU General Public License as published by
14
+ *  the Free Software Foundation; either version 2 of the License, or
15
+ *  (at your option) any later version.
16
+ *
17
+ *  This program is distributed in the hope that it will be useful,
18
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+ *  GNU General Public License for more details.
21
+ *
22
+ *  You should have received a copy of the GNU General Public License
23
+ *  along with this program; if not, write to the Free Software
24
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
+ * ---------------------------------------------------------------------- 
26
+ * 
27
+ * @author Iouri V. Ivliev <ii@any.com.ru>
28
+ *
29
+ * $Id: $
30
+ */
31
+
32
+#include <config.h>
33
+
34
+#include <exception>
35
+#include <iostream>
36
+#include <sys/limits.h>
37
+#include <stdlib.h>
38
+#include <getopt.h>
39
+
40
+#include <pfs.h>
41
+
42
+#define PROG_NAME "pfswb"
43
+
44
+class QuietException 
45
+{
46
+};
47
+
48
+static void printHelp()
49
+{
50
+  std::cerr << PROG_NAME " (" PACKAGE_STRING ") :\n" 
51
+    "\t[--red <val>] [--green <val>] [--blue <val>]\n"
52
+    "\t[--auto] [--x <val>] [--y <val>] [--width <val>] [--height <val>]\n"
53
+    "\t[--keep-lum]\n"
54
+    "\t[--verbose] [--help]\n"
55
+    "See man page for more information.\n";
56
+}
57
+
58
+// verbose mode
59
+static bool verbose = false;
60
+
61
+// auto WB
62
+static bool autowb = false;
63
+// default gray box bounds
64
+static int x = 0;
65
+static int y = 0;
66
+static int width = INT_MAX/2;
67
+static int height = INT_MAX/2;
68
+
69
+// keep original luminance
70
+static bool keep = false;
71
+
72
+// default WB multipliers
73
+static float red = 1.f;
74
+static float green = 1.f;
75
+static float blue = 1.f;
76
+
77
+static void multipliers(
78
+    const pfs::Array2D &R, const pfs::Array2D &G, const pfs::Array2D &B, 
79
+    float &r, float &g, float &b)
80
+{
81
+  r = red;
82
+  g = green;
83
+  b = blue;
84
+  if (!autowb) return;
85
+  // auto WB gray box
86
+  int w = R.getCols();
87
+  int h = R.getRows();
88
+  if (x>=w || y>=h)
89
+    throw pfs::Exception("gray box is out of frame bounds");
90
+  int x1 = width+x;
91
+  if (x1>w) x1 = w;
92
+  int y1 = height+y;
93
+  if (y1>h) y1 = h;
94
+  VERBOSE_STR 
95
+    << "auto WB gray box: " 
96
+    << (x1-x) << "x" << (y1-y) << "+" << x << "+" << y << std::endl;
97
+  // auto WB multipliers
98
+  double ar = 0.;
99
+  double ag = 0.;
100
+  double ab = 0.;
101
+  for (int y0=y; y0<y1; ++y0)
102
+  {
103
+    for (int x0=x; x0<x1; ++x0)
104
+    {
105
+      ar += R(x0,y0);
106
+      ag += G(x0,y0);
107
+      ab += B(x0,y0);
108
+    }
109
+  }
110
+  int n = (x1-x)*(y1-y);
111
+  ar /= n;
112
+  ag /= n;
113
+  ab /= n;
114
+  VERBOSE_STR << "average red value: " << ar << std::endl;
115
+  VERBOSE_STR << "average green value: " << ag << std::endl;
116
+  VERBOSE_STR << "average blue value: " << ab << std::endl;
117
+  float a = (float)((ar+ag+ab)/3.);
118
+  r *= a/ar;
119
+  g *= a/ag;
120
+  b *= a/ab;
121
+}
122
+
123
+static void pfswb()
124
+{
125
+  pfs::DOMIO pfsio;
126
+  VERBOSE_STR << "auto WB: " << (autowb ? "yes" : "no" ) << std::endl;
127
+  VERBOSE_STR << "base red multiplier value: " << red << std::endl;
128
+  VERBOSE_STR << "base green multiplier value: " << green << std::endl;
129
+  VERBOSE_STR << "base blue multiplier value: " << blue << std::endl;
130
+  VERBOSE_STR << "keep original luminance: " << (keep ? "yes" : "no" ) << std::endl;
131
+  while (true) 
132
+  {
133
+    // Read frame
134
+    pfs::Frame *frame = pfsio.readFrame( stdin );
135
+    if (!frame)
136
+    {
137
+      break; // No more frames
138
+    }
139
+    // Get channels
140
+    pfs::Channel *X, *Y, *Z;
141
+    frame->getXYZChannels(X, Y, Z);
142
+    if (!(Y && X && Z))
143
+    {
144
+      throw pfs::Exception( "Missing X, Y, Z channels in the PFS stream" );
145
+    }
146
+    int w = Y->getCols();
147
+    int h = Y->getRows();
148
+    int s = w*h;
149
+    float min = 1e20, max = -1e20;
150
+    for (int i=s; i--; )
151
+    {
152
+      float const &l = (*Y)(i);
153
+      if (min > l) min = l;
154
+      if (max < l) max = l;
155
+    }
156
+    VERBOSE_STR << "luminance range of original frame: " << min << ":" << max << std::endl;
157
+    // Convert from XYZ to RGB
158
+    pfs::transformColorSpace(pfs::CS_XYZ, X, Y, Z, pfs::CS_RGB, X, Y, Z);
159
+    // WB adjustment
160
+    float r, g, b;
161
+    multipliers(*X,*Y,*Z,r,g,b);
162
+    VERBOSE_STR << "red multiplier value: " << r << std::endl;
163
+    VERBOSE_STR << "green multiplier value: " << g << std::endl;
164
+    VERBOSE_STR << "blue multiplier value: " << b << std::endl;
165
+    for (int i=s; i--; )
166
+    {
167
+      (*X)(i) *= r;
168
+      (*Y)(i) *= g;
169
+      (*Z)(i) *= b;
170
+    }
171
+    // Convert back to XYZ
172
+    pfs::transformColorSpace(pfs::CS_RGB, X, Y, Z, pfs::CS_XYZ, X, Y, Z);
173
+    float amin = 1e20, amax = -1e20;
174
+    for (int i=s; i--; )
175
+    {
176
+      float const &l = (*Y)(i);
177
+      if (amin > l) amin = l;
178
+      if (amax < l) amax = l;
179
+    }
180
+    VERBOSE_STR << "luminance range of adjusted frame: " << amin << ":" << amax << std::endl;
181
+    if (keep)
182
+    {
183
+      float k = (max-min)/(amax-amin);
184
+      float nmin = 1e20, nmax = -1e20;
185
+      for (int i=s; i--; )
186
+      {
187
+        float const l = ((*Y)(i)-amin)*k+min;
188
+        if (nmin > l) nmin = l;
189
+        if (nmax < l) nmax = l;
190
+        (*Y)(i) = l;
191
+        (*X)(i) *= k;
192
+        (*Z)(i) *= k;
193
+      }
194
+      VERBOSE_STR << "restored luminance range: " << nmin << ":" << nmax << std::endl;
195
+    }
196
+    // Write frame
197
+    pfsio.writeFrame(frame, stdout);
198
+    pfsio.freeFrame(frame);        
199
+  }
200
+}
201
+
202
+int main(int argc, char *const argv[])
203
+{
204
+  static const struct option cmdLineOptions[] = {
205
+    { "help", no_argument, NULL, 'h' },
206
+    { "verbose", no_argument, NULL, 'v' },
207
+    { "auto", no_argument, NULL, 'A' },
208
+    { "x", required_argument, NULL, 'X' },
209
+    { "y", required_argument, NULL, 'Y' },
210
+    { "width", required_argument, NULL, 'W' },
211
+    { "height", required_argument, NULL, 'H' },
212
+    { "keep-lum", no_argument, NULL, 'k' },
213
+    { "red", required_argument, NULL, 'r' },
214
+    { "green", required_argument, NULL, 'g' },
215
+    { "blue", required_argument, NULL, 'b' },
216
+    { NULL, 0, NULL, 0 }
217
+  };
218
+
219
+  try
220
+  {
221
+    int optionIndex = 0;
222
+    while (true)
223
+    {
224
+      int c = getopt_long(argc, argv, "hvAX:Y:W:H:kr:g:b:", cmdLineOptions, &optionIndex);
225
+      if (c == -1)
226
+      {
227
+        break;
228
+      }
229
+      switch (c)
230
+      {
231
+      case 'h':
232
+        printHelp();
233
+        throw QuietException();
234
+      case 'v':
235
+        verbose = true;
236
+        break;
237
+      case 'A':
238
+        autowb = true;
239
+        break;
240
+      case 'X':
241
+        x = (int)strtol(optarg, NULL, 10);
242
+        if (x<=0)
243
+          throw pfs::Exception("gray box x value out of range, should be >0");
244
+      break;
245
+      case 'Y':
246
+        y = (int)strtol(optarg, NULL, 10);
247
+        if (y<=0)
248
+          throw pfs::Exception("gray box y value out of range, should be >0");
249
+        break;
250
+      case 'W':
251
+        width = (int)strtol(optarg, NULL, 10);
252
+        if (width<=0)
253
+          throw pfs::Exception("gray box width value out of range, should be >0");
254
+        break;
255
+      case 'H':
256
+      height = (int)strtol(optarg, NULL, 10);
257
+        if (height<=0)
258
+          throw pfs::Exception("gray box height value out of range, should be >0");
259
+        break;
260
+      case 'k':
261
+        keep = true;
262
+        break;
263
+      case 'r':
264
+        red = strtof(optarg, NULL);
265
+        if (red<=0.0f)
266
+        throw pfs::Exception("red multiplier value out of range, should be >0");
267
+        break;
268
+      case 'g':
269
+        green = strtof(optarg, NULL);
270
+        if (green<=0.0f)
271
+          throw pfs::Exception("green multiplier value out of range, should be >0");
272
+        break;
273
+      case 'b':
274
+        blue = strtof(optarg, NULL);
275
+        if (blue<=0.0f)
276
+        throw pfs::Exception("blue multiplier value out of range, should be >0");
277
+        break;
278
+      case '?':
279
+        throw QuietException();
280
+      case ':':
281
+        throw QuietException();
282
+      }
283
+    }
284
+
285
+    pfswb();
286
+  }
287
+  catch (std::exception ex)
288
+  {
289
+    std::cerr << PROG_NAME" std error: " << ex.what() << std::endl;
290
+    return EXIT_FAILURE;
291
+  }        
292
+  catch (pfs::Exception ex)
293
+  {
294
+    std::cerr << PROG_NAME" error: " << ex.getMessage() << std::endl;
295
+    return EXIT_FAILURE;
296
+  }        
297
+  catch (QuietException ex)
298
+  {
299
+    return EXIT_FAILURE;
300
+  }        
301
+  return EXIT_SUCCESS;
302
+}
(-)graphics/pfstools/files/patch-src-hdrhtml-hdrhtml.cpp (-192 lines)
Lines 1-192 Link Here
1
--- src/hdrhtml/hdrhtml.cpp.orig	2009-03-11 21:45:55 UTC
2
+++ src/hdrhtml/hdrhtml.cpp
3
@@ -27,6 +27,7 @@
4
 
5
 #include "hdrhtml.h"
6
 
7
+#include <limits>
8
 #include <algorithm>
9
 #include <math.h>
10
 #include <fstream>
11
@@ -48,6 +49,8 @@
12
 
13
 #include <config.h>
14
 
15
+#define log2f(x)	((float)logf(x)/logf(2))
16
+
17
 // ================================================
18
 //        Parameters controllig the web page 
19
 // ================================================
20
@@ -94,8 +97,8 @@ public:
21
     
22
     if( min_val > max_val )             // missing min/max info
23
     {
24
-      min_val = numeric_limits<T>::max();
25
-      max_val = numeric_limits<T>::min();
26
+      min_val = std::numeric_limits<T>::max();
27
+      max_val = std::numeric_limits<T>::min();
28
 
29
       for( int k=0; k < d_size; k++ ) {
30
         if( data[k] > max_val ) max_val = data[k];
31
@@ -195,6 +198,7 @@ public:
32
     this->y_i = new float[lut_size];
33
     own_y_i = true;
34
     memcpy(this->y_i, other.y_i, lut_size * sizeof(float));
35
+    return *this;
36
   }
37
 
38
   ~UniformArrayLUT()
39
@@ -341,7 +345,7 @@ public:
40
     for( int k = 1; k < bin_n; k++ )
41
       hist.n[k] += hist.n[k-1];
42
 
43
-//    cerr << "d_size: " << d_size << "  hist.n: " << hist.n[bin_n-1] << "\n";
44
+//    std::cerr << "d_size: " << d_size << "  hist.n: " << hist.n[bin_n-1] << "\n";
45
     assert( hist.n[bin_n-1] == d_size );    
46
   }
47
 
48
@@ -361,7 +365,7 @@ public:
49
 //            Text template file utils
50
 // ================================================
51
 
52
-typedef void (*replace_callback)( ostream &out, void *user_data, const char *parameter );
53
+typedef void (*replace_callback)( std::ostream &out, void *user_data, const char *parameter );
54
 
55
 class ReplacePattern
56
 {
57
@@ -403,7 +407,7 @@ public:
58
   {
59
   }
60
   
61
-  virtual void write_replacement( ostream &out, const char *parameter = NULL )
62
+  virtual void write_replacement( std::ostream &out, const char *parameter = NULL )
63
   {
64
     if( callback != NULL )
65
       callback( out, user_data, parameter );
66
@@ -567,7 +571,7 @@ public:
67
         // Skip white spaces
68
         while( line_str[pos] == ' ' || line_str[pos] == '\t' ) pos++;
69
         int new_pos = line_str.find_first_of( ',', pos );
70
-        int len;
71
+        size_t len;
72
         if( new_pos == std::string::npos ) {
73
           if( k != columns-1 ) {
74
             std::string full_message( "Missing column data in the file: " );
75
@@ -576,16 +580,16 @@ public:
76
           }
77
           len = std::string::npos;
78
         } else
79
-          len = new_pos-pos;
80
+          len = (size_t)(new_pos-pos);
81
         
82
         float value;
83
         if( len == 0 ) {
84
-          value = numeric_limits<float>::quiet_NaN();
85
+          value = std::numeric_limits<float>::quiet_NaN();
86
         } else {
87
           std::string token = line_str.substr( pos, len );
88
           const char *str_beg = token.c_str();
89
           char *str_end;
90
-//          cerr << "token: " << str_beg << "\n";
91
+//          std::cerr << "token: " << str_beg << "\n";
92
           value = strtof( str_beg, &str_end );
93
           if( str_beg == str_end ) {
94
             std::ostringstream error_message;
95
@@ -643,15 +647,15 @@ void HDRHTMLSet::add_image( int width, i
96
     basis_table.data[0][k] = log2f( basis_table.data[0][k] );
97
   
98
 // Fix zero and negative values in the image, convert to log2 space, find min and max values
99
-  float img_min = numeric_limits<float>::max();
100
-  float img_max = numeric_limits<float>::min();
101
+  float img_min = std::numeric_limits<float>::max();
102
+  float img_max = std::numeric_limits<float>::min();
103
   {
104
     float *arrays[] = { R, G, B, Y };
105
     int k;
106
 
107
     for( k = 0; k < 4; k++ ) {
108
       float *x = arrays[k];
109
-      float min_val = numeric_limits<float>::max(), max_val = numeric_limits<float>::min();
110
+      float min_val = std::numeric_limits<float>::max(), max_val = std::numeric_limits<float>::min();
111
       for( int i=0; i < pixels; i++ ) {
112
         if( x[i] < min_val && x[i] > 0)
113
           min_val = x[i];
114
@@ -741,7 +745,7 @@ void HDRHTMLSet::add_image( int width, i
115
   for( int k=1; k <= f8_stops+1; k++ ) {
116
 
117
 
118
-    float max_value = (float)numeric_limits<unsigned short>::max(); //(1<<16) -1;
119
+    float max_value = (float)std::numeric_limits<unsigned short>::max(); //(1<<16) -1;
120
 
121
     float exp_multip = log2f(1/powf( 2, l_start + k*8 ));
122
 
123
@@ -796,9 +800,9 @@ void HDRHTMLSet::add_image( int width, i
124
   
125
 }
126
 
127
-void print_image_objects( ostream &out, void *user_data, const char *parameter );
128
-void print_cf_table( ostream &out, void *user_data, const char *parameter );
129
-void print_image_htmlcode( ostream &out, void *user_data, const char *parameter );
130
+void print_image_objects( std::ostream &out, void *user_data, const char *parameter );
131
+void print_cf_table( std::ostream &out, void *user_data, const char *parameter );
132
+void print_image_htmlcode( std::ostream &out, void *user_data, const char *parameter );
133
 
134
 void HDRHTMLSet::generate_webpage( const char *page_template, const char *image_template,
135
   const char *object_output, const char *html_output)
136
@@ -852,11 +856,11 @@ void HDRHTMLSet::generate_webpage( const
137
   
138
 }
139
 
140
-void print_image_objects( ostream &out, void *user_data, const char *parameter )
141
+void print_image_objects( std::ostream &out, void *user_data, const char *parameter )
142
 {
143
   HDRHTMLSet *hdrhtml_set = (HDRHTMLSet*)user_data;
144
 
145
-  list<HDRHTMLImage>::iterator it;
146
+  std::list<HDRHTMLImage>::iterator it;
147
   for( it = hdrhtml_set->image_list.begin(); it != hdrhtml_set->image_list.end(); it++ ) {  
148
     std::string obj_name( "hdr_" );
149
     obj_name.append( it->base_name );
150
@@ -882,7 +886,7 @@ void print_image_objects( ostream &out, 
151
   
152
 }
153
 
154
-void print_image_htmlcode( ostream &out, HDRHTMLSet *hdrhtml_set, const HDRHTMLImage &it )
155
+void print_image_htmlcode( std::ostream &out, HDRHTMLSet *hdrhtml_set, const HDRHTMLImage &it )
156
 {
157
     std::string obj_name( "hdr_" );
158
     obj_name.append( it.base_name );
159
@@ -907,13 +911,13 @@ void print_image_htmlcode( ostream &out,
160
  
161
 }
162
 
163
-void print_image_htmlcode( ostream &out, void *user_data, const char *parameter )
164
+void print_image_htmlcode( std::ostream &out, void *user_data, const char *parameter )
165
 {
166
   HDRHTMLSet *hdrhtml_set = (HDRHTMLSet*)user_data;
167
 
168
   if( parameter != NULL ) {
169
 
170
-    list<HDRHTMLImage>::iterator it;
171
+    std::list<HDRHTMLImage>::iterator it;
172
     for( it = hdrhtml_set->image_list.begin(); it != hdrhtml_set->image_list.end(); it++ ) {
173
       if( it->base_name.compare( parameter ) == 0 )
174
         break;
175
@@ -925,7 +929,7 @@ void print_image_htmlcode( ostream &out,
176
     
177
   } else {
178
     
179
-    list<HDRHTMLImage>::iterator it;
180
+    std::list<HDRHTMLImage>::iterator it;
181
     for( it = hdrhtml_set->image_list.begin(); it != hdrhtml_set->image_list.end(); it++ ) {
182
       
183
       print_image_htmlcode( out, hdrhtml_set, *it );
184
@@ -935,7 +939,7 @@ void print_image_htmlcode( ostream &out,
185
   
186
 }
187
 
188
-void print_cf_table( ostream &out, void *user_data, const char *parameter )
189
+void print_cf_table( std::ostream &out, void *user_data, const char *parameter )
190
 {
191
   CSVTable *cf = (CSVTable*)user_data;
192
   
(-)graphics/pfstools/files/patch-src-matlab-compatibility.h (-10 lines)
Lines 1-10 Link Here
1
--- src/matlab/compatibility.h.orig	2007-03-01 14:10:57 UTC
2
+++ src/matlab/compatibility.h
3
@@ -59,6 +59,6 @@
4
 
5
 #endif
6
 
7
-#define DEBUG_STR if(1); else cerr
8
+#define DEBUG_STR if(1); else std::cerr
9
 
10
 #endif
(-)graphics/pfstools/files/patch-src-octave-pfsclose.cpp (-14 lines)
Lines 1-14 Link Here
1
--- src/octave/pfsclose.cpp.orig	2016-02-12 17:10:27 UTC
2
+++ src/octave/pfsclose.cpp
3
@@ -53,9 +53,9 @@ DEFUN_DLD( pfsclose, args, , helpString 
4
     return retval;
5
   }
6
 
7
-  Octave_map pfsStream = args(0).map_value();
8
+  octave_map pfsStream = args(0).map_value();
9
 
10
-  Octave_map::const_iterator itFH = pfsStream.seek( "FH" );
11
+  octave_map::const_iterator itFH = pfsStream.seek( "FH" );
12
   if( itFH == pfsStream.end() ||
13
     !pfsStream.contents( itFH )(0).is_real_scalar() )
14
   {
(-)graphics/pfstools/files/patch-src-octave-pfsget.cpp (-58 lines)
Lines 1-58 Link Here
1
--- src/octave/pfsget.cpp.orig	2016-02-12 17:10:27 UTC
2
+++ src/octave/pfsget.cpp
3
@@ -52,9 +52,9 @@ DEFUN_DLD( pfsget, args, , helpString)
4
     return retval;
5
   }
6
 
7
-  Octave_map pfsStream = args(0).map_value();
8
+  octave_map pfsStream = args(0).map_value();
9
 
10
-  Octave_map::const_iterator itFH = pfsStream.seek( "FH" );
11
+  octave_map::const_iterator itFH = pfsStream.seek( "FH" );
12
   if( itFH == pfsStream.end() ||
13
     !pfsStream.contents( itFH )(0).is_real_scalar() )
14
   {
15
@@ -63,7 +63,7 @@ DEFUN_DLD( pfsget, args, , helpString)
16
   }  
17
   FILE *fh = (FILE*)((long)(pfsStream.contents( itFH )(0).double_value()));
18
 
19
-  Octave_map::const_iterator itMode = pfsStream.seek( "MODE" );
20
+  octave_map::const_iterator itMode = pfsStream.seek( "MODE" );
21
   if( itMode == pfsStream.end() || !pfsStream.contents( itMode )(0).is_string() )
22
   {
23
     error( SCRIPT_NAME ": MODE field missing in the structure or it has wrong type");
24
@@ -95,7 +95,7 @@ DEFUN_DLD( pfsget, args, , helpString)
25
     
26
       // Add channels as matrices to pfs stream struct
27
       {
28
-        Octave_map channels;
29
+        octave_scalar_map channels;
30
         
31
         pfs::ChannelIteratorPtr cit( frame->getChannelIterator() );
32
         while( cit->hasNext() ) {
33
@@ -115,7 +115,7 @@ DEFUN_DLD( pfsget, args, , helpString)
34
 
35
       //Add tags
36
       {
37
-        Octave_map tags;
38
+        octave_scalar_map tags;
39
         
40
         pfs::TagIteratorPtr it( frame->getTags()->getIterator() );        
41
         while( it->hasNext() ) {
42
@@ -124,14 +124,14 @@ DEFUN_DLD( pfsget, args, , helpString)
43
         }
44
         pfsStream.assign( "tags", tags );
45
         
46
-        Octave_map channelTagList;
47
+        octave_scalar_map channelTagList;
48
 
49
         //Copy all channel tags
50
         pfs::ChannelIteratorPtr cit( frame->getChannelIterator() );
51
         while( cit->hasNext() ) {
52
           pfs::Channel *ch = cit->getNext();
53
 
54
-          Octave_map channelTags;
55
+          octave_scalar_map channelTags;
56
           
57
           pfs::TagIteratorPtr tit( ch->getTags()->getIterator() );        
58
           while( tit->hasNext() ) {
(-)graphics/pfstools/files/patch-src-octave-pfsopen.cpp (-20 lines)
Lines 1-20 Link Here
1
--- src/octave/pfsopen.cpp.orig	2016-02-12 17:10:27 UTC
2
+++ src/octave/pfsopen.cpp
3
@@ -137,7 +137,7 @@ DEFUN_DLD( pfsopen, args, , helpString)
4
     }    
5
   }
6
 
7
-  Octave_map pfsStream;
8
+  octave_map pfsStream;
9
   pfsStream.assign( "FH", octave_value((double)((long)fh)) );
10
   pfsStream.assign( "MODE", writeMode ? octave_value("W") : octave_value("R") );
11
   pfsStream.assign( "EOF", octave_value(false) );
12
@@ -145,7 +145,7 @@ DEFUN_DLD( pfsopen, args, , helpString)
13
   if( writeMode ) {
14
     pfsStream.assign( "columns", octave_value(width) );
15
     pfsStream.assign( "rows", octave_value(height) );
16
-    Octave_map channels;
17
+    octave_map channels;
18
     pfsStream.assign( "channels", octave_value(channels) );    
19
   }
20
   
(-)graphics/pfstools/files/patch-src-octave-pfsput.cpp (-103 lines)
Lines 1-103 Link Here
1
--- src/octave/pfsput.cpp.orig	2016-02-12 17:10:27 UTC
2
+++ src/octave/pfsput.cpp
3
@@ -52,9 +52,9 @@ DEFUN_DLD( pfsput, args, , helpString)
4
     return retval;
5
   }
6
   
7
-  Octave_map pfsStream = args(0).map_value();
8
+  octave_map pfsStream = args(0).map_value();
9
 
10
-  Octave_map::const_iterator itFH = pfsStream.seek( "FH" );
11
+  octave_map::const_iterator itFH = pfsStream.seek( "FH" );
12
   if( itFH == pfsStream.end() ||
13
     !pfsStream.contents( itFH )(0).is_real_scalar() )
14
   {
15
@@ -65,7 +65,7 @@ DEFUN_DLD( pfsput, args, , helpString)
16
 
17
   // Check mode
18
   {                             
19
-    Octave_map::const_iterator itMode = pfsStream.seek( "MODE" );
20
+    octave_map::const_iterator itMode = pfsStream.seek( "MODE" );
21
     if( itMode == pfsStream.end() || !pfsStream.contents( itMode )(0).is_string() )
22
     {
23
       error( SCRIPT_NAME ": MODE field missing in the structure or it has wrong type");
24
@@ -80,8 +80,8 @@ DEFUN_DLD( pfsput, args, , helpString)
25
   // Get width & height
26
   int width, height;
27
   {                             
28
-    Octave_map::const_iterator itCols = pfsStream.seek( "columns" );
29
-    Octave_map::const_iterator itRows = pfsStream.seek( "rows" );
30
+    octave_map::const_iterator itCols = pfsStream.seek( "columns" );
31
+    octave_map::const_iterator itRows = pfsStream.seek( "rows" );
32
     if( itCols == pfsStream.end() || itRows == pfsStream.end() ||
33
       !pfsStream.contents( itCols )(0).is_real_scalar() ||
34
       !pfsStream.contents( itRows )(0).is_real_scalar() )
35
@@ -94,9 +94,9 @@ DEFUN_DLD( pfsput, args, , helpString)
36
   }
37
 
38
   // Get channels
39
-  Octave_map channels;
40
+  octave_map channels;
41
   {
42
-    Octave_map::const_iterator itChannels = pfsStream.seek( "channels" );
43
+    octave_map::const_iterator itChannels = pfsStream.seek( "channels" );
44
     if( itChannels == pfsStream.end() ||
45
       !pfsStream.contents( itChannels )(0).is_map() )
46
     {
47
@@ -111,7 +111,7 @@ DEFUN_DLD( pfsput, args, , helpString)
48
     pfs::Frame *frame = ctx.createFrame( width, height );
49
 
50
     // For each channel in the 'channels' map
51
-    for( Octave_map::iterator itCh = channels.begin(); itCh != channels.end(); itCh++ ) {
52
+    for( octave_map::iterator itCh = channels.begin(); itCh != channels.end(); itCh++ ) {
53
       std::string channelName = channels.key(itCh);
54
 
55
       if( !channels.contents( itCh )(0).is_real_matrix() ) {
56
@@ -135,15 +135,15 @@ DEFUN_DLD( pfsput, args, , helpString)
57
 
58
     // Copy frame tags
59
     {
60
-      Octave_map::const_iterator itTags = pfsStream.seek( "tags" );
61
+      octave_map::const_iterator itTags = pfsStream.seek( "tags" );
62
       if( itTags != pfsStream.end() ) {
63
         if( !pfsStream.contents( itTags )(0).is_map() )
64
         {
65
           throw pfs::Exception( "'tags' field must be a structure" );  
66
         }
67
         
68
-        Octave_map tags = pfsStream.contents( itTags )(0).map_value();
69
-        for( Octave_map::iterator itTag = tags.begin(); itTag != tags.end(); itTag++ ) {
70
+        octave_map tags = pfsStream.contents( itTags )(0).map_value();
71
+        for( octave_map::iterator itTag = tags.begin(); itTag != tags.end(); itTag++ ) {
72
           std::string tagName = tags.key(itTag);
73
 
74
           if( !tags.contents( itTag )(0).is_string() ) 
75
@@ -156,14 +156,14 @@ DEFUN_DLD( pfsput, args, , helpString)
76
 
77
     // Copy channel tags
78
     {
79
-      Octave_map::const_iterator itChTags = pfsStream.seek( "channelTags" );
80
+      octave_map::const_iterator itChTags = pfsStream.seek( "channelTags" );
81
       if( itChTags != pfsStream.end() ) {
82
         if( !pfsStream.contents( itChTags )(0).is_map() )
83
         {
84
           throw pfs::Exception( "'channelTags' field must be a structure" );  
85
         }
86
-        Octave_map tagChannels = pfsStream.contents( itChTags )(0).map_value();
87
-        for( Octave_map::iterator itCh = tagChannels.begin(); itCh != tagChannels.end(); itCh++ ) {
88
+        octave_map tagChannels = pfsStream.contents( itChTags )(0).map_value();
89
+        for( octave_map::iterator itCh = tagChannels.begin(); itCh != tagChannels.end(); itCh++ ) {
90
           std::string channelName = tagChannels.key(itCh);
91
           if( !tagChannels.contents( itCh )(0).is_map() ) {
92
             throw pfs::Exception( "each channelTags file must be a structure" );  
93
@@ -173,8 +173,8 @@ DEFUN_DLD( pfsput, args, , helpString)
94
             throw pfs::Exception( "can not set channel tag if channel is missing" );
95
           }
96
           
97
-          Octave_map tags = tagChannels.contents( itCh )(0).map_value();
98
-          for( Octave_map::iterator itTag = tags.begin(); itTag != tags.end(); itTag++ ) {
99
+          octave_map tags = tagChannels.contents( itCh )(0).map_value();
100
+          for( octave_map::iterator itTag = tags.begin(); itTag != tags.end(); itTag++ ) {
101
             std::string tagName = tags.key(itTag);
102
             if( !tags.contents( itTag )(0).is_string() ) 
103
               throw pfs::Exception( "all channel tags must be given as strings" );
(-)graphics/pfstools/files/patch-src-pfs-pfs.cpp (-29 lines)
Lines 1-29 Link Here
1
--- src/pfs/pfs.cpp.orig	2010-07-14 09:44:27 UTC
2
+++ src/pfs/pfs.cpp
3
@@ -71,7 +71,7 @@ const char *PFSFILEID="PFS1\x0a";
4
 // TagContainer implementation  
5
 //------------------------------------------------------------------------------
6
 
7
-typedef list<string> TagList;
8
+typedef std::list<string> TagList;
9
 
10
 class TagIteratorImpl: public TagIterator
11
 {
12
@@ -570,7 +570,7 @@ public:
13
 
14
     //Read channel IDs and tags
15
     //       FrameImpl::ChannelID *channelID = new FrameImpl::ChannelID[channelCount];
16
-    list<ChannelImpl*> orderedChannel;
17
+    std::list<ChannelImpl*> orderedChannel;
18
     for( int i = 0; i < channelCount; i++ ) {
19
       char channelName[MAX_CHANNEL_NAME+1], *rs;
20
       rs = fgets( channelName, MAX_CHANNEL_NAME, inputStream );
21
@@ -592,7 +592,7 @@ public:
22
     
23
 
24
     //Read channels
25
-    list<ChannelImpl*>::iterator it;
26
+    std::list<ChannelImpl*>::iterator it;
27
     for( it = orderedChannel.begin(); it != orderedChannel.end(); it++ ) {
28
       ChannelImpl *ch = *it;
29
       int size = frame->getWidth()*frame->getHeight();
(-)graphics/pfstools/files/patch-src-pfs-pfs.h (-54 lines)
Lines 1-54 Link Here
1
--- src/pfs/pfs.h.orig	2006-03-01 17:21:16 UTC
2
+++ src/pfs/pfs.h
3
@@ -115,6 +115,7 @@ namespace pfs
4
   class TagIterator 
5
     {
6
     public:
7
+      virtual ~TagIterator() {};
8
       /**
9
        * Get next item on the list.
10
        *
11
@@ -135,6 +136,7 @@ namespace pfs
12
   class TagContainer
13
     {
14
     public:
15
+      virtual ~TagContainer() {};
16
       /**
17
        * Get a string tag of the name tagName from the TagContainer.
18
        * @param tagName name of the tag to retrieve
19
@@ -181,6 +183,7 @@ namespace pfs
20
  */
21
   class Channel : public Array2D {
22
   public:
23
+    virtual ~Channel() {};
24
     /**
25
      * Gets width of the channel (in pixels).
26
      * This is a synonym for Array2D::getCols().
27
@@ -226,6 +229,7 @@ namespace pfs
28
   class ChannelIterator 
29
     {
30
     public:
31
+      virtual ~ChannelIterator() {};
32
       /**
33
        * Get next item on the list.
34
        */
35
@@ -580,7 +584,9 @@ namespace pfs
36
        */
37
       Exception( const char* const message )
38
 	{
39
-          strcpy( msg, message );
40
+          const size_t s = sizeof(msg)/sizeof(msg[0]) - 1;
41
+          strncpy( msg, message, s );
42
+          msg[s] = '\0';
43
 	}
44
 			
45
       ~Exception() {};
46
@@ -590,7 +596,7 @@ namespace pfs
47
        *
48
        * @return text description of the cause for the exception
49
        */
50
-      const char* getMessage()
51
+      const char* getMessage() const
52
         {
53
           return msg;
54
 	}
(-)graphics/pfstools/files/patch-src-pfs-pfsutils.cpp (-11 lines)
Lines 1-11 Link Here
1
--- src/pfs/pfsutils.cpp.orig	2006-09-21 21:42:54 UTC
2
+++ src/pfs/pfsutils.cpp
3
@@ -81,7 +81,7 @@ class FrameFileIteratorImpl
4
   char fileName[1024];
5
   FILE *stdinout;
6
 
7
-  typedef list<FilePattern> PatternList;
8
+  typedef std::list<FilePattern> PatternList;
9
 
10
   PatternList patternList;
11
   PatternList::iterator currentPattern;
(-)graphics/pfstools/files/patch-src-pfsglview-picture_io.cpp (-29 lines)
Lines 1-29 Link Here
1
--- src/pfsglview/picture_io.cpp.orig	2006-11-20 12:13:13 UTC
2
+++ src/pfsglview/picture_io.cpp
3
@@ -87,7 +87,7 @@ void PictureIO::setFrame(pfs::Frame *fra
4
 		return;
5
 
6
 	// only XYZ channels are taken into consideration
7
-	if( channel != "XYZ" &&  channel != "X00" && channel != "0Y0" && channel != "00Z" ) {
8
+	if (strcmp(channel,"XYZ") && strcmp(channel,"X00") && strcmp(channel,"0Y0") && strcmp(channel,"00Z")) {
9
 		if(verbose)
10
 			fprintf( stderr, "WARNING: wrong channel (PictureIO::setFrame())\n");
11
 		return;
12
@@ -573,7 +573,7 @@ float PictureIO::getDynamicRange(void) {
13
 	}	
14
 	std::sort(vec.begin(), vec.end());
15
 	
16
-	printf("size: %d\n", vec.size());
17
+	printf("size: %lu\n", vec.size());
18
 	
19
 	val = vec[0];
20
 	std::vector<unsigned int> svec;
21
@@ -589,7 +589,7 @@ float PictureIO::getDynamicRange(void) {
22
 	
23
 	float dr = svec[ svec.size()-1] / svec[0];
24
 			
25
-	printf("min:%ld  max:%ld  svec size: %d  dr:%f\n", vec[0], vec[ vec.size()-1], svec.size(), log10(dr));
26
+	printf("min:%u  max:%u  svec size: %lu  dr:%f\n", vec[0], vec[ vec.size()-1], svec.size(), log10(dr));
27
 
28
 	
29
 
(-)graphics/pfstools/files/patch-src-pfsglview-picture_io.h (-13 lines)
Lines 1-13 Link Here
1
--- src/pfsglview/picture_io.h.orig	2008-07-29 16:14:30 UTC
2
+++ src/pfsglview/picture_io.h
3
@@ -6,7 +6,9 @@
4
 
5
 #define MAX_FRAMES_IN_MEMORY 10
6
 
7
-class pfs::Frame;
8
+namespace pfs {
9
+class Frame;
10
+};
11
 enum LumMappingMethod {
12
 			MAP_LINEAR,
13
 			MAP_GAMMA1_4,
(-)graphics/pfstools/files/patch-src-pfsview-pfsview_widget.cpp (-22 lines)
Lines 1-22 Link Here
1
--- src/pfsview/pfsview_widget.cpp.orig	2011-04-30 14:01:17 UTC
2
+++ src/pfsview/pfsview_widget.cpp
3
@@ -142,7 +142,7 @@ void PFSViewWidget::setFrame( pfs::Frame
4
     // Chose first available channel
5
     pfs::ChannelIterator *it = frame->getChannels();
6
     if( !it->hasNext() )      // TODO: failover
7
-      throw new pfs::Exception( "No channels available!" );
8
+      throw pfs::Exception( "No channels available!" );
9
     visibleChannel = it->getNext()->getName();
10
   } else if( visibleChannel != COLOR_CHANNELS ) {
11
     // Get a new pointer, as the old frame object
12
@@ -335,8 +335,8 @@ static void mapFrameToImage( pfs::Array2
13
   assert( !color || (color && B != NULL) );
14
 
15
   
16
-  float lutPixFloor[257*2];
17
-  QRgb lutPixel[257*2];
18
+  float lutPixFloor[257*2+1];
19
+  QRgb lutPixel[257*2+1];
20
   int lutSize;
21
   if( !color && ( negativeTreatment == NEGATIVE_GREEN_SCALE ||
22
         negativeTreatment == NEGATIVE_ABSOLUTE ) ) { // Handle negative numbers
(-)graphics/pfstools/files/patch-src_camera_CMakeLists.txt (+11 lines)
Line 0 Link Here
1
--- src/camera/CMakeLists.txt.orig	2018-01-19 06:59:44 UTC
2
+++ src/camera/CMakeLists.txt
3
@@ -4,7 +4,7 @@ include_directories ("${PROJECT_BINARY_D
4
 link_directories("${PROJECT_SOURCE_DIR}/src/pfs")
5
 
6
 set(TRG pfshdrcalibrate)
7
-add_executable(${TRG} ${TRG}.cpp  responses.cpp robertson02.cpp  mitsunaga99.cpp  mitsunaga99_numerical.cpp nrutil.cpp "${GETOPT_OBJECT}")			  
8
+add_executable(${TRG} ${TRG}.cpp  responses.cpp robertson02.cpp robertson02old.cpp  mitsunaga99.cpp  mitsunaga99_numerical.cpp nrutil.cpp "${GETOPT_OBJECT}")			  
9
 target_link_libraries(${TRG} pfs)
10
 install (TARGETS ${TRG} DESTINATION bin)
11
 install (FILES ${TRG}.1 DESTINATION ${MAN_DIR})
(-)graphics/pfstools/files/patch-src_camera_pfshdrcalibrate.1 (+112 lines)
Line 0 Link Here
1
--- src/camera/pfshdrcalibrate.1.orig	2018-01-19 06:59:44 UTC
2
+++ src/camera/pfshdrcalibrate.1
3
@@ -5,12 +5,14 @@ from a set of differently exposed images
4
 
5
 .SH SYNOPSIS
6
 .B pfshdrcalibrate
7
-[--response <type>] [--calibration <type>]
8
+[--response <type>] [--weights <type>]
9
+[--method <type>] [--no-calibration]
10
 [--gauss <val>]
11
 [--response-file <filename.m>]
12
 [--save-response <filename.m>]
13
 [--multiplier <val>] [--bpp <val>]
14
-[--luminance] [--samples <val>]
15
+[--luminance] [--deghosting]
16
+[--samples <val>]
17
 [--help] [--verbose]
18
 
19
 .SH DESCRIPTION
20
@@ -38,13 +40,20 @@ automatic self-calibration. Predefined r
21
 "gamma", "log". Default is "linear". This option can be used only with Robertson method.
22
 
23
 .TP
24
---calibration <type>, -c <type>
25
+--weights <type>, -w <type>
26
+
27
+Allows one to choose from predefined weighting finctions. Predefined
28
+weighting finctions are: "gauss" and "composite". Default is "composite".
29
+
30
+.TP
31
+--method <type>, -c <type>
32
 
33
 Type of automatic self-calibration method used for recovery of the
34
 response curve and/or type of method used for HDR merging. Accepted
35
-types include: "robertson", "mitsunaga". "robertson" is the default
36
-and recommended algorithm (see commends in the Bugs section
37
-below). More infomation on the algorithms can be found in:
38
+types include: "robertson", "mitsunaga" and "robertson-old".
39
+"robertson" is the default and recommended algorithm (see commends
40
+in the Bugs section below). More infomation on the algorithms can
41
+be found in:
42
 .IP
43
 M.A. Robertson,  S. Borman and R.L. Stevenson
44
 .PD 0
45
@@ -63,6 +72,12 @@ Radiometric Self Calibration
46
 .IP
47
 In: Proc on IEEE Conf. on Computer Vision and Pattern Recognition (CVPR'99). Volume 1, p. 1374
48
 .PD
49
+
50
+.TP
51
+--no-calibration, -C
52
+
53
+Disable self-calibration. Only do HDR merging or save responce.
54
+
55
 .TP
56
 --gauss <val>, -g <val>
57
 
58
@@ -80,16 +95,15 @@ response curve (see -c option).
59
 --save-response <filename.m>, -s <filename.m>
60
 
61
 Saves the response curve calculated during automatic self-calibration
62
-stage in a matlab format file. Can be later reused for set of images
63
-captured with given camera. Also works fine for plotting with gnuplot.
64
+stage (or predefined curve when self-calibration disabled) in a matlab
65
+format file. Can be later reused for set of images captured with given
66
+camera. Also works fine for plotting with gnuplot.
67
 
68
 .TP
69
 --multiplier <val>, -m <val>
70
 
71
 Input multiplier value. Can be used to manipulate the range of source
72
-exposures. Default value for Robertson method is 256 since LDR images
73
-are by default scaled to 0..1. This value is set to 1.0 for Mitsunaga
74
-method.
75
+exposures. Default value is 1.
76
 
77
 .TP
78
 --bpp <val>, -b <val>
79
@@ -97,6 +111,13 @@ method.
80
 Number of bits per pixel in input data from the camera. Default value
81
 is 8.
82
 
83
+Actually, the bpp parameter sets the number of levels used in the
84
+camera's response to 2**<val>. When a response curve is loaded from
85
+a file, this parameter has no effect. In this case, the number
86
+of input levels will be the same as the response curve levels.
87
+To change the number of levels in the response curve file, use the
88
+pfssmoothresp(1) command.
89
+
90
 .TP
91
 --samples <val>, -p <val>
92
 
93
@@ -172,6 +193,7 @@ mitsunaga self-calibration method with 1
94
 .BR pfsindcraw (1)
95
 .BR pfsabsolute (1)
96
 .BR pfsglview (1)
97
+.BR pfssmoothresp (1)
98
 .SH BUGS
99
 Currently Mitsunaga and Nayar's method does not produce reliable
100
 camera response curves. Robertson's method should be used instead.
101
@@ -186,6 +208,11 @@ research purposes and getting accurate r
102
 generating good looking images. The heuristics could hide the well
103
 visible artifacts, but would also introduce error to the measurements.
104
 .PP
105
+Sometimes Robertson's automatic self-calibration with "robertson"
106
+method cannot successfully comlete. Try to use "robertson-old" method
107
+\- the previous (stolen from pfscalibration 1.4) implementation
108
+of the Robertson02 algorithm.
109
+.PP
110
 For any other issues please report bugs and comments on implementation
111
 to the discussion group http://groups.google.com/group/pfstools
112
 
(-)graphics/pfstools/files/patch-src_camera_pfshdrcalibrate.cpp (+755 lines)
Line 0 Link Here
1
--- src/camera/pfshdrcalibrate.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/camera/pfshdrcalibrate.cpp
3
@@ -42,6 +42,7 @@
4
 
5
 #include <responses.h>
6
 #include <robertson02.h>
7
+#include <robertson02old.h>
8
 #include <mitsunaga99.h>
9
 
10
 using namespace std;
11
@@ -58,9 +59,12 @@ inline float max3( float a, float b, flo
12
 inline float min3( float a, float b, float c )
13
 {
14
   // ignore zero values
15
-  if( int(a)==0 ) a=1e8;
16
-  if( int(b)==0 ) b=1e8;
17
-  if( int(c)==0 ) c=1e8;
18
+  if (a <= std::numeric_limits<float>::epsilon())
19
+    a = std::numeric_limits<float>::max();
20
+  if (b <= std::numeric_limits<float>::epsilon())
21
+    b = std::numeric_limits<float>::max();
22
+  if (c <= std::numeric_limits<float>::epsilon())
23
+    c = std::numeric_limits<float>::max();
24
   
25
   float min = (a<b) ? a : b;
26
   return (c<min) ? c : min;
27
@@ -78,11 +82,12 @@ class QuietException 
28
 void printHelp()
29
 {
30
   fprintf( stderr, PROG_NAME ": \n"
31
-    "\t[--calibration <type>] [--luminance]\n"
32
-    "\t[--response <type>] [--response-file <filename.m>] \n"
33
-    "\t[--save-response <filename.m>] \n"
34
+    "\t[--method <type>] [--no-calibration]\n"
35
+    "\t[--response <type>] [--weights <type>]\n"
36
+    "\t[--response-file <filename.m>] [--save-response <filename.m>]\n"
37
     "\t[--multiplier <val>] \n"
38
     "\t[--bpp <val>] \n"
39
+    "\t[--luminance] [--deghosting]\n"
40
     "\t[--verbose] [--help]\n"
41
     "See man page for more information.\n" );
42
 }
43
@@ -103,20 +108,22 @@ void pfshdrcalibrate( int argc, char* ar
44
   enum TCalibration 
45
     { NONE, CALIBRATE } opt_calibration = CALIBRATE;
46
   enum TResponse
47
-    { FROM_FILE, LINEAR, GAMMA, LOG10 } opt_response = LINEAR;
48
+    { FROM_FILE_RESP, LINEAR_RESP, GAMMA_RESP, LOG10_RESP } opt_response = LINEAR_RESP;
49
+  enum TWeight
50
+    { FROM_FILE_WEIGHT, GAUSS_WEIGHT, COMPOSITE_WEIGHT } opt_weight = COMPOSITE_WEIGHT;
51
   enum TMethod
52
-    { ROBERTSON_METHOD, MITSUNAGA_METHOD } opt_method = ROBERTSON_METHOD;
53
+    { ROBERTSON_METHOD, MITSUNAGA_METHOD, ROBERTSON_OLD_METHOD } opt_method = ROBERTSON_METHOD;
54
 	
55
   /* defaults */
56
-  float         input_multiplier              = 1.0f;
57
+  float         input_multiplier              = -1.0f;
58
   FILE         *responseFile                  = NULL;
59
   FILE         *responseSaveFile              = NULL;
60
   int           opt_bpp                       = 8;
61
   bool          opt_fillgaps                  = false;   /* todo remove */
62
   bool          opt_luminance                 = false;
63
   float         opt_gauss                     = 0.2; 
64
-  int           opt_maxresponse               = -1;
65
-  int           opt_minresponse               = -1;
66
+  float         opt_maxresponse               = -1.0f;
67
+  float         opt_minresponse               = -1.0f;
68
   unsigned long mitsunaga_sample_no           = MITSUNAGA_SAMPLES_NO;
69
   bool		opt_deghosting = false;
70
   
71
@@ -128,10 +135,12 @@ void pfshdrcalibrate( int argc, char* ar
72
     { "verbose", no_argument, NULL, 'v' },
73
     { "luminance", no_argument, NULL, 'Y' },
74
     { "method", required_argument, NULL, 'c' },
75
+    { "no-calibrate", no_argument, NULL, 'C' },
76
     { "gauss", required_argument, NULL, 'g' },
77
     { "max-response", required_argument, NULL, 'A' },
78
     { "min-response", required_argument, NULL, 'S' },
79
     { "response", required_argument, NULL, 'r' },
80
+    { "weights", required_argument, NULL, 'w' },
81
     { "response-file", required_argument, NULL, 'f' },
82
     { "save-response", required_argument, NULL, 's' },
83
     { "multiplier", required_argument, NULL, 'm' },
84
@@ -144,7 +153,7 @@ void pfshdrcalibrate( int argc, char* ar
85
   int optionIndex = 0;
86
   while( ( c =  getopt_long( argc, 
87
 			     argv, 
88
-			     "hvYc:g:r:f:s:m:b:p:xd", 
89
+			     "hvYc:g:r:f:s:m:b:p:xdA:S:w:C", 
90
 			     cmdLineOptions, 
91
 			     &optionIndex) ) 
92
 	 != -1 ) 
93
@@ -172,27 +181,22 @@ void pfshdrcalibrate( int argc, char* ar
94
 	  opt_fillgaps = true;
95
 	  break;
96
 		
97
+	  /* disable calibration, apply or save responce only */
98
+	case 'C':
99
+	  opt_calibration = NONE;
100
+	  break;
101
+		
102
 	  /* calibration method */
103
 	case 'c':
104
-	  if( strcmp( optarg, "mitsunaga" ) == 0 ) 
105
-	    {
106
-	      opt_calibration = CALIBRATE;
107
-	      opt_method = MITSUNAGA_METHOD;
108
-	    }
109
-	  else 
110
-	    if( strcmp( optarg, "robertson" ) == 0 ) 
111
-	      {
112
-		opt_calibration = CALIBRATE;	
113
-		opt_method = ROBERTSON_METHOD;
114
-	      }
115
-	    else 
116
-	      if( strcmp( optarg, "none" ) == 0 ) 
117
-		{
118
-		  opt_calibration = NONE;	
119
-		  opt_method = ROBERTSON_METHOD;
120
-		}
121
-	      else
122
-		throw pfs::Exception("unsupported automatic self-calibration method");        
123
+	  if( strcmp( optarg, "mitsunaga" ) == 0 ) {
124
+	    opt_method = MITSUNAGA_METHOD;
125
+	  } else if( strcmp( optarg, "robertson" ) == 0 ) {
126
+	    opt_method = ROBERTSON_METHOD;
127
+	  } else if( strcmp( optarg, "robertson-old" ) == 0 ) {
128
+	    opt_method = ROBERTSON_OLD_METHOD;
129
+	  } else {
130
+	    throw pfs::Exception("unsupported automatic self-calibration method");        
131
+	  }
132
 	  break;
133
 		
134
 	  /* support of Gaussian weighting curve */
135
@@ -206,22 +210,32 @@ void pfshdrcalibrate( int argc, char* ar
136
 	  /* predefined response curve */
137
 	case 'r':
138
 	  if( strcmp( optarg, "linear" ) == 0 ) {            
139
-	    opt_response = LINEAR;
140
+	    opt_response = LINEAR_RESP;
141
 	  } else if( strcmp( optarg, "gamma" ) == 0 ) {
142
-            opt_response = GAMMA;
143
+            opt_response = GAMMA_RESP;
144
           } else if( strcmp( optarg, "log" ) == 0 ) {
145
-            opt_response = LOG10;
146
+            opt_response = LOG10_RESP;
147
           } else {      
148
-		throw pfs::Exception("unknown standard response (check the manpage or use default)");
149
+	    throw pfs::Exception("unknown standard response (check the manpage or use default)");
150
+          }
151
+	  break;
152
+
153
+	  /* predefined weighting function */
154
+	case 'w':
155
+	  if( strcmp( optarg, "gauss" ) == 0 ) {
156
+	    opt_weight = GAUSS_WEIGHT;
157
+	  } else if( strcmp( optarg, "composite" ) == 0 ) {
158
+	    opt_weight = COMPOSITE_WEIGHT;
159
+          } else {
160
+	    throw pfs::Exception("unknown standard weight (check the manpage or use default)");
161
           }
162
-          opt_calibration = NONE;
163
 	  break;
164
 
165
 	  
166
 	  /* response curve from file */
167
 	case 'f':
168
-	  opt_response    = FROM_FILE;
169
-	  opt_calibration = NONE;
170
+	  opt_response    = FROM_FILE_RESP;
171
+	  opt_weight      = FROM_FILE_WEIGHT;
172
 	  responseFile    = fopen(optarg, "r");
173
 	  if( !responseFile )
174
 	    throw pfs::Exception("could not open file with response curve");
175
@@ -257,15 +271,15 @@ void pfshdrcalibrate( int argc, char* ar
176
 
177
 
178
 	case 'A':                   // max response
179
-	  opt_maxresponse = atoi(optarg);
180
-	  if( opt_maxresponse<=opt_minresponse )
181
-	    throw pfs::Exception("max response should be higher than min response");
182
+	  opt_maxresponse = atof(optarg);
183
+	  if( opt_maxresponse<0.0f || opt_maxresponse>1.0f )
184
+	    throw pfs::Exception("max response is out of range: 0..1");
185
 	  break;
186
 
187
 	case 'S':                   // min response
188
-	  opt_minresponse = atoi(optarg);
189
-	  if( opt_minresponse<0 )
190
-	    throw pfs::Exception("min response should be >0");
191
+	  opt_minresponse = atof(optarg);
192
+	  if( opt_minresponse<0.0f || opt_minresponse>1.0f )
193
+	    throw pfs::Exception("min response is out of range: 0..1");
194
 	  break;
195
 	  
196
 	case 'd':
197
@@ -293,39 +307,35 @@ void pfshdrcalibrate( int argc, char* ar
198
   //    input_multiplier = 255;
199
   //Ivo end
200
 
201
-  if( opt_method == ROBERTSON_METHOD )
202
-    {
203
-      input_multiplier  = float( 1 << opt_bpp ) - 1;
204
-      opt_gauss        *= input_multiplier;
205
-    }
206
-
207
-  
208
-  if( opt_method == MITSUNAGA_METHOD )
209
+  if( input_multiplier == -1.0f )
210
+  {
211
     input_multiplier = 1.0f;
212
+  }
213
   
214
 
215
   //--- verbose information and load initialization data
216
-  VERBOSE_STR << "Assuming " << opt_bpp << " Bits per pixel in the LDR images (use --bpp to change this)" << endl;
217
+  //VERBOSE_STR << "Assuming " << opt_bpp << " Bits per pixel in the LDR images (use --bpp to change this)" << endl;
218
 
219
-  VERBOSE_STR << "calibrating channels: "
220
+  VERBOSE_STR << (opt_calibration == CALIBRATE ? "calibrating and " : "") 
221
+              << "recovering channels: "
222
               << (opt_luminance ? "LUMINANCE" : "RGB") << endl;
223
 
224
   switch( opt_response )
225
     {
226
       
227
-    case FROM_FILE:
228
+    case FROM_FILE_RESP:
229
       VERBOSE_STR << "response curve from file" << endl;
230
       break;
231
       
232
-    case LINEAR:
233
+    case LINEAR_RESP:
234
       VERBOSE_STR << "initial response: linear" << endl;
235
       break;
236
       
237
-    case GAMMA:
238
+    case GAMMA_RESP:
239
       VERBOSE_STR << "initial response: gamma" << endl;
240
       break;
241
 
242
-    case LOG10:
243
+    case LOG10_RESP:
244
       VERBOSE_STR << "initial response: logarithmic" << endl;
245
       break;
246
       
247
@@ -344,8 +354,8 @@ void pfshdrcalibrate( int argc, char* ar
248
 
249
 
250
   // number of input levels
251
-  int M = (int) powf( 2.0f, opt_bpp );
252
-  VERBOSE_STR << "number of input levels: " << M << endl;
253
+  int M = 1 << opt_bpp;
254
+  VERBOSE_STR << "input levels from bpp: " << M << " (" << opt_bpp << "bpp)" << endl;
255
   VERBOSE_STR << "input multiplier: " << input_multiplier << endl;
256
   
257
 
258
@@ -363,7 +373,7 @@ void pfshdrcalibrate( int argc, char* ar
259
   int height   = 0;
260
   int size     = 0;
261
 
262
-  float minResponse = M;
263
+  float minResponse = 1.0f;
264
   float maxResponse = 0.0f;
265
 
266
   // collected exposures
267
@@ -451,15 +461,15 @@ void pfshdrcalibrate( int argc, char* ar
268
       
269
 	  for( int i=0 ; i < size ; i++ )
270
 	    {
271
-	      (*eY.yi)( i ) = (*Y)( i ) * input_multiplier;
272
-
273
-	      float val = (*eY.yi)( i );
274
-
275
-	      if( val>0.0f )          // discard zero values
276
+	      float val = (*Y)( i ) * input_multiplier;
277
+	      if (val < std::numeric_limits<float>::epsilon())
278
+	        val = std::numeric_limits<float>::epsilon();
279
+	      else // discard zero values
280
 		{
281
 		  maxResponse = (maxResponse > val) ? maxResponse : val;
282
 		  minResponse = (minResponse < val) ? minResponse : val;
283
 		}
284
+	      (*eY.yi)( i ) = val;
285
 	    }
286
 	  
287
 	  imgsY.push_back( eY );
288
@@ -489,21 +499,26 @@ void pfshdrcalibrate( int argc, char* ar
289
 	for( int i = 0 ; i < size ; i++ )
290
 	  {
291
 
292
-	    (*eR.yi)( i ) = (*X)( i ) * input_multiplier;
293
-	    (*eG.yi)( i ) = (*Y)( i ) * input_multiplier;
294
-	    (*eB.yi)( i ) = (*Z)( i ) * input_multiplier;
295
-
296
-	    float maxval = max3( (*eR.yi)( i ),
297
-				 (*eG.yi)( i ),
298
-				 (*eB.yi)( i ) );
299
+	    float r = (*X)( i ) * input_multiplier;
300
+	    if (r < std::numeric_limits<float>::epsilon())
301
+	      r = std::numeric_limits<float>::epsilon();
302
+	    float g = (*Y)( i ) * input_multiplier;
303
+	    if (g < std::numeric_limits<float>::epsilon())
304
+	      g = std::numeric_limits<float>::epsilon();
305
+	    float b = (*Z)( i ) * input_multiplier;
306
+	    if (b < std::numeric_limits<float>::epsilon())
307
+	      b = std::numeric_limits<float>::epsilon();
308
 
309
-	    float minval = min3( (*eR.yi)( i ),
310
-				 (*eG.yi)( i ),
311
-				 (*eB.yi)( i ) );
312
+	    float maxval = max3( r, g, b );
313
+	    float minval = min3( r, g, b );
314
 
315
 	    maxResponse  = (maxResponse > maxval) ? maxResponse : maxval;
316
 	    minResponse  = (minResponse < minval) ? minResponse : minval;
317
 
318
+	    (*eR.yi)( i ) = r;
319
+	    (*eG.yi)( i ) = g;
320
+	    (*eB.yi)( i ) = b;
321
+
322
 	  }
323
 
324
 	// add to exposures list
325
@@ -523,21 +538,27 @@ void pfshdrcalibrate( int argc, char* ar
326
     
327
 
328
   // some more info on input frames
329
-  VERBOSE_STR << "registered values: min=" << (int) minResponse
330
-              << " max=" << (int) maxResponse << endl;
331
+  VERBOSE_STR << "registered camera response range: min=" << minResponse
332
+              << "; max=" << maxResponse << endl;
333
+  
334
+  if( minResponse < 0.0f )
335
+    throw pfs::Exception( "input min value < 0 (wrong input?)" );
336
+  if( maxResponse > 1.0f )
337
+    throw pfs::Exception( "input max value > 1 (use input multiplier to adjust range)" );
338
 
339
   if( opt_minresponse == -1 )
340
-    opt_minresponse = (int) minResponse;
341
-
342
+    opt_minresponse = minResponse;
343
   if( opt_maxresponse == -1 )
344
-    opt_maxresponse = (int) maxResponse;
345
+    opt_maxresponse = maxResponse;
346
+  if (opt_maxresponse<=opt_minresponse)
347
+    throw pfs::Exception("max response should be higher than min response");
348
 
349
-  if( opt_response != FROM_FILE )
350
-    VERBOSE_STR << "camera response range: min=" << opt_minresponse
351
-                << " max=" << opt_maxresponse << endl;
352
-  
353
-  if( maxResponse >= M )
354
-    throw pfs::Exception( "input value higher than defined number of input levels (adjust the number of bits per pixel)" );
355
+  if( opt_response != FROM_FILE_RESP )
356
+    VERBOSE_STR << "using camera response range: min=" << opt_minresponse
357
+                << "; max=" << opt_maxresponse << endl;
358
+
359
+  int Mmin( (int) (M * (opt_minresponse + std::numeric_limits<float>::epsilon())) );
360
+  int Mmax( (int) (M * (opt_maxresponse - std::numeric_limits<float>::epsilon())) );
361
 
362
   /* ------------------------------------------------------------------------------------------------ */
363
   /* ---------------------------- preparation of images done ---------------------------------------- */
364
@@ -548,24 +569,35 @@ void pfshdrcalibrate( int argc, char* ar
365
   /* ------------------------------------------------------------------------------------------------ */
366
 
367
   // weighting function representing confidence in accuracy of acquisition
368
-  float* w = new float [ M ];
369
+  int Mw(M);
370
+  float* w = new float [ Mw ];
371
 
372
   if( w == NULL )
373
     throw pfs::Exception( "could not allocate memory for weighting function" );
374
 
375
   /* 1.4: currently, weights are always Gaussian */
376
   /* Composite function works better for extreme cases */
377
-  weightsComposite ( w, M, opt_minresponse, opt_maxresponse, opt_gauss );
378
-  
379
-//   weightsGauss( w, M, opt_minresponse, opt_maxresponse, opt_gauss );
380
+  switch (opt_weight)
381
+  {
382
+  case GAUSS_WEIGHT:
383
+    weightsGauss( w, Mw, Mmin, Mmax, opt_gauss );
384
+    break;
385
+  default: //case COMPOSITE_WEIGHT:
386
+    weightsComposite ( w, Mw, Mmin, Mmax, opt_gauss );
387
+    break;
388
+  }
389
 
390
   // camera response functions for each channel
391
-  float* Iy = new float [ M ];
392
-  float* Ir = new float [ M ];
393
-  float* Ig = new float [ M ];
394
-  float* Ib = new float [ M ];
395
+  int Mr(M);
396
+  float* Ir = new float [ Mr ];
397
+  int Mg(M);
398
+  float* Ig = new float [ Mg ];
399
+  int Mb(M);
400
+  float* Ib = new float [ Mb ];
401
+  int &My(Mg);
402
+  float* &Iy(Ig);
403
   
404
-  if( Iy == NULL || Ib == NULL || Ig == NULL || Ib == NULL )
405
+  if( Ib == NULL || Ig == NULL || Ib == NULL )
406
     throw pfs::Exception( "could not allocate memory for camera responses" );
407
 
408
   // initial responses
409
@@ -573,65 +605,79 @@ void pfshdrcalibrate( int argc, char* ar
410
     {
411
       
412
       /* ------ Response function from file ------ */
413
-    case FROM_FILE:
414
+    case FROM_FILE_RESP:
415
 
416
       if( opt_luminance )
417
-	{
418
+      {
419
 
420
-	  bool loadY_ok = responseLoad ( responseFile, Iy, M );
421
-	  bool loadW_ok = weightsLoad  ( responseFile,  w, M );
422
-	  fclose( responseFile );
423
-	  
424
-	  if( !loadY_ok || !loadW_ok )
425
-	    throw pfs::Exception( "could not load response curve from file" );
426
+	bool load_ok = responseLoad( responseFile, &Iy, &My );
427
+        if (load_ok && opt_weight == FROM_FILE_WEIGHT)
428
+	  load_ok = weightsLoad( responseFile,  &w, &Mw );
429
+	fclose( responseFile );
430
 
431
-	}
432
+	if( !load_ok )
433
+	  throw pfs::Exception( "could not load response curve from file" );
434
 
435
-    else
436
+        if (M != My)
437
+          VERBOSE_STR << "input levels from response: " << My << ", was " << M << endl;
438
+
439
+      }
440
+      else
441
       {
442
 
443
 	// read camera response from file (and also weights)
444
-	bool loadR_ok = responseLoad ( responseFile, Ir, M );
445
-	bool loadG_ok = responseLoad ( responseFile, Ig, M );
446
-	bool loadB_ok = responseLoad ( responseFile, Ib, M );
447
-	bool loadW_ok = weightsLoad  ( responseFile,  w, M );
448
+	bool load_ok = responseLoad( responseFile, &Ir, &Mr );
449
+        if (load_ok)
450
+	  load_ok = responseLoad( responseFile, &Ig, &Mg );
451
+        if (load_ok)
452
+	  load_ok = responseLoad( responseFile, &Ib, &Mb );
453
+        if (load_ok && opt_weight == FROM_FILE_WEIGHT)
454
+	  load_ok = weightsLoad( responseFile,  &w, &Mw );
455
 	fclose( responseFile );
456
 
457
-	if( !loadR_ok || !loadG_ok || !loadB_ok || !loadW_ok )
458
+	if( !load_ok )
459
 	  throw pfs::Exception( "could not load response curve from file" );
460
+
461
+        if (M != Mr || M != Mg || M != Mb)
462
+          VERBOSE_STR << "input levels from response: (" << Mr << "," << Mg << "," << Mb << "), was " << M << endl;
463
+
464
       }
465
 
466
-      opt_calibration = NONE;	  
467
+      //if (M != Mw)
468
+      //  weightsMinMax(w, Mw, Mmin, Mmax);
469
+
470
       break;
471
 
472
       /* ------ Response function linear ------ */
473
-    case LINEAR:      
474
-      responseLinear( Iy, M );
475
-      responseLinear( Ir, M );
476
-      responseLinear( Ig, M );
477
-      responseLinear( Ib, M );      
478
+    case LINEAR_RESP:      
479
+      //responseLinear( Iy, My );
480
+      responseLinear( Ir, Mr );
481
+      responseLinear( Ig, Mg );
482
+      responseLinear( Ib, Mb );      
483
       break;
484
 
485
       /* ------ Response function gamma ------ */
486
-    case GAMMA:
487
-      responseGamma( Iy, M );
488
-      responseGamma( Ir, M );
489
-      responseGamma( Ig, M );
490
-      responseGamma( Ib, M );
491
+    case GAMMA_RESP:
492
+      //responseGamma( Iy, My );
493
+      responseGamma( Ir, Mr );
494
+      responseGamma( Ig, Mg );
495
+      responseGamma( Ib, Mb );
496
       break;
497
       
498
       /* ------ Response function logarithmic ------ */
499
-    case LOG10:
500
-      responseLog10( Iy, M );
501
-      responseLog10( Ir, M );
502
-      responseLog10( Ig, M );
503
-      responseLog10( Ib, M );
504
+    case LOG10_RESP:
505
+      //responseLog10( Iy, My );
506
+      responseLog10( Ir, Mr );
507
+      responseLog10( Ig, Mg );
508
+      responseLog10( Ib, Mb );
509
       break;
510
 
511
     default:
512
       throw pfs::Exception( "camera response not initialized" );
513
       break;
514
-  }
515
+    }
516
+
517
+  weightsMinMax(w, Mw, Mmin, Mmax);
518
 
519
   
520
   /* ------------------------------------------------------------------------------------------------ */
521
@@ -657,20 +703,20 @@ void pfshdrcalibrate( int argc, char* ar
522
       if( opt_luminance )
523
 	{
524
 
525
-	  int num    = responseFillGaps( Iy, w, M );
526
+	  int num    = responseFillGaps( Iy, My, w, My );
527
 
528
-	  float perc = 100.0f * num / M;
529
+	  float perc = 100.0f * num / My;
530
 
531
 	  VERBOSE_STR << "interpolated " << perc << "% of the Y response curve..." << endl;
532
 	}
533
       else
534
 	{          
535
           
536
-	  int numr   = responseFillGaps ( Ir, w, M );
537
-	  int numg   = responseFillGaps ( Ig, w, M );
538
-	  int numb   = responseFillGaps ( Ib, w, M );
539
+	  int numr   = responseFillGaps ( Ir, Mr, w, Mr );
540
+	  int numg   = responseFillGaps ( Ig, Mg, w, Mg );
541
+	  int numb   = responseFillGaps ( Ib, Mb, w, Mb );
542
 
543
-	  float perc = 100.0f * ( numr + numb + numg) / ( 3 * M );
544
+	  float perc = 100.0f * ( numr + numb + numg) / ( Mr + Mg + Mb );
545
 
546
 	  VERBOSE_STR << "interpolated " << perc << "% of the RGB response curve..." << endl;
547
 	}
548
@@ -707,25 +753,34 @@ void pfshdrcalibrate( int argc, char* ar
549
 	  
550
 	  /* --------------------- Robertson Calibration --------------------- */
551
 	case ROBERTSON_METHOD:
552
+	case ROBERTSON_OLD_METHOD:
553
 
554
-	  VERBOSE_STR << "automatic self-calibration method: robertson" << endl;
555
+	  VERBOSE_STR << "automatic self-calibration method: robertson" << (opt_method == ROBERTSON_OLD_METHOD ? " (old)" : "") << endl;
556
 	  
557
 	  if( opt_luminance )
558
 	    {
559
 	      VERBOSE_STR << "recovering Y channel..." << endl;
560
-	      sp = robertson02_getResponse( Yj, imgsY, Iy, w, M);
561
+	      sp = opt_method == ROBERTSON_OLD_METHOD 
562
+                   ? robertson02old_getResponse( Yj, imgsY, Iy, My, w, Mw) 
563
+                   :    robertson02_getResponse( Yj, imgsY, Iy, My, w, Mw);
564
 	    }
565
 	  else
566
 	    {
567
               
568
 	      VERBOSE_STR << "recovering R channel..." << endl;
569
-	      sp = robertson02_getResponse( Xj, imgsR, Ir, w, M);
570
+	      sp  = opt_method == ROBERTSON_OLD_METHOD 
571
+                    ? robertson02old_getResponse( Xj, imgsR, Ir, Mr, w, Mw) 
572
+                    :    robertson02_getResponse( Xj, imgsR, Ir, Mr, w, Mw);
573
 	      
574
 	      VERBOSE_STR << "recovering G channel..." << endl;
575
-	      sp += robertson02_getResponse( Yj, imgsG, Ig, w, M);
576
+	      sp += opt_method == ROBERTSON_OLD_METHOD 
577
+                    ? robertson02old_getResponse( Yj, imgsG, Ig, Mg, w, Mw) 
578
+                    :    robertson02_getResponse( Yj, imgsG, Ig, Mg, w, Mw);
579
 	      
580
 	      VERBOSE_STR << "recovering B channel..." << endl;
581
-	      sp += robertson02_getResponse( Zj, imgsB, Ib, w, M);
582
+	      sp += opt_method == ROBERTSON_OLD_METHOD 
583
+                    ? robertson02old_getResponse( Zj, imgsB, Ib, Mb, w, Mw) 
584
+                    :    robertson02_getResponse( Zj, imgsB, Ib, Mb, w, Mw);
585
 	      
586
 	      sp /= 3;
587
 	    }
588
@@ -742,12 +797,14 @@ void pfshdrcalibrate( int argc, char* ar
589
 	  else 
590
 	    {
591
 					
592
+	      if (Mw!=Mr || Mw!=Mg || Mw!=Mb)
593
+	        throw pfs::Exception( "number of levels in functions (responce and weighting) must be the same for Mitsunaga & Nayar method");
594
 	      VERBOSE_STR << "Mitsunaga & Nayar ( " << mitsunaga_sample_no << " samples)" << endl;
595
 	  
596
 	      HDRCaptureMitsunaga* mits_calibration = new HDRCaptureMitsunaga();		
597
 				
598
 	      mits_calibration -> capture ( imgsR, imgsG, imgsB, 
599
-					    M, 3,
600
+					    Mw, 3,
601
 					    Xj, Yj, Zj, 
602
 					    mitsunaga_sample_no, 
603
 					    Ir, Ig, Ib, 
604
@@ -783,36 +840,37 @@ void pfshdrcalibrate( int argc, char* ar
605
 	  
606
 	  /* --------------------- Robertson Apply Curve --------------------- */	  
607
 	case ROBERTSON_METHOD:
608
+	case ROBERTSON_OLD_METHOD:
609
 	  
610
 	  if( opt_luminance )
611
 	    {
612
 
613
 	      VERBOSE_STR << "applying response to Y channel..." << endl;
614
-	      sp = robertson02_applyResponse( Yj, imgsY, Iy, w, M);
615
+	      sp = opt_method == ROBERTSON_OLD_METHOD 
616
+                   ? robertson02old_applyResponse( Yj, imgsY, Iy, My, w, Mw) 
617
+                   :    robertson02_applyResponse( Yj, imgsY, Iy, My, w, Mw);
618
 
619
 	    }
620
 	  else
621
 	    {
622
 
623
-              pfs::Array2D *RGB_out[3] = { Xj, Yj, Zj };
624
-              const ExposureList *exposures[] = { &imgsR, &imgsG, &imgsB };
625
-              const float *resp_curves[] = { Ir, Ig, Ib };
626
+              if (opt_method == ROBERTSON_METHOD) {
627
+                pfs::Array2D *RGB_out[3] = { Xj, Yj, Zj };
628
+                const ExposureList *exposures[] = { &imgsR, &imgsG, &imgsB };
629
+                const float *resp_curves[] = { Ir, Ig, Ib };
630
+                const int resp_curve_sizes[] = { Mr, Mg, Mb };
631
               
632
-              VERBOSE_STR << "applying response to RGB channels..." << endl;
633
-	      sp = robertson02_applyResponseRGB( RGB_out, exposures, resp_curves, w, M, opt_deghosting );
634
-
635
-/*                                            
636
-              VERBOSE_STR << "applying response to R channel..." << endl;
637
-	      sp = robertson02_applyResponse( Xj, imgsR, Ir, w, M);
638
-
639
-	      VERBOSE_STR << "applying response to G channel..." << endl;
640
-	      sp += robertson02_applyResponse( Yj, imgsG, Ig, w, M);
641
-
642
-	      VERBOSE_STR << "applying response to B channel..." << endl;
643
-	      sp += robertson02_applyResponse( Zj, imgsB, Ib, w, M);
644
-                                            
645
-                                            
646
-	      sp /= 3;*/
647
+                VERBOSE_STR << "applying response to RGB channels..." << endl;
648
+	        sp = robertson02_applyResponseRGB( RGB_out, exposures, resp_curves, resp_curve_sizes, w, Mw, opt_deghosting );
649
+              } else {
650
+                VERBOSE_STR << "applying response to R channel..." << endl;
651
+	        sp =  robertson02old_applyResponse( Xj, imgsR, Ir, Mr, w, Mw);
652
+	        VERBOSE_STR << "applying response to G channel..." << endl;
653
+	        sp += robertson02old_applyResponse( Yj, imgsG, Ig, Mg, w, Mw);
654
+	        VERBOSE_STR << "applying response to B channel..." << endl;
655
+	        sp += robertson02old_applyResponse( Zj, imgsB, Ib, Mb, w, Mw);
656
+	        sp /= 3;
657
+              }
658
 
659
 	      if( sp > 0 )
660
 		{
661
@@ -830,17 +888,19 @@ void pfshdrcalibrate( int argc, char* ar
662
 	    throw pfs::Exception( "recovering Y channel not implemented, use robertson calibration." );
663
 	  else
664
 	    {
665
+	      if (Mw!=Mr || Mw!=Mg || Mw!=Mb)
666
+	        throw pfs::Exception( "number of levels in functions (responce and weighting) must be the same for Mitsunaga & Nayar method");
667
 	      HDRCaptureMitsunaga* mits_calibration = new HDRCaptureMitsunaga();		
668
 	      
669
 	      mits_calibration -> capture ( imgsR, imgsG, imgsB, 
670
-					    M, 3,
671
+					    Mw, 3,
672
 					    Xj, Yj, Zj, 
673
 					    mitsunaga_sample_no, 
674
 					    Ir, Ig, Ib, 
675
 					    w, 0 );
676
 
677
 	      
678
-	      // normalization
679
+	      /*// normalization
680
 	      VERBOSE_STR << "Normalization" << endl;
681
 
682
 	      float mmax = -1e30;
683
@@ -859,7 +919,7 @@ void pfshdrcalibrate( int argc, char* ar
684
 		  (*Xj)( j ) /=  mmax;
685
 		  (*Yj)( j ) /=  mmax;
686
 		  (*Zj)( j ) /=  mmax;								
687
-		}
688
+		}*/
689
 
690
 	    }
691
 	  break;
692
@@ -883,16 +943,16 @@ void pfshdrcalibrate( int argc, char* ar
693
   {
694
     if( opt_luminance )
695
       {
696
-	responseSave( responseSaveFile, Iy, M, "IY" );
697
-	weightsSave ( responseSaveFile,  w, M, "W" );
698
+	responseSave( responseSaveFile, Iy, My, M, "IY" );
699
+	weightsSave ( responseSaveFile,  w, Mw, M, "W" );
700
 	fclose( responseSaveFile );
701
       }
702
     else
703
       {
704
-	responseSave( responseSaveFile, Ir, M, "IR" );
705
-	responseSave( responseSaveFile, Ig, M, "IG" );
706
-	responseSave( responseSaveFile, Ib, M, "IB" );
707
-	weightsSave ( responseSaveFile,  w, M, "W");
708
+	responseSave( responseSaveFile, Ir, Mr, M, "IR" );
709
+	responseSave( responseSaveFile, Ig, Mg, M, "IG" );
710
+	responseSave( responseSaveFile, Ib, Mb, M, "IB" );
711
+	weightsSave ( responseSaveFile,  w, Mw, M, "W");
712
 	fclose( responseSaveFile );
713
     }
714
   }
715
@@ -919,7 +979,7 @@ void pfshdrcalibrate( int argc, char* ar
716
   // clean up memory
717
   pfsio.freeFrame( frame );
718
   delete[] w;
719
-  delete[] Iy;
720
+  //delete[] Iy;
721
   delete[] Ir;
722
   delete[] Ig;
723
   delete[] Ib;
724
@@ -944,16 +1004,27 @@ int main( int argc, char* argv[] )
725
       pfshdrcalibrate( argc, argv );
726
     }
727
 
728
-  catch( pfs::Exception ex ) 
729
+  catch( std::exception const &ex ) 
730
+    {
731
+      fprintf( stderr, PROG_NAME " error: %s\n", ex.what() );
732
+      return EXIT_FAILURE;
733
+    }     
734
+
735
+  catch( pfs::Exception const &ex ) 
736
     {
737
       fprintf( stderr, PROG_NAME " error: %s\n", ex.getMessage() );
738
       return EXIT_FAILURE;
739
     }     
740
-   
741
-  catch( QuietException  ex ) 
742
+
743
+  catch( QuietException const &ex ) 
744
     {
745
       return EXIT_FAILURE;
746
     }   
747
-     
748
+
749
+  catch( ... ) 
750
+    {
751
+      return EXIT_FAILURE;
752
+    }   
753
+
754
   return EXIT_SUCCESS;
755
 }
(-)graphics/pfstools/files/patch-src_camera_responses.cpp (+378 lines)
Line 0 Link Here
1
--- src/camera/responses.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/camera/responses.cpp
3
@@ -27,10 +27,10 @@
4
  * $Id: responses.cpp,v 1.11 2011/02/25 13:45:14 ihrke Exp $
5
  */
6
 
7
-#ifdef HAVE_CONFIG_H
8
 #include <config.h>
9
-#endif
10
 
11
+#include <algorithm>
12
+#include <cmath>
13
 #include <iostream>
14
 #include <vector>
15
 
16
@@ -38,11 +38,17 @@
17
 #include <stdlib.h>
18
 #include <math.h>
19
 
20
+#include <pfs.h>
21
+
22
 #include <responses.h>
23
 
24
 #define MIN_WEIGHT 1e-3
25
 //#define MIN_WEIGHT 0.0f
26
 
27
+#define PROG_NAME "responses"
28
+
29
+extern bool verbose; /* verbose should be declared for each standalone code */
30
+
31
 void dump_gnuplot( const char* filename, const float* array, int M )
32
 {
33
   FILE* fp = fopen(filename, "w");
34
@@ -60,43 +66,47 @@ void dump_gnuplot( const char* filename,
35
   dump_gnuplot(fn, array, M);
36
 }
37
 
38
+static float const minWeight(1e-3f);
39
 
40
-void weightsGauss( float* w, int M, int Mmin, int Mmax, float sigma )
41
+void weightsGauss(float *w, int M, int Mmin, int Mmax, float sigma)
42
 {
43
-  float mid = Mmin + ( Mmax - Mmin ) / 2.0f;
44
-
45
-  std::cerr << "Mmin: " << Mmin << "mid: " << mid << "Mmax: " << Mmax << "M: " << M << std::endl;
46
-
47
-  for( int m=0 ; m<M ; m++ )
48
+  float step(-(Mmax-Mmin)/2.0f);
49
+  float const k(-sigma*40.0f/(step*step));
50
+  float const mid(Mmin-step);
51
+  VERBOSE_STR
52
+    << "gauss: Mmin: " << Mmin 
53
+    << "; Mmax: " << Mmax 
54
+    << "; M: " << M 
55
+    << "; mid: " << mid 
56
+    << "; sigma: " << sigma 
57
+    << "; k: " << k 
58
+    << std::endl;
59
+  std::fill(w, w+Mmin, 0.0f);
60
+  std::fill(w+Mmax+1, w+M, 0.0f);
61
+  for (int m = Mmin; m <= Mmax; ++m, ++step)
62
+  {
63
+    w[m] = std::exp(k*step*step);
64
+    if (w[m] < minWeight)
65
     {
66
-      // non-normalized Gaussian seems to have been used before (max=1 instead of int_-pi^pi = 1 )
67
-
68
-#define SIGMA_CUT 2.0
69
-
70
-      float weight =  exp( - (m - mid) * (m - mid) / ( 2 * sigma * sigma ) );
71
-      //float weight = 1.0f / (sigma * sqrt ( 2.0 * M_PI )) * exp( - (m-mid)*(m-mid) / (2*sigma*sigma) );
72
-
73
-      /* robust Gaussian fixes saturation clipping problem */
74
-      if ( fabs( m - mid ) < SIGMA_CUT * sigma )
75
-	w[ m ] = weight;
76
-      else
77
-	{
78
-	   w[m] = exp( - ( SIGMA_CUT * sigma )*( SIGMA_CUT * sigma ) / (2*sigma*sigma) ); 
79
-	  /* more efficient version below */
80
-	  //	  w [ m ] = exp ( - SIGMA_CUT * SIGMA_CUT / 2.0f );
81
-	}
82
+      w[m] = 0.0f;
83
     }
84
-
85
+    //std::cerr << "m: " << m << "; step: " << step << "; w[m]: " << w[m] << std::endl;
86
+  }
87
 }
88
 
89
-
90
 void weightsComposite( float* w, int M, int Mmin, int Mmax, float sigma )
91
 {
92
   float mid = Mmin + ( Mmax - Mmin ) / 2.0f;
93
   float relative_dark_pos = 0.0;
94
 
95
 
96
-  std::cerr << "Mmin: " << Mmin << "mid: " << mid << "Mmax: " << Mmax << "M: " << M << std::endl;
97
+  VERBOSE_STR
98
+    << "composite: Mmin: " << Mmin 
99
+    << "; Mmax: " << Mmax 
100
+    << "; M: " << M 
101
+    << "; mid: " << mid 
102
+    << "; sigma: " << sigma 
103
+    << std::endl;
104
 
105
 
106
   for( int m=0 ; m<M ; m++ )
107
@@ -113,7 +123,7 @@ void weightsComposite( float* w, int M, 
108
       //float weight = 1.0f / (sigma * sqrt ( 2.0 * M_PI )) * exp( - (m-mid)*(m-mid) / (2*sigma*sigma) );
109
 
110
       /* robust Gaussian fixes saturation clipping problem */
111
-      if ( fabs( m - mid ) < SIGMA_CUT * sigma )
112
+      if ( fabs( m - mid ) < SIGMA_CUT_WC * sigma )
113
 	{
114
 	  w [ m ] = weight;	  
115
 	}
116
@@ -162,18 +172,22 @@ void weightsComposite( float* w, int M, 
117
 
118
 void responseLinear( float* I, int M )
119
 {
120
-  for( int m=0 ; m<M ; m++ )
121
-    I[m] = m / 255.0f; // range is not important, values are normalized later
122
+  float const scale(2.0f/(M-1));
123
+  for( int m=0 ; m<M ; ++m )
124
+    I[m] = scale * m;
125
 }
126
 
127
 
128
 void responseGamma( float* I, int M )
129
 {
130
-  float norm = M / 4.0f;
131
+  //float norm = M / 4.0f;
132
+  float const norm(2.0f/(M-1));
133
+  static float const scale(1.0f / std::pow(0.5f, 2.2f));
134
   
135
   // response curve decided empirically
136
-  for( int m=0 ; m<M ; m++ )
137
-    I[m] = powf( m/norm, 1.7f ) + 1e-4;
138
+  for( int m=0 ; m<M ; ++m )
139
+    //I[m] = powf( m/norm, 1.7f ) + 1e-4;
140
+    I[m] = scale * std::pow(m*norm, 2.2f);
141
 }
142
 
143
 
144
@@ -187,46 +201,49 @@ void responseLog10( float* I, int M )
145
 }
146
 
147
 
148
-void responseSave( FILE* file, const float* I, int M, const char* name)
149
+void responseSave(FILE *file, float const *I, int Mr, int M, char const *name)
150
 {
151
   // response curve matrix header
152
   fprintf(file, "# Camera response curve, channel %s\n", name);
153
   fprintf(file, "# data layout: log10(response) | camera output | response\n");
154
   fprintf(file, "# name: %s\n", name);
155
   fprintf(file, "# type: matrix\n");
156
-  fprintf(file, "# rows: %d\n", M);
157
+  fprintf(file, "# rows: %d\n", Mr);
158
   fprintf(file, "# columns: 3\n");
159
 
160
+  //float const factor(((float)Mr)/M);
161
   // save response
162
-  for( int m=0 ; m<M ; m++ )
163
-    if( I[m] > 0.0f )
164
-      fprintf(file, " %e %4d %e\n", log10f(I[m]), m, I[m]);
165
-    else
166
-      fprintf(file, " %e %4d %e\n", -6.0f, m, I[m]);
167
-  
168
+  for (int m=0; m<Mr; ++m)
169
+  {
170
+    //int const i((int)(factor*m));
171
+    fprintf(file, " %e %4d %e\n", log10f(I[m]>0.0f ? I[m] : -6.0f), m, I[m]);
172
+  }
173
   fprintf(file, "\n");
174
 }
175
 
176
 
177
-void weightsSave( FILE* file, const float* w, int M, const char* name)
178
+void weightsSave(FILE *file, float const *w, int Mw, int M, char const *name)
179
 {
180
   // weighting function matrix header
181
   fprintf(file, "# Weighting function\n");
182
   fprintf(file, "# data layout: weight | camera output\n");
183
   fprintf(file, "# name: %s\n", name);
184
   fprintf(file, "# type: matrix\n");
185
-  fprintf(file, "# rows: %d\n", M);
186
+  fprintf(file, "# rows: %d\n", Mw);
187
   fprintf(file, "# columns: 2\n");
188
   
189
+  //float const factor(((float)Mw)/M);
190
   // save weights
191
-  for( int m=0 ; m<M ; m++ )
192
+  for (int m=0; m<Mw; ++m)
193
+  {
194
+    //int const i((int)(factor*m));
195
     fprintf(file, " %e %4d\n", w[m], m);
196
-  
197
+  }
198
   fprintf(file, "\n");
199
 }
200
 
201
 
202
-bool responseLoad( FILE* file, float* I, int M)
203
+bool responseLoad(FILE *file, float *I[], int *M)
204
 {
205
   char line[1024];
206
   int m=0,c=0;
207
@@ -235,37 +252,41 @@ bool responseLoad( FILE* file, float* I,
208
   while( fgets(line, 1024, file) )
209
     if( sscanf(line, "# rows: %d\n", &m) == 1 )
210
       break;
211
-  if( m!=M )
212
-  {
213
-    std::cerr << "response: number of input levels is different,"
214
-              << " M=" << M << " m=" << m << std::endl; 
215
-    return false;
216
-  }
217
   while( fgets(line, 1024, file) )
218
     if( sscanf(line, "# columns: %d\n", &c) == 1 )
219
       break;
220
-  if( c!=3 )
221
+  if( m==0 || c!=3 )
222
     return false;
223
+  if( m!=*M )
224
+  {
225
+    //std::cerr << "response: number of input levels is different,"
226
+    //          << " M=" << *M << " m=" << m << std::endl; 
227
+    //return false;
228
+    delete[] *I;
229
+    *I = new float[ *M = m ];
230
+  }
231
   
232
   // read response
233
   float ignore;
234
-  for( int i=0 ; i<M ; i++ )
235
+  for( int i=0 ; i<*M ; ++i )
236
   {
237
     float val;
238
     if( fscanf(file, " %f %d %f\n", &ignore, &m, &val) !=3 )
239
       return false;
240
-    if( m<0 || m>M )
241
+    if( m<0 || m>*M )
242
+    {
243
       std::cerr << "response: camera value out of range,"
244
                 << " m=" << m << std::endl;
245
-    else
246
-      I[m] = val;
247
+      continue;
248
+    }
249
+    (*I)[m] = val;
250
   }
251
   
252
   return true;
253
 }
254
 
255
 
256
-bool weightsLoad( FILE* file, float* w, int M)
257
+bool weightsLoad(FILE *file, float *w[], int *M)
258
 {
259
   char line[1024];
260
   int m=0,c=0;
261
@@ -274,37 +295,49 @@ bool weightsLoad( FILE* file, float* w, 
262
   while( fgets(line, 1024, file) )
263
     if( sscanf(line, "# rows: %d\n", &m) == 1 )
264
       break;
265
-  if( m!=M )
266
-  {
267
-    std::cerr << "response: number of input levels is different,"
268
-              << " M=" << M << " m=" << m << std::endl; 
269
-    return false;
270
-  }
271
   while( fgets(line, 1024, file) )
272
     if( sscanf(line, "# columns: %d\n", &c) == 1 )
273
       break;
274
-  if( c!=2 )
275
+  if( m==0 || c!=2 )
276
     return false;
277
+  if( m!=*M )
278
+  {
279
+    //std::cerr << "weights: number of input levels is different,"
280
+    //          << " M=" << *M << " m=" << m << std::endl; 
281
+    //return false;
282
+    delete[] *w;
283
+    *w = new float[ *M = m ];
284
+  }
285
   
286
-  // read response 
287
-  for( int i=0 ; i<M ; i++ )
288
-    if( fscanf(file, " %f %d\n", &(w[i]), &m) !=2 )
289
+  // read weights 
290
+  for( int i=0 ; i<*M ; i++ )
291
+  {
292
+    float val;
293
+    if( fscanf(file, " %f %d\n", &val, &m) !=2 )
294
       return false;
295
+    if( m<0 || m>*M )
296
+    {
297
+      std::cerr << "weights: camera value out of range,"
298
+                << " m=" << m << std::endl;
299
+      continue;
300
+    }
301
+    (*w)[m] = val;
302
+  }
303
   
304
   return true;
305
 }
306
 
307
-int responseFillGaps( float* I, float* w, int M )
308
+int responseFillGaps(float *I, int Mr, float *w, int Mw )
309
 {
310
   int m1=0;
311
   int m2=0;
312
   int filled_gaps = 0;
313
 
314
-  while( m2<M )
315
+  while( m2<Mr )
316
   {
317
     // 1. find first non-zero
318
     m1 = m2;                    // start from the last non-zero value
319
-    while( m1+1<M )
320
+    while( m1+1<Mr )
321
       if( I[m1+1]==0.0f )
322
         break;
323
       else
324
@@ -312,7 +345,7 @@ int responseFillGaps( float* I, float* w
325
     
326
     // 2. find next non-zero
327
     m2 = m1+1;                  // start from the last zero value
328
-    while( m2<M )
329
+    while( m2<Mr )
330
       if( I[m2]!=0.0f )
331
         break;
332
       else
333
@@ -320,14 +353,16 @@ int responseFillGaps( float* I, float* w
334
     
335
     if( m2-m1>1 )               // there is someting to interpolate
336
     {
337
+      float factor(((float)Mw)/Mr);
338
       float delta= (I[m2]-I[m1]) / (m2-m1);
339
       if( I[m2]<=0.0f )
340
         delta = (I[m1] - I[m1-1])/2.0f; // for some wierd data use gradient
341
       
342
       for( int m=m1+1 ; m<m2 ; m++ )
343
       {
344
-        I[m] = I[m-1]+delta;
345
-        w[m] = MIN_WEIGHT;      // give very low confidence in the interpolated data
346
+        I[m]  = I[m-1]+delta;
347
+        int wm = (int) ( m * factor );
348
+        w[wm] = MIN_WEIGHT;     // give very low confidence in the interpolated data
349
         filled_gaps++;
350
       }
351
     }
352
@@ -335,3 +370,26 @@ int responseFillGaps( float* I, float* w
353
 
354
   return filled_gaps;
355
 }
356
+
357
+void weightsMinMax(float *w, int M, int &Mmin, int &Mmax)
358
+{
359
+  for (Mmin=0; Mmin<M && w[Mmin]<std::numeric_limits<float>::epsilon(); ++Mmin)
360
+  {
361
+    w[Mmin] = 0.0f;
362
+  }
363
+  for (Mmax=M; --Mmax>=0 && w[Mmax]<std::numeric_limits<float>::epsilon(); )
364
+  {
365
+    w[Mmax] = 0.0f;
366
+  }
367
+  if (Mmin >= Mmax)
368
+  {
369
+    throw pfs::Exception("wrong weighting function");
370
+  }
371
+  float const mid(Mmin+(Mmax-Mmin)/2.0f);
372
+  VERBOSE_STR
373
+    << "min/max: Mmin: " << Mmin 
374
+    << "; Mmax: " << Mmax 
375
+    << "; M: " << M 
376
+    << "; mid: " << mid 
377
+    << std::endl;
378
+}
(-)graphics/pfstools/files/patch-src_camera_responses.h (+57 lines)
Line 0 Link Here
1
--- src/camera/responses.h.orig	2018-01-19 06:59:44 UTC
2
+++ src/camera/responses.h
3
@@ -68,7 +68,7 @@ typedef std::vector<Exposure> ExposureLi
4
  * @param Mmax maximum registered camera output level
5
  * @param sigma sigma value for gaussian
6
  */
7
-void weightsGauss( float* w, int M, int Mmin, int Mmax, float sigma );
8
+void weightsGauss(float *w, int M, int Mmin, int Mmax, float sigma);
9
 
10
 /**
11
  * @brief Composite weighting function - dark regions
12
@@ -119,7 +119,7 @@ void responseLog10( float* I, int M );
13
  * @param M number of camera output levels
14
  * @param name matrix name for use in Octave or Matlab
15
  */
16
-void responseSave( FILE* file, const float* I, int M, const char* name);
17
+void responseSave(FILE *file, float const *I, int Mr, int M, char const *name);
18
 
19
 
20
 /**
21
@@ -130,7 +130,7 @@ void responseSave( FILE* file, const flo
22
  * @param M number of camera output levels
23
  * @param name matrix name for use in Octave or Matlab
24
  */
25
-void weightsSave( FILE* file, const float* w, int M, const char* name);
26
+void weightsSave(FILE *file, float const *w, int Mw, int M, char const *name);
27
 
28
 
29
 /**
30
@@ -141,7 +141,7 @@ void weightsSave( FILE* file, const floa
31
  * @param M number of camera output levels
32
  * @return false means file has different output levels or is wrong for some other reason
33
  */
34
-bool responseLoad( FILE* file, float* I, int M);
35
+bool responseLoad(FILE *file, float *I[], int *M);
36
 
37
 
38
 /**
39
@@ -152,7 +152,7 @@ bool responseLoad( FILE* file, float* I,
40
  * @param M number of camera output levels
41
  * @return false means file has different output levels or is wrong for some other reason
42
  */
43
-bool weightsLoad( FILE* file, float* w, int M);
44
+bool weightsLoad(FILE *file, float *w[], int *M);
45
 
46
 
47
 /**
48
@@ -166,6 +166,8 @@ bool weightsLoad( FILE* file, float* w, 
49
  * @param M number of camera output levels
50
  * @return number of filled values in the response curve
51
  */
52
-int responseFillGaps( float* I, float* w, int M );
53
+int responseFillGaps(float *I, int Mr, float *w, int Mw);
54
+
55
+void weightsMinMax(float *w, int M, int &Mmin, int &Mmax);
56
 
57
 #endif
(-)graphics/pfstools/files/patch-src_camera_robertson02.cpp (+341 lines)
Line 0 Link Here
1
--- src/camera/robertson02.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/camera/robertson02.cpp
3
@@ -79,10 +79,17 @@ float get_exposure_compensation( const E
4
 int robertson02_applyResponseRGB( pfs::Array2D *rgb_out[],         
5
   const ExposureList *imgs[], 
6
   const float *resp_curve[], 
7
+  const int    resp_curve_size[], 
8
   const float *weights, 
9
-  int M,
10
+  int          Mw, 
11
   bool deghosting )
12
 {
13
+  float const rfactor[] = { 
14
+    float(resp_curve_size[0]), 
15
+    float(resp_curve_size[1]), 
16
+    float(resp_curve_size[2]) 
17
+  };
18
+  float const wfactor(Mw);
19
   // number of exposures
20
   int N = imgs[0]->size();
21
   
22
@@ -93,16 +100,16 @@ int robertson02_applyResponseRGB( pfs::A
23
   // number of saturated pixels
24
   int saturated_pixels = 0;
25
 
26
-  float pw[M];
27
-  for( int i = 0 ; i < M ; i++ ) {
28
+  float pw[Mw];
29
+  for( int i = 0 ; i < Mw ; ++i ) {
30
     pw[i] = weights[i];
31
   }
32
-  for( int i = 1; i < 10; i++ )
33
-    pw[M-i] = 0;
34
+  for( int i = 1; i < 10; ++i )
35
+    pw[Mw-i] = 0;
36
   
37
   float ew[N]; // Per-exposure weight to account for noise charactetistic
38
   // For each exposure
39
-  for( int i = 0 ; i < N ; i++ ) {
40
+  for( int i = 0 ; i < N ; ++i ) {
41
     const Exposure &ex = (*imgs[0])[i];
42
 
43
     // TODO: Estimate read-out noise and use for exposure weighting
44
@@ -121,7 +128,7 @@ int robertson02_applyResponseRGB( pfs::A
45
   float w[3][N];
46
   bool saturated_exp[N];  
47
 
48
-//  for( int i = 0; i < M; i++ )
49
+//  for( int i = 0; i < Mw; ++i )
50
 //    cerr << "i = " << i << "; weight = " << weights[i] << endl;  
51
   
52
   // For each pixel
53
@@ -145,11 +152,13 @@ int robertson02_applyResponseRGB( pfs::A
54
           const Exposure &ex = (*imgs[cc])[i];          
55
           float ti = get_exposure_compensation( ex );
56
         
57
-          int   m  = (int) (*ex.yi)( j );
58
-          X[i*3+cc] = resp_curve[cc][ m ] / ti;
59
-          w[cc][i] = weights [ m ] * ew[i];
60
+          float v  = (*ex.yi)( j );
61
+          int   rm = (int) ( (v - std::numeric_limits<float>::epsilon()) * rfactor[cc] );
62
+          int   wm = (int) ( (v - std::numeric_limits<float>::epsilon()) * wfactor );
63
+          X[i*3+cc] = resp_curve[cc][ rm ] / ti;
64
+          w[cc][i] = weights [ wm ] * ew[i];
65
 
66
-          saturated_exp[i] |= ( m <= 1 || m >= M-2 );        
67
+          saturated_exp[i] |= ( v <= 1.0f/rfactor[cc]+std::numeric_limits<float>::epsilon() || v >= (1.0f-1.0f/rfactor[cc]-std::numeric_limits<float>::epsilon()) );        
68
         
69
 //        cerr << X[i*3+cc] << ", ";        
70
 
71
@@ -239,35 +248,37 @@ int robertson02_applyResponseRGB( pfs::A
72
           continue;
73
         
74
         const Exposure &ex = (*imgs[cc])[i];          
75
-        int   m  = (int) (*ex.yi)( j );
76
+        float v  = (*ex.yi)( j );
77
+        int   rm = (int) ( (v - std::numeric_limits<float>::epsilon()) * rfactor[cc] );
78
+        int   wm = (int) ( (v - std::numeric_limits<float>::epsilon()) * wfactor );
79
         float ti = get_exposure_compensation( ex );
80
 
81
         // Testing the noise-optimal approach
82
 /*        float iso2 = ex.iso*ex.iso;
83
           float sigma_r2 = 0.00001;
84
-          float w = ex.exposure_time*ex.exposure_time*iso2/(iso2*ex.exposure_time*resp_curve[cc][m] + 2*sigma_r2);        
85
-          sum += w * resp_curve[cc][ m ] / ti;
86
+          float w = ex.exposure_time*ex.exposure_time*iso2/(iso2*ex.exposure_time*resp_curve[cc][rm] + 2*sigma_r2);        
87
+          sum += w * resp_curve[cc][ rm ] / ti;
88
           div += w;*/
89
         
90
-//        float w = weights [ m ] * ew[i];
91
-//        sum += w * resp_curve[cc][ m ] / ti;
92
+//        float w = weights [ wm ] * ew[i];
93
+//        sum += w * resp_curve[cc][ rm ] / ti;
94
 //        div += w;
95
 
96
 //        const float noise_level = 0.01;      
97
-//        float var = (noise_level*noise_level)*resp_curve[cc][ m ]/(ti*ti);
98
+//        float var = (noise_level*noise_level)*resp_curve[cc][ rm ]/(ti*ti);
99
         
100
 //        float w = 1/var;
101
-//        float w = log(sqrt(resp_curve[cc][ m ] / ti / var))+3;
102
-//        float w = log(sqrt(m));
103
-        float w = weights [ m ] * ew[i];
104
+//        float w = log(sqrt(resp_curve[cc][ rm ] / ti / var))+3;
105
+//        float w = log(sqrt(v));
106
+        float w = weights [ wm ] * ew[i];
107
         
108
-        sum += w * resp_curve[cc][ m ] / ti;
109
+        sum += w * resp_curve[cc][ rm ] / ti;
110
         div += w;
111
 
112
-        if( j < 10 && cc == 1 )
113
-          std::cerr << "j = " << j << " ;i = " << i << " ;w = " << w << std::endl;        
114
+        //if( j < 10 && cc == 1 )
115
+        //  std::cerr << "j = " << j << " ;i = " << i << " ;w = " << w << std::endl;        
116
         
117
-        div2 += weights [ m ];        
118
+        div2 += weights [ wm ];        
119
       }
120
 
121
 /*      float mean = sum / div;
122
@@ -278,13 +289,15 @@ int robertson02_applyResponseRGB( pfs::A
123
         for( int i = 0 ; i < N ; i++ )
124
         {
125
         const Exposure &ex = (*imgs[cc])[i];          
126
-        int   m  = (int) (*ex.yi)( j );
127
+        float v  = (*ex.yi)( j );
128
+        int   rm = (int) ( (v - std::numeric_limits<float>::epsilon()) * rfactor[cc] );
129
+        int   wm = (int) ( (v - std::numeric_limits<float>::epsilon()) * wfactor );
130
         float ti = ex.ti;
131
 
132
-        float ww = 1/(fabs(resp_curve[cc][ m ]/ti - mean) + 1e-7);
133
+        float ww = 1/(fabs(resp_curve[cc][ rm ]/ti - mean) + 1e-7);
134
         
135
-        sum += weights [ m ] * ew[i] * resp_curve[cc][ m ] * ww / ti;
136
-        div += weights [ m ] * ew[i] * ww;
137
+        sum += weights [ wm ] * ew[i] * resp_curve[cc][ rm ] * ww / ti;
138
+        div += weights [ wm ] * ew[i] * ww;
139
         }*/
140
       
141
       if( div2 >= 0.0001f )
142
@@ -314,21 +327,21 @@ int robertson02_applyResponseRGB( pfs::A
143
 
144
         const Exposure &ex = (*imgs[cc])[0];
145
         // If pixel value > gray level, use the shortest exposure;        
146
-        float short_long = ( (*ex.yi)(j) > M/2 ) ? 1.f : -1.f;        
147
+        float short_long = ( (*ex.yi)(j) > 0.5f ) ? 1.f : -1.f;        
148
         
149
         float best_ti = 1e10f * short_long;
150
-        int best_v = short_long == 1.f ? M-1 : 0;        
151
+        int best_v = short_long == 1.f ? resp_curve_size[cc]-1 : 0;        
152
         for( int i = 0 ; i < N ; i++ )
153
 	{
154
           if( deghosting && skip_exp[i] )
155
             continue;
156
           
157
           const Exposure &ex = (*imgs[cc])[i];          
158
-	  int   m  = (int) (*ex.yi)( j );
159
+	  //int   m  = (int) (*ex.yi)( j );
160
 	  float ti = get_exposure_compensation( ex );;          
161
           if( ti*short_long < best_ti*short_long ) {            
162
             best_ti = ti;
163
-            best_v = (int)(*ex.yi)(j);
164
+            best_v = (int) ( ((*ex.yi)(j) - std::numeric_limits<float>::epsilon()) * rfactor[cc] );
165
           }          
166
 	}        
167
         (*rgb_out[cc])(j) = 1/best_ti * resp_curve[cc][best_v];
168
@@ -350,9 +363,12 @@ int robertson02_applyResponseRGB( pfs::A
169
 int robertson02_applyResponse( pfs::Array2D *xj,         
170
   const ExposureList &imgs, 
171
   const float *rcurve, 
172
+  int          Mr, 
173
   const float *weights, 
174
-  int M )
175
+  int          Mw )
176
 {
177
+  float const rfactor(Mr);
178
+  float const wfactor(Mw);
179
 
180
   // number of exposures
181
   int N = imgs.size();
182
@@ -364,9 +380,9 @@ int robertson02_applyResponse( pfs::Arra
183
   // number of saturated pixels
184
   int saturated_pixels = 0;
185
 
186
-//  cerr << "M = " << M << endl;
187
+//  cerr << "Mw = " << Mw << endl;
188
 //  cerr << "W[0] = " << weights[0] << endl;
189
-//  cerr << "W[end] = " << weights[M-1] << endl;
190
+//  cerr << "W[end] = " << weights[Mw-1] << endl;
191
   
192
   // all pixels
193
   for( int j = 0; j < width * height; j++ )
194
@@ -377,11 +393,13 @@ int robertson02_applyResponse( pfs::Arra
195
 
196
     for( int i = 0 ; i < N ; i++ )
197
     {
198
-      int   m  = (int) (*imgs[ i ].yi)( j );
199
+      float v  = (*imgs[ i ].yi)( j );
200
+      int   rm = (int) ( (v - std::numeric_limits<float>::epsilon()) * rfactor );
201
+      int   wm = (int) ( (v - std::numeric_limits<float>::epsilon()) * wfactor );
202
       float ti = imgs[ i ].ti;
203
 	   
204
-      sum += weights [ m ] / ti * rcurve [ m ];
205
-      div += weights [ m ];
206
+      sum += weights [ wm ] / ti * rcurve [ rm ];
207
+      div += weights [ wm ];
208
     }
209
 
210
     
211
@@ -398,7 +416,7 @@ int robertson02_applyResponse( pfs::Arra
212
     /*
213
       {
214
       float best_ti = 1e10;
215
-      int best_v = M-1;        
216
+      int best_v = Mr-1;        
217
       for( int i = 0 ; i < N ; i++ )
218
       {
219
       int   m  = (int) (*imgs[ i ].yi)( j );
220
@@ -408,7 +426,7 @@ int robertson02_applyResponse( pfs::Arra
221
       best_v = (int)(*imgs[i].yi)(j);
222
       }          
223
       }        
224
-      (*xj)( j ) = (M-1) / best_ti * rcurve [best_v];        
225
+      (*xj)( j ) = (Mr-1) / best_ti * rcurve [best_v];        
226
         
227
       }*/
228
       
229
@@ -424,9 +442,12 @@ int robertson02_applyResponse( pfs::Arra
230
 int robertson02_getResponse( pfs::Array2D       *xj, 
231
   const ExposureList &imgs,
232
   float              *rcurve, 
233
+  int                 Mr, 
234
   const float        *weights, 
235
-  int M )
236
+  int                 Mw )
237
 {
238
+  float const rfactor(Mr);
239
+  //float const wfactor(Mw);
240
 
241
 // number of exposures
242
   int N = imgs.size();
243
@@ -441,7 +462,7 @@ int robertson02_getResponse( pfs::Array2
244
   // indices
245
   int i, j, m;
246
   
247
-  float* rcurve_prev = new float[ M ];	// previous response
248
+  float* rcurve_prev = new float[ Mr ];	// previous response
249
 
250
   if( rcurve_prev == NULL )
251
   {
252
@@ -451,19 +472,19 @@ int robertson02_getResponse( pfs::Array2
253
 
254
   // 0. Initialization
255
   
256
-  normalize_rcurve( rcurve, M );
257
+  normalize_rcurve( rcurve, Mr );
258
   
259
-  for( m = 0 ; m < M ; m++ ) {
260
+  for( m = 0 ; m < Mr ; ++m ) {
261
     //  cerr << "m = " << m << " rc = " << rcurve [ m ] << endl;    
262
     rcurve_prev [ m ] = rcurve [ m ];
263
   }
264
   
265
-  robertson02_applyResponse( xj, imgs, rcurve, weights, M );
266
+  robertson02_applyResponse( xj, imgs, rcurve, Mr, weights, Mw );
267
 
268
   // Optimization process
269
   bool   converged  = false;
270
-  long  *cardEm     = new long [ M ];
271
-  float *sum        = new float[ M ];
272
+  long  *cardEm     = new long [ Mr ];
273
+  float *sum        = new float[ Mr ];
274
 
275
   if( sum == NULL || 
276
     cardEm == NULL )
277
@@ -479,12 +500,12 @@ int robertson02_getResponse( pfs::Array2
278
   {
279
 
280
     // Display response curve - for debugging purposes
281
-/*    for( m = 0 ; m < M ; m+=32 ) {
282
+/*    for( m = 0 ; m < Mr ; m+=32 ) {
283
       cerr << "m = " << m << " rc = " << rcurve [ m ] << endl;
284
       }*/
285
     
286
     // 1. Minimize with respect to rcurve
287
-    for( m = 0 ; m < M ; m++ )
288
+    for( m = 0 ; m < Mr ; ++m )
289
     {
290
       cardEm [ m ] = 0;
291
       sum[ m ] = 0.0f;
292
@@ -499,9 +520,9 @@ int robertson02_getResponse( pfs::Array2
293
 
294
       for( j = 0 ; j < width * height ; j++ )
295
       {
296
-        m = (int) (*yi)( j );
297
+        m = (int) ( ((*yi)( j ) - std::numeric_limits<float>::epsilon()) * rfactor );
298
 
299
-        if( m < M && m >= 0 )
300
+        if( m < Mr && m >= 0 )
301
         {
302
           sum[ m ] += ti * (*xj)( j );
303
           cardEm[ m ] ++;
304
@@ -512,7 +533,7 @@ int robertson02_getResponse( pfs::Array2
305
     }
306
 
307
 
308
-    for( m = 0; m < M ; m++ )
309
+    for( m = 0; m < Mr ; ++m )
310
     {
311
       if( cardEm[ m ] != 0 )
312
         rcurve [ m ] = sum [ m ] / cardEm [ m ];
313
@@ -521,16 +542,16 @@ int robertson02_getResponse( pfs::Array2
314
     }
315
 
316
     // 2. Normalize rcurve
317
-    float middle_response = normalize_rcurve( rcurve, M );    
318
+    float middle_response = normalize_rcurve( rcurve, Mr );    
319
     
320
     // 3. Apply new response
321
-    saturated_pixels = robertson02_applyResponse( xj, imgs, rcurve, weights, M );
322
+    saturated_pixels = robertson02_applyResponse( xj, imgs, rcurve, Mr, weights, Mw );
323
     
324
     // 4. Check stopping condition
325
     float delta = 0.0f;
326
     int   hits  = 0;
327
 
328
-    for( m = 0 ; m < M ; m++ )
329
+    for( m = 0 ; m < Mr ; ++m )
330
     {
331
       if( rcurve[ m ] != 0.0f )
332
       {
333
@@ -548,7 +569,7 @@ int robertson02_getResponse( pfs::Array2
334
 
335
     VERBOSE_STR << " #" << cur_it
336
                 << " delta=" << delta
337
-                << " (coverage: " << 100*hits/M << "%)\n";
338
+                << " (coverage: " << 100*hits/Mr << "%)\n";
339
     
340
     if( delta < MAX_DELTA )
341
       converged = true;
(-)graphics/pfstools/files/patch-src_camera_robertson02.h (+33 lines)
Line 0 Link Here
1
--- src/camera/robertson02.h.orig	2018-01-19 06:59:44 UTC
2
+++ src/camera/robertson02.h
3
@@ -44,8 +44,9 @@
4
 int robertson02_getResponse( pfs::Array2D*       output,       /* output image (gray scale) */
5
 			     const ExposureList &imgs,         /* differrent exposures */
6
 			     float              *rcurve,       /* response curve */
7
+			     int                 Mr,           /* number of values in rcurve */
8
 			     const float        *weights,      /* weights */
9
-			     int                 M             /* number of values in rcurve/weights */
10
+			     int                 Mw            /* number of values in weights */
11
 			     );
12
 
13
 
14
@@ -63,15 +64,17 @@ int robertson02_getResponse( pfs::Array2
15
 int robertson02_applyResponse( pfs::Array2D* xj, 
16
 			       const ExposureList &imgs, 
17
 			       const float* I, 
18
+			       int Mr, 
19
 			       const float* w, 
20
-			       int M );
21
+			       int Mw );
22
 
23
 
24
 int robertson02_applyResponseRGB( pfs::Array2D *rgb_out[],         
25
   const ExposureList *imgs[], 
26
   const float *resp_curve[], 
27
+  const int    resp_curve_size[], 
28
   const float *weights, 
29
-  int M,
30
+  int          Mw, 
31
   bool deghosting = false );
32
 
33
   
(-)graphics/pfstools/files/patch-src_fileformat_CMakeLists.txt (+37 lines)
Line 0 Link Here
1
--- src/fileformat/CMakeLists.txt.orig	2018-01-25 16:27:28 UTC
2
+++ src/fileformat/CMakeLists.txt
3
@@ -81,18 +81,22 @@ if( OPENEXR_FOUND )
4
  endif( OPENEXR_FOUND )
5
 
6
 if( ImageMagick_FOUND )
7
+    execute_process(COMMAND ${ImageMagick_EXECUTABLE_DIR}/Magick++-config --cflags OUTPUT_VARIABLE ImageMagick_CFLAGS)
8
+
9
     include_directories(${ImageMagick_INCLUDE_DIRS})
10
     add_executable(pfsinimgmagick pfsinimgmagick.cpp "${GETOPT_OBJECT}")
11
     target_link_libraries(pfsinimgmagick pfs ${ImageMagick_LIBRARIES})
12
     install (TARGETS pfsinimgmagick DESTINATION bin)
13
     install (FILES pfsinimgmagick.1 DESTINATION ${MAN_DIR})
14
-    set_target_properties(pfsinimgmagick PROPERTIES COMPILE_FLAGS "-DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16")
15
+    #set_target_properties(pfsinimgmagick PROPERTIES COMPILE_FLAGS "-DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16")
16
+    set_target_properties(pfsinimgmagick PROPERTIES COMPILE_FLAGS "${ImageMagick_CFLAGS}")
17
 
18
     add_executable(pfsoutimgmagick pfsoutimgmagick.cpp "${GETOPT_OBJECT}")
19
     target_link_libraries(pfsoutimgmagick pfs ${ImageMagick_LIBRARIES})
20
     install (TARGETS pfsoutimgmagick DESTINATION bin)
21
     install (FILES pfsoutimgmagick.1 DESTINATION ${MAN_DIR})
22
-    set_target_properties(pfsoutimgmagick PROPERTIES COMPILE_FLAGS "-DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16")
23
+    #set_target_properties(pfsoutimgmagick PROPERTIES COMPILE_FLAGS "-DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16")
24
+    set_target_properties(pfsoutimgmagick PROPERTIES COMPILE_FLAGS "${ImageMagick_CFLAGS}")
25
 
26
 endif( ImageMagick_FOUND )
27
 
28
@@ -128,4 +132,9 @@ if( TIFF_FOUND )
29
 
30
 endif( TIFF_FOUND )
31
 
32
+if(OPENMP_FOUND)
33
+  set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" )
34
+  set( CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}" )
35
+endif(OPENMP_FOUND)
36
+
37
 	
(-)graphics/pfstools/files/patch-src_fileformat_exrio.cpp (+11 lines)
Line 0 Link Here
1
--- src/fileformat/exrio.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/fileformat/exrio.cpp
3
@@ -93,7 +93,7 @@ void OpenEXRReader::readImage( pfs::Arra
4
 OpenEXRReader::~OpenEXRReader()
5
 {
6
   delete file;
7
-  file==NULL;
8
+  file=NULL;
9
 }
10
 
11
 OpenEXRWriter::OpenEXRWriter(const char* filename)
(-)graphics/pfstools/files/patch-src_fileformat_pfsinexr.cpp (+11 lines)
Line 0 Link Here
1
--- src/fileformat/pfsinexr.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/fileformat/pfsinexr.cpp
3
@@ -235,7 +235,7 @@ void readFrames( int argc, char* argv[] 
4
     }
5
     
6
     file.setFrameBuffer( frameBuffer );
7
-    file.readPixels( dw.min.y, dw.max.y );
8
+    file.readPixels( dtw.min.y, dtw.max.y );
9
 
10
     VERBOSE_STR << "reading file (linear) '" << ff.fileName << "'" << std::endl;
11
     
(-)graphics/pfstools/files/patch-src_fileformat_pfsinimgmagick.1 (+60 lines)
Line 0 Link Here
1
--- src/fileformat/pfsinimgmagick.1.orig	2018-01-29 14:36:10 UTC
2
+++ src/fileformat/pfsinimgmagick.1
3
@@ -1,9 +1,10 @@
4
 .TH "pfsinimgmagick" 1
5
 .SH NAME
6
-pfsinimgmagick \- Load images or frames using ImageMagick++ library
7
+pfsinimgmagick \- Load images or frames using Magick++ library
8
 .SH SYNOPSIS
9
 .B pfsinimgmagick
10
-(<file> [--linear] [--absolute <max_lum>] [--frames <range>] [--skip-missing])  [<file>...]
11
+[--ignore-alpha] [--linear] [--absolute <max_lum>] 
12
+<file> [<file> ...] [--frames <range>] [--skip-missing] [<file> ...] ...
13
 
14
 .SH DESCRIPTION
15
 This command can load images or frames in the multitude of image
16
@@ -25,7 +26,8 @@ the 'LUMINANCE' tag is set to 'RELATIVE'
17
 be used to convert pixels to absolute luminance values.
18
 .PP
19
 This command handles properly 'alpha' channel (transparency) stored in
20
-images.
21
+images. Use '--ignore-alpha' switch if you don't want to output an alpha 
22
+channel.
23
 .PP
24
 Each file can contain a \%%d pattern, which is substituted with frame
25
 numbers. The pattern has the same syntax as C
26
@@ -62,22 +64,25 @@ frame in a sequence. This switch can be 
27
 animation where some of the frame has not been generated.
28
 
29
 .TP
30
+.B \--ignore-alpha, -A
31
+When input image contains alpha channel, don't store it in output frame.
32
+
33
+.TP
34
 .B \--linear, -l
35
 Converts pixel values to linear luminance (XYZ), assuming the sRGB
36
-color space for the input image. The maximum pixel value (255,255,255)
37
-is mapped to Y=1. \fILUMINANCE\fR tag is set to RELATIVE.
38
+color space for the input image. The maximum pixel value (defined
39
+by ImageMagick builtin constant named as 'QuantumRange') is mapped
40
+to Y=1. \fILUMINANCE\fR tag is set to RELATIVE.
41
 
42
 .TP
43
 .B \--absolute <max_lum>, -a <max_lum>
44
 \fB--absolute\fR converts pixel values to an absolute linear luminance
45
 (XYZ), that is the color space, in which channel Y contains luminance
46
-given in cd/m^2. The sRGB color space is assumed for the input
47
-image. The maximum pixel value (255,255,255) is mapped to
48
-Y=\fI<max_lum>\fR. \fI<max_lum>\fR is typically set to 80 [cd/m^2] for
49
-a CRT monitor. \fILUMINANCE\fR tag is set to
50
-ABSOLUTE. \fB--absolute\fR process images almost the same as
51
-\fB--relative\fR, but additionally it scales all pixels by
52
-\fI<max_lum>\fR.
53
+given in cd/m^2. The maximum pixel value is mapped to Y=\fI<max_lum>\fR.
54
+\fI<max_lum>\fR is typically set to 80 [cd/m^2] for a CRT monitor.
55
+\fILUMINANCE\fR tag is set to ABSOLUTE. \fB--absolute\fR process images
56
+almost the same as \fB--relative\fR, but additionally it scales all
57
+pixels by \fI<max_lum>\fR.
58
 
59
 .SH EXAMPLES
60
 .TP
(-)graphics/pfstools/files/patch-src_fileformat_pfsinimgmagick.cpp (+260 lines)
Line 0 Link Here
1
--- src/fileformat/pfsinimgmagick.cpp.orig	2018-01-28 11:26:58 UTC
2
+++ src/fileformat/pfsinimgmagick.cpp
3
@@ -42,7 +42,7 @@ class QuietException 
4
 
5
 void printHelp()
6
 {
7
-  std::cerr << PROG_NAME " [--linear] [--absolute <max_lum>] [--verbose] [--help]" << std::endl
8
+  std::cerr << PROG_NAME " [--ignore-alpha] [--linear] [--absolute <max_lum>] \\\n\t[--verbose] [--help]" << std::endl
9
             << "See man page for more information." << std::endl;
10
 }
11
 
12
@@ -55,6 +55,7 @@ void readFrames( int argc, char* argv[] 
13
   bool verbose = false;
14
   bool opt_linear=false;
15
   float absoluteMaxLum = 0;
16
+  bool opt_alpha = true;
17
   
18
   // Parse command line parameters
19
   static struct option cmdLineOptions[] = {
20
@@ -62,9 +63,10 @@ void readFrames( int argc, char* argv[] 
21
     { "verbose", no_argument, NULL, 'v' },
22
     { "linear", no_argument, NULL, 'l' },
23
     { "absolute", required_argument, NULL, 'a' },
24
+    { "ignore-alpha", no_argument, NULL, 'A' },
25
     { NULL, 0, NULL, 0 }
26
   };
27
-  static const char optstring[] = "lhva:";
28
+  static const char optstring[] = "lhva:A";
29
     
30
   pfs::FrameFileIterator it( argc, argv, "rb", NULL, NULL,
31
     optstring, cmdLineOptions );
32
@@ -86,6 +88,9 @@ void readFrames( int argc, char* argv[] 
33
     case 'a':
34
       absoluteMaxLum = (float)strtod( optarg, NULL );
35
       break;
36
+    case 'A':
37
+      opt_alpha = false;
38
+      break;
39
     case '?':
40
       throw QuietException();
41
     case ':':
42
@@ -93,93 +98,131 @@ void readFrames( int argc, char* argv[] 
43
     }
44
   }
45
 
46
-  if( absoluteMaxLum != 0 && opt_linear )
47
-    throw pfs::Exception( "'absolute' and 'linear' are conflicting options" );
48
+  size_t const quantumBits(sizeof(Magick::Quantum)*8);
49
   
50
-  if( absoluteMaxLum < 0 )
51
+  if( absoluteMaxLum < 0.0f )
52
     throw pfs::Exception( "maximum absolute luminance must be > 0" );
53
 
54
-  VERBOSE_STR << "linearize input image: " << ((opt_linear || absoluteMaxLum!=0) ? "yes" : "no") << std::endl;
55
-  if( absoluteMaxLum != 0 )
56
+  Magick::InitializeMagick(*argv);
57
+
58
+  VERBOSE_STR << "quantum range: " << QuantumRange << std::endl;
59
+  VERBOSE_STR << "internal quantum: " 
60
+              << (
61
+                std::numeric_limits<Magick::Quantum>::is_integer 
62
+                ? (std::numeric_limits<Magick::Quantum>::is_signed ? "signed" : "unsigned") 
63
+                : "floating-point" 
64
+              ) 
65
+              << " (" << quantumBits << " bits)" 
66
+              << std::endl;
67
+  if (absoluteMaxLum > 0.0f)
68
     VERBOSE_STR << "maximum absolute luminance: " << absoluteMaxLum << std::endl;
69
 
70
-  Magick::InitializeMagick("");
71
-  
72
-  while( true ) {
73
-    pfs::FrameFile ff = it.getNextFrameFile();
74
-    if( ff.fh == NULL ) break; // No more frames
75
-    it.closeFrameFile( ff );
76
+  VERBOSE_STR << "linearize input image(s): " << (opt_linear ? "yes" : "no") << std::endl;
77
+
78
+  while (true)
79
+  {
80
+    pfs::FrameFile ff(it.getNextFrameFile());
81
+    if (!ff.fh) break; // No more files
82
+    it.closeFrameFile(ff);
83
 
84
     VERBOSE_STR << "reading file '" << ff.fileName << "'" << std::endl;
85
-    Magick::Image imImage( ff.fileName );
86
+    Magick::Image imImage(ff.fileName);
87
 
88
-    VERBOSE_STR << "input image gamma:  " << imImage.gamma() << std::endl;
89
-    bool hasAlpha = imImage.matte();
90
-    if( hasAlpha )
91
-      VERBOSE_STR << "alpha channel found" << std::endl;    
92
-    
93
-    pfs::Frame *frame = pfsio.createFrame( imImage.columns(),
94
-      imImage.rows() );
95
-    pfs::Channel *X, *Y, *Z;
96
-    frame->createXYZChannels( X, Y, Z );
97
+    //VERBOSE_STR << "input image gamma: " << imImage.gamma() << std::endl;
98
+    bool saveAlpha(imImage.matte());
99
+    if (saveAlpha)
100
+      VERBOSE_STR << "alpha channel found" 
101
+                  << (opt_alpha ? "" : " and ignored") 
102
+                  << std::endl;
103
+    saveAlpha &= opt_alpha;
104
 
105
-    pfs::Channel *alpha = NULL;
106
-    if( hasAlpha )
107
-      alpha = frame->createChannel( "ALPHA" );
108
-    
109
-    // Copy line by line to pfs::Frame
110
-    int pixInd = 0;
111
-    const float maxValue = (float)(1<<QuantumDepth) - 1;
112
-    for( int r = 0; r < imImage.rows(); r++ ) {
113
-      const Magick::PixelPacket *pixels =
114
-        imImage.getConstPixels( 0, r, imImage.columns(), 1 );
115
+    pfs::Frame *frame = pfsio.createFrame(imImage.columns(), imImage.rows());
116
+    pfs::TagContainer *tags = frame->getTags();
117
+    pfs::Channel *X, *Y, *Z, *alpha(0);
118
+    frame->createXYZChannels(X, Y, Z);
119
+    if (saveAlpha)
120
+      alpha = frame->createChannel("ALPHA");
121
 
122
-      for( int c = 0; c < imImage.columns(); c++ ) {
123
-        (*X)(pixInd) = (float)pixels[c].red / maxValue;
124
-        (*Y)(pixInd) = (float)pixels[c].green / maxValue;
125
-        (*Z)(pixInd) = (float)pixels[c].blue / maxValue;
126
-        if( alpha != NULL )
127
-          (*alpha)(pixInd) = (float)pixels[c].opacity / maxValue;
128
-        pixInd++;
129
+    // Copy line by line to pfs::Frame
130
+    int const cols(imImage.columns());
131
+    int const rows(imImage.rows());
132
+    for (int r = 0; r < rows; ++r)
133
+    {
134
+      Magick::PixelPacket const *pixels = imImage.getConstPixels(0, r, cols, 1);
135
+      int const roffs(r*cols);
136
+#pragma omp parallel for
137
+      for (int c = 0; c < cols; ++c)
138
+      {
139
+        int const coffs(roffs+c);
140
+        (*X)(coffs) = (float)pixels[c].red / QuantumRange;
141
+        (*Y)(coffs) = (float)pixels[c].green / QuantumRange;
142
+        (*Z)(coffs) = (float)pixels[c].blue / QuantumRange;
143
+        if (alpha)
144
+          (*alpha)(coffs) = 1.0f - (float)pixels[c].opacity / QuantumRange;
145
       } 
146
-    }    
147
+    }
148
 
149
     // Linearize data is necessary
150
-    if( opt_linear || absoluteMaxLum != 0 )
151
-    {
152
-      pfs::transformColorSpace( pfs::CS_SRGB, X, Y, Z, pfs::CS_XYZ, X, Y, Z );
153
-      if( absoluteMaxLum != 0 ) {
154
-        // Rescale to absolute luminance level
155
-        const int pixCount = X->getWidth()*X->getHeight();
156
-        for( int i = 0; i < pixCount; i++ ) {
157
-          (*X)(i) *= absoluteMaxLum;
158
-          (*Y)(i) *= absoluteMaxLum;
159
-          (*Z)(i) *= absoluteMaxLum;
160
-        }        
161
-        frame->getTags()->setString("LUMINANCE", "ABSOLUTE");
162
-      } else
163
-        frame->getTags()->setString("LUMINANCE", "RELATIVE");
164
-    }
165
-    else
166
+    pfs::transformColorSpace(
167
+      opt_linear ? pfs::CS_SRGB : pfs::CS_RGB, X, Y, Z, 
168
+      pfs::CS_XYZ, X, Y, Z
169
+    );
170
+    tags->setString("LUMINANCE", opt_linear ? "RELATIVE" : "DISPLAY");
171
+
172
+    if (absoluteMaxLum > 0.0f)
173
     {
174
-      pfs::transformColorSpace( pfs::CS_RGB, X, Y, Z, pfs::CS_XYZ, X, Y, Z );
175
-      frame->getTags()->setString("LUMINANCE", "DISPLAY");
176
+      // Rescale to absolute luminance level
177
+      int const pixCount(X->getWidth()*X->getHeight());
178
+#pragma omp parallel for
179
+      for (int i = 0; i < pixCount; ++i)
180
+      {
181
+        (*X)(i) *= absoluteMaxLum;
182
+        (*Y)(i) *= absoluteMaxLum;
183
+        (*Z)(i) *= absoluteMaxLum;
184
+      }        
185
+      tags->setString("LUMINANCE", "ABSOLUTE");
186
     }
187
 
188
     // This is the luminance / luma perceived as reference white
189
     // Some tone-mappers may need this
190
-    frame->getTags()->setString("WHITE_Y", "1");    
191
+    tags->setString("WHITE_Y", "1");    
192
 
193
     const char *fileNameTag = strcmp( "-", ff.fileName )==0 ? "stdin" : ff.fileName;
194
-    frame->getTags()->setString( "FILE_NAME", fileNameTag );
195
+    tags->setString( "FILE_NAME", fileNameTag );
196
  
197
-    char strbuf[3];
198
-    snprintf( strbuf, 3, "%d", (int)imImage.depth() );
199
-    frame->getTags()->setString("BITDEPTH", strbuf );    
200
-   
201
+    char strbuf[8];
202
+    snprintf(strbuf, 3, "%d", (int)imImage.depth());
203
+    tags->setString("BITDEPTH", strbuf);    
204
+
205
+    // page geometry
206
+    tags->setString(
207
+      "UNITS", 
208
+      CommandOptionToMnemonic(
209
+        MagickCore::MagickResolutionOptions, 
210
+        (ssize_t)imImage.resolutionUnits()
211
+      )
212
+    ); 
213
+    {
214
+      Magick::Geometry density(imImage.density());
215
+      snprintf(strbuf, 7, "%lu", density.width());
216
+      tags->setString("DENSITY_X", strbuf);    
217
+      snprintf(strbuf, 7, "%lu", density.height());
218
+      tags->setString("DENSITY_Y", strbuf);    
219
+    }
220
+    {
221
+      Magick::Geometry page(imImage.page());
222
+      snprintf(strbuf, 7, "%lu", page.width());
223
+      tags->setString("PAGE_W", strbuf);    
224
+      snprintf(strbuf, 7, "%lu", page.height());
225
+      tags->setString("PAGE_H", strbuf);    
226
+      snprintf(strbuf, 7, "%+ld", page.xOff());
227
+      tags->setString("PAGE_X", strbuf);    
228
+      snprintf(strbuf, 7, "%+ld", page.yOff());
229
+      tags->setString("PAGE_Y", strbuf);    
230
+    }
231
+
232
     pfsio.writeFrame( frame, stdout );
233
     pfsio.freeFrame( frame );
234
-        
235
   }
236
 }
237
 
238
@@ -189,15 +232,19 @@ int main( int argc, char* argv[] )
239
   try {
240
     readFrames( argc, argv );
241
   }
242
-  catch( pfs::Exception ex ) {
243
+  catch( pfs::Exception const &ex ) {
244
     std::cerr << PROG_NAME << " error: " << ex.getMessage() << std::endl;
245
     return EXIT_FAILURE;
246
   }        
247
-  catch( Magick::Exception &ex ) { //This is comming from ImageMagick
248
+  catch( Magick::Exception const &ex ) { //This is comming from ImageMagick
249
     std::cerr << PROG_NAME << " error: " << ex.what() << std::endl;
250
     return EXIT_FAILURE;
251
   }
252
-  catch( QuietException  ex ) {
253
+  catch( std::exception const &ex ) {
254
+    std::cerr << PROG_NAME << " error: " << ex.what() << std::endl;
255
+    return EXIT_FAILURE;
256
+  }
257
+  catch( QuietException  const &ex ) {
258
     return EXIT_FAILURE;
259
   }        
260
   return EXIT_SUCCESS;
(-)graphics/pfstools/files/patch-src_fileformat_pfsinjpeghdr.cpp (+22 lines)
Line 0 Link Here
1
--- src/fileformat/pfsinjpeghdr.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/fileformat/pfsinjpeghdr.cpp
3
@@ -123,8 +123,8 @@ void readFrames( int argc, char* argv[] 
4
     case JPEG_HEADER_HDR:  // HDR image          
5
       jpeghdr_start_decompress(&jhinf);
6
       frame = pfsio.createFrame( jhinf.cinfo.output_width, jhinf.cinfo.output_height );
7
-      hdrscan = (JHSAMPLE *)malloc(jhinf.cinfo.output_width * jhinf.cinfo.output_height *
8
-        sizeof(JHSAMPLE)*3);
9
+      hdrscan = 
10
+        new JHSAMPLE[jhinf.cinfo.output_width * jhinf.cinfo.output_height * 3];
11
       // Important: test jhinf.output_scanline, not jhinf.cinfo
12
       int index ;
13
       index = 0;
14
@@ -144,7 +144,7 @@ void readFrames( int argc, char* argv[] 
15
         (Z->getRawData())[i] = hdrscan[3*i + 2];
16
       }       
17
       pfs::transformColorSpace( pfs::CS_RGB, X, Y, Z, pfs::CS_XYZ, X, Y, Z );	  
18
-      free((void *)hdrscan);
19
+      delete[] hdrscan;
20
       break;
21
     case JPEG_HEADER_OK:  // LDR image
22
     case JPEG_SUSPENDED:
(-)graphics/pfstools/files/patch-src_fileformat_pfsintiff.cpp (+90 lines)
Line 0 Link Here
1
--- src/fileformat/pfsintiff.cpp.orig	2018-01-25 18:02:57 UTC
2
+++ src/fileformat/pfsintiff.cpp
3
@@ -55,7 +55,8 @@ void readFrames( int argc, char* argv[] 
4
   pfs::DOMIO pfsio;
5
 
6
   bool verbose = false;
7
-  bool opt_linear=false;
8
+  bool opt_linear = false;
9
+  float absoluteMaxLum = 0;
10
   bool opt_exponential_mode = false;
11
   
12
   // Parse command line parameters
13
@@ -63,10 +64,11 @@ void readFrames( int argc, char* argv[] 
14
     { "help", no_argument, NULL, 'h' },
15
     { "verbose", no_argument, NULL, 'v' },
16
     { "linear", no_argument, NULL, 'l' },
17
+    { "absolute", required_argument, NULL, 'a' },
18
     { "expmode", no_argument, NULL, 'e' },
19
     { NULL, 0, NULL, 0 }
20
   };
21
-  static const char optstring[] = "elhv";
22
+  static const char optstring[] = "ela:hv";
23
     
24
   pfs::FrameFileIterator it( argc, argv, "rb", NULL, stdin,
25
     optstring, cmdLineOptions );
26
@@ -85,6 +87,9 @@ void readFrames( int argc, char* argv[] 
27
     case 'l':
28
       opt_linear = true;
29
       break;
30
+    case 'a':
31
+      absoluteMaxLum = (float)strtod( optarg, NULL );
32
+      break;
33
     case 'e':
34
       opt_exponential_mode = true;
35
       break;
36
@@ -95,7 +100,9 @@ void readFrames( int argc, char* argv[] 
37
     }
38
   }
39
 
40
-  VERBOSE_STR << "linearize input image: " << (opt_linear ? "yes" : "no") << std::endl;
41
+  VERBOSE_STR << "linearize input image: " << ((opt_linear || absoluteMaxLum!=0) ? "yes" : "no") << std::endl;
42
+  if( absoluteMaxLum != 0 )
43
+    VERBOSE_STR << "maximum absolute luminance: " << absoluteMaxLum << std::endl;
44
   VERBOSE_STR << "exponential mode (Lars3 HDR camera): "
45
               << (opt_exponential_mode ? "yes" : "no") << std::endl;  
46
   
47
@@ -119,20 +126,35 @@ void readFrames( int argc, char* argv[] 
48
 
49
     //Store RGB data temporarily in XYZ channels
50
     reader.readImage( X, Y, Z );
51
-    if( opt_linear && !reader.isRelative() )
52
+    if( opt_linear || absoluteMaxLum != 0 )
53
     {
54
       pfs::transformColorSpace( pfs::CS_SRGB, X, Y, Z, pfs::CS_XYZ, X, Y, Z );
55
+      if( absoluteMaxLum != 0 ) {
56
+        // Rescale to absolute luminance level
57
+        const int pixCount = X->getWidth()*X->getHeight();
58
+#pragma omp parallel for
59
+        for( int i = 0; i < pixCount; i++ ) {
60
+          (*X)(i) *= absoluteMaxLum;
61
+          (*Y)(i) *= absoluteMaxLum;
62
+          (*Z)(i) *= absoluteMaxLum;
63
+        }        
64
+      }
65
+    }
66
+    else if( !reader.isColorspaceXYZ() )
67
+    {
68
+      pfs::transformColorSpace( pfs::CS_RGB, X, Y, Z, pfs::CS_XYZ, X, Y, Z );
69
+    }
70
+    if( absoluteMaxLum != 0 || reader.isColorspaceXYZ() )
71
+    {
72
+      frame->getTags()->setString("LUMINANCE", "ABSOLUTE");
73
+    }
74
+    else if( opt_linear )
75
+    {
76
       frame->getTags()->setString("LUMINANCE", "RELATIVE");
77
     }
78
     else
79
     {
80
-      if( !reader.isColorspaceXYZ() )
81
-        pfs::transformColorSpace( pfs::CS_RGB, X, Y, Z, pfs::CS_XYZ, X, Y, Z );
82
-      
83
-      if( reader.isRelative() )
84
-        frame->getTags()->setString("LUMINANCE", "RELATIVE");
85
-      else
86
-        frame->getTags()->setString("LUMINANCE", "DISPLAY");
87
+      frame->getTags()->setString("LUMINANCE", "DISPLAY");
88
     }
89
 
90
     const char *fileNameTag = strcmp( "-", ff.fileName )==0 ? "stdin" : ff.fileName;
(-)graphics/pfstools/files/patch-src_fileformat_pfsinyuv.cpp (+18 lines)
Line 0 Link Here
1
--- src/fileformat/pfsinyuv.cpp.orig	2018-01-25 16:27:28 UTC
2
+++ src/fileformat/pfsinyuv.cpp
3
@@ -482,6 +482,7 @@ void readFrames( int argc, char* argv[] 
4
     case pfs::CS_HLGYCbCr2020:
5
       VERBOSE_STR << "colorspace: HDR HLG BT2020" << std::endl;
6
       break;
7
+    default: ;
8
   }
9
 
10
   if( width <= 0 || height <= 0 )
11
@@ -547,6 +548,7 @@ void readFrames( int argc, char* argv[] 
12
       case pfs::CS_HLGYCbCr2020:
13
         frame->getTags()->setString("LUMINANCE", "ABSOLUTE");
14
         break;
15
+      default: ;
16
     }
17
 
18
     if( fps > 0 ){
(-)graphics/pfstools/files/patch-src_fileformat_pfsoutimgmagick.1 (+86 lines)
Line 0 Link Here
1
--- src/fileformat/pfsoutimgmagick.1.orig	2018-01-29 14:36:10 UTC
2
+++ src/fileformat/pfsoutimgmagick.1
3
@@ -1,9 +1,12 @@
4
 .TH "pfsoutimgmagick" 1
5
 .SH NAME
6
-pfsoutimgmagick \- Write images or frames using Image Magick library
7
+pfsoutimgmagick \- Write images or frames using Magick++ library
8
 .SH SYNOPSIS
9
 .B pfsoutimgmagick
10
-[--linear] [--quality <val>] [--bit-depth] [--frames <range>]) <file> [<file>...]
11
+[--ignore-alpha] [--srgb] [--absolute <max_lum>] 
12
+[--quality <percent>] [--compress <method>] 
13
+[--bit-depth <depth>] [--quantum-format <format>] 
14
+<file> [<file> ...] [--frames <range>]
15
 .SH DESCRIPTION
16
 This command can write images or frames in the multitude of image
17
 formats supported by the ImageMagick library. This includes but is not
18
@@ -13,17 +16,20 @@ ImageMagick for the full list of availab
19
 \fBpfsoutimgmagick\fR reads images or frames in \fIpfs\fR format from
20
 the Standard Input and writes them under the specified file name(s).
21
 .PP
22
-The input of \fBpfsinimgmagick\fR must be within 0-1 range. If \fILUMINANCE\fR
23
-tag set is set to \fIRELATIVE\fR or \fIABSOLUTE\fR, the linear
24
-values will be gamma corrected, assuming sRGB color space. Use \fI--linear\fR
25
-switch to disable gamma correction.
26
+The input of \fBpfsoutimgmagick\fR must be within 0-1 range. When input
27
+is \fIABSOLUTE\fR pfs stream with <max_lum> luminance, use '--absolute 
28
+<max_lum>' switch to set valid range. To make an output image(s) 
29
+gamma-corrected, assuming sRGB color space, use '--srgb' switch.
30
 .PP
31
 The images are stored using the bit-depth for which the ImageMagick
32
 library was compiled (default is 16 bit). Note that some formats (for
33
 example JPEG) do not support encoding more than 8 bits per color
34
 channel. To use higher bit-depths, store images in the PNG format.
35
 .PP
36
-This command stores 'ALPHA' channel if it is present in the pfs stream.
37
+This command stores alpha channel if it is present in the pfs stream 
38
+(channel name is 'ALPHA' or 'A') and output format supports transparency.
39
+Use '--ignore-alpha' switch if you don't want to output an alpha 
40
+channel.
41
 .PP
42
 Each file name can contain a \%%d pattern, which is substituted with
43
 frame numbers. The pattern has the same syntax as C \fIprintf\fR
44
@@ -49,6 +55,9 @@ for frames 1,2,...,100 and
45
 .I 0:2:
46
 for frame 0,2,4,... up to the last file that exists.
47
 .TP
48
+.B \--ignore-alpha, -A
49
+When input frame contains alpha channel, don't store it in output image.
50
+.TP
51
 .B --srgb, -s
52
 Apply the sRGB non-linearity (approximately 2.2 gamma) before writing
53
 a file. This can be used instead of using \fIpfsgamma -g 2.2\fR to
54
@@ -57,10 +66,18 @@ compress contrast to make sure that tone
55
 a display. It should be only used with linearized (not gamma
56
 corrected) images that are normalized to the 0-1 range.
57
 .TP
58
-\fB--quality\fR <val>, \fB-q\fR <val>
59
+\fB--absolute\fR <max_lum>, \fB-a\fR <max_lum>
60
+Normalize input pfs stream with absolute luminance <max_lum> to the 
61
+0-1 range.
62
+.TP
63
+\fB--quality\fR <percent>, \fB-q\fR <percent>
64
 Set JPEG/PNG compression level from 1 to 100. Default 75.
65
 .TP
66
-\fB--bit-depth\fR <val>, \fB-b <val>
67
+\fB--compress\fR <method>, \fB-c\fR <method>
68
+Set compression method. Default is 'none'. See ImageMagick manual
69
+for details.
70
+.TP
71
+\fB--bit-depth\fR <depth>, \fB-b\fR <depth>
72
 Enforce bit-depth (per color
73
 channel). The allowed values are from 8 to 32. If not specified, the
74
 bit depth from the pfs stream ('BITDEPTH' tag) will be used
75
@@ -68,6 +85,11 @@ instead. If the 'BITDEPTH' tag is missin
76
 value will be used (usually 16). The bit depth of actually stored file
77
 may be lower of that specified, if the file format does not support
78
 higher bit depths.
79
+.TP
80
+\fB--quantum-format\fR <format>, \fB-F\fR <format>
81
+Defines an output quantum format. Default is 'unsigned'. Available 
82
+formats depend on internal ImageMagick quantum format. See ImageMagick 
83
+manual for details.
84
 
85
 .SH EXAMPLES
86
 .TP
(-)graphics/pfstools/files/patch-src_fileformat_pfsoutimgmagick.cpp (+368 lines)
Line 0 Link Here
1
--- src/fileformat/pfsoutimgmagick.cpp.orig	2018-01-29 15:31:37 UTC
2
+++ src/fileformat/pfsoutimgmagick.cpp
3
@@ -32,6 +32,7 @@
4
 #include <Magick++.h>
5
 
6
 #include <iostream>
7
+#include <sstream>
8
 
9
 #include <getopt.h>
10
 #include <pfs.h>
11
@@ -44,37 +45,37 @@ class QuietException 
12
 
13
 void printHelp()
14
 {
15
-  std::cerr << PROG_NAME " [--linear] [--quality] [--bit-depth] [--verbose] [--help]" << std::endl
16
+  std::cerr << PROG_NAME " [--ignore-alpha] [--srgb] [--absolute <max_lum>] \\\n\t[--quality <percent>] [--compress <method>] \\\n\t[--bit-depth <depth>] [--quantum-format <format>] \\\n\t[--verbose] [--help]" << std::endl
17
             << "See man page for more information." << std::endl;
18
 }
19
 
20
-template<class T>
21
-inline T clamp( const T v, const T minV, const T maxV )
22
-{
23
-    if( v < minV ) return minV;
24
-    if( v > maxV ) return maxV;
25
-    return v;
26
-}
27
-
28
 void writeFrames( int argc, char* argv[] )
29
 {
30
   pfs::DOMIO pfsio;
31
 
32
   bool verbose = false;
33
   bool opt_srgb=false;
34
+  float absoluteMaxLum = 0;
35
   int quality = 75;
36
+  char const *opt_compress = 0;
37
   int opt_bit_depth = -1;
38
+  char const *opt_quantum = "unsigned";
39
+  bool opt_alpha = true;
40
   
41
   // Parse command line parameters
42
   static struct option cmdLineOptions[] = {
43
     { "help", no_argument, NULL, 'h' },
44
     { "verbose", no_argument, NULL, 'v' },
45
+    { "ignore-alpha", no_argument, NULL, 'A' },
46
     { "srgb", no_argument, NULL, 's' },
47
+    { "absolute", required_argument, NULL, 'a' },
48
     { "quality", required_argument, NULL, 'q' },
49
+    { "compress", required_argument, NULL, 'c' },
50
     { "bit-depth", required_argument, NULL, 'b' },
51
+    { "quantum-format", required_argument, NULL, 'F' },
52
     { NULL, 0, NULL, 0 }
53
   };
54
-  static const char optstring[] = "shvq:b:";
55
+  static const char optstring[] = "f:hvAsa:q:c:b:F:";
56
     
57
   pfs::FrameFileIterator it( argc, argv, "wb", NULL, NULL,
58
     optstring, cmdLineOptions );
59
@@ -90,14 +91,26 @@ void writeFrames( int argc, char* argv[]
60
     case 'v':
61
       verbose = true;
62
       break;
63
+    case 'A':
64
+      opt_alpha = false;
65
+      break;
66
+    case 's':
67
+      opt_srgb = true;
68
+      break;
69
+    case 'a':
70
+      absoluteMaxLum = (float)strtod( optarg, NULL );
71
+      break;
72
     case 'q':
73
       quality = strtol( optarg, NULL, 10 );
74
       break;
75
+    case 'c':
76
+      opt_compress = optarg;
77
+      break;
78
     case 'b':
79
       opt_bit_depth = strtol( optarg, NULL, 10 );
80
       break;
81
-    case 's':
82
-      opt_srgb = true;
83
+    case 'F':
84
+      opt_quantum = optarg;
85
       break;
86
     case '?':
87
       throw QuietException();
88
@@ -106,31 +119,59 @@ void writeFrames( int argc, char* argv[]
89
     }
90
   }
91
 
92
-  if( quality < 1 || quality > 100 )
93
-      throw pfs::Exception( "'quality' argument must be within 1-100 range" );
94
+  size_t const quantumBits(sizeof(Magick::Quantum)*8);
95
 
96
-  if( opt_bit_depth != -1 && (opt_bit_depth < 8 || opt_bit_depth > 32 ) )
97
-      throw pfs::Exception( "'bit-depth' argument must be within 8-32 range" );
98
+  if (quality < 1 || quality > 100)
99
+    throw pfs::Exception("'quality' argument must be within 1-100 range");
100
+
101
+  if (opt_bit_depth != -1 
102
+      && (opt_bit_depth < 8 || opt_bit_depth > quantumBits))
103
+  {
104
+    std::ostringstream msg;
105
+    msg << "'bit-depth' argument must be within 8-" << quantumBits << " range";
106
+    throw pfs::Exception(msg.str().c_str());
107
+  }
108
   
109
-  VERBOSE_STR << "quality: " << quality << "%\n";
110
+  if (absoluteMaxLum < 0.0f)
111
+    throw pfs::Exception( "maximum absolute luminance must be > 0" );
112
 
113
-  Magick::InitializeMagick("");
114
+  Magick::InitializeMagick(*argv);
115
+
116
+  VERBOSE_STR << "quantum range: " << QuantumRange << std::endl;
117
+  VERBOSE_STR << "internal quantum: " 
118
+              << (
119
+                std::numeric_limits<Magick::Quantum>::is_integer 
120
+                ? (std::numeric_limits<Magick::Quantum>::is_signed ? "signed" : "unsigned") 
121
+                : "floating-point" 
122
+              ) 
123
+              << " (" << quantumBits << " bits)" 
124
+              << std::endl;
125
+  if (absoluteMaxLum > 0.0f)
126
+    VERBOSE_STR << "maximum absolute luminance: " << absoluteMaxLum << std::endl;
127
+
128
+  ssize_t compress((ssize_t)Magick::NoCompression);
129
+  if (opt_compress)
130
+  {
131
+    compress = ParseCommandOption(MagickCore::MagickCompressOptions, Magick::MagickFalse, opt_compress);
132
+    if (compress < 0)
133
+      throw pfs::Exception((std::string("unknown compression method: '") + opt_compress + "'").c_str());
134
+  }
135
   
136
-  while( true ) {
137
-    pfs::Frame *frame = pfsio.readFrame( stdin );
138
-    if( frame == NULL ) {
139
-      break;
140
-    }        
141
+  while (true)
142
+  {
143
+    pfs::Frame *frame = pfsio.readFrame(stdin);
144
+    if (!frame) break; // No more frames
145
+    pfs::TagContainer const *tags = frame->getTags();
146
 
147
     pfs::FrameFile ff = it.getNextFrameFile();
148
-    if( ff.fh == NULL ) {
149
-      pfsio.freeFrame( frame );
150
-      break; // No more frames
151
+    if (!ff.fh)
152
+    {
153
+      pfsio.freeFrame(frame);
154
+      break; // No more files
155
     }
156
-    it.closeFrameFile( ff );
157
-    
158
-    pfs::Channel *X, *Y, *Z, *alpha;
159
-        
160
+    it.closeFrameFile(ff);
161
+
162
+    pfs::Channel *X, *Y, *Z, *alpha = 0;
163
     frame->getXYZChannels( X, Y, Z );
164
     if( X == NULL )         // No color
165
     {
166
@@ -142,66 +183,152 @@ void writeFrames( int argc, char* argv[]
167
       Z = frame->createChannel( "Z" );
168
       pfs::transformColorSpace( pfs::CS_RGB, Y, Y, Y, pfs::CS_XYZ, X, Y, Z );
169
     }
170
+    (alpha = frame->getChannel("ALPHA")) || (alpha = frame->getChannel("A"));
171
 
172
-    alpha = frame->getChannel( "ALPHA" );
173
-    if( alpha == NULL )
174
-      alpha = frame->getChannel( "A" );
175
-        
176
-    const char* luminanceTag = frame->getTags()->getString("LUMINANCE");
177
-    if( luminanceTag!=NULL && strcmp(luminanceTag,"ABSOLUTE")==0 )
178
+    size_t const frameWidth(frame->getWidth());
179
+    size_t const frameHeight(frame->getHeight());
180
+    size_t const pixelCount(frameWidth*frameHeight);
181
+
182
+    if (absoluteMaxLum > 0.0f)
183
+    {
184
+#pragma omp parallel for
185
+      for (int pix = 0; pix < pixelCount; ++pix)
186
+      {
187
+        (*X)(pix) /= absoluteMaxLum;
188
+        (*Y)(pix) /= absoluteMaxLum;
189
+        (*Z)(pix) /= absoluteMaxLum;
190
+      }
191
+    }
192
+
193
+    const char* luminanceTag = tags->getString("LUMINANCE");
194
+    if( luminanceTag!=NULL && strcmp(luminanceTag,"ABSOLUTE")==0 && absoluteMaxLum == 0.0f )
195
         std::cerr << PROG_NAME << " warning: This file format cannot store absolute luminance values\n";    
196
     if( opt_srgb )
197
     {
198
       if( luminanceTag!=NULL && strcmp(luminanceTag,"DISPLAY")==0 )
199
         std::cerr << PROG_NAME << " warning: This image seems to be display referred thus there is no need for applying the sRGB non-linearity\n";
200
-      pfs::transformColorSpace( pfs::CS_XYZ, X, Y, Z, pfs::CS_SRGB, X, Y, Z );        
201
+      pfs::transformColorSpace( pfs::CS_XYZ, X, Y, Z, pfs::CS_SRGB, X, Y, Z );
202
       VERBOSE_STR << "writing file (sRGB corrected) '" << ff.fileName << "'" << std::endl;
203
     }
204
     else
205
     {      
206
-      pfs::transformColorSpace( pfs::CS_XYZ, X, Y, Z, pfs::CS_RGB, X, Y, Z );        
207
+      pfs::transformColorSpace( pfs::CS_XYZ, X, Y, Z, pfs::CS_RGB, X, Y, Z );
208
       VERBOSE_STR << "writing file (linear) '" << ff.fileName << "'" << std::endl;
209
     }        
210
 
211
     // Determine bit-depth for writing images (bitdepth == -1 for default)
212
     int bitdepth = -1;
213
-    if( opt_bit_depth != -1 )
214
+    if( opt_bit_depth > 0 )
215
       bitdepth = opt_bit_depth;
216
     else {      
217
-      const char* bitDepthTag = frame->getTags()->getString("BITDEPTH");
218
+      const char* bitDepthTag = tags->getString("BITDEPTH");
219
       if( bitDepthTag!=NULL ) {
220
         bitdepth=strtol( bitDepthTag, NULL, 10 );
221
         if( bitdepth < 8 )
222
           bitdepth = 8;
223
-        else if( bitdepth > 16 )
224
-          bitdepth = 16;
225
+        else if( bitdepth > quantumBits )
226
+          bitdepth = quantumBits;
227
       }
228
     }
229
     
230
     {
231
       // Copy image to array that can be accepted by ImageMagick
232
-      const int pixelCount = frame->getWidth()*frame->getHeight();
233
-      unsigned short *imgBuffer =
234
-        new unsigned short[pixelCount*(alpha == NULL ? 3 : 4)];
235
-      int i = 0;
236
-      float maxValue = (float)(1<<16) -1;
237
-      for( int pix = 0; pix < pixelCount; pix++ ) {
238
-        imgBuffer[i++] = (unsigned short)(clamp((*X)(pix),0.f,1.f)*maxValue);
239
-        imgBuffer[i++] = (unsigned short)(clamp((*Y)(pix),0.f,1.f)*maxValue);
240
-        imgBuffer[i++] = (unsigned short)(clamp((*Z)(pix),0.f,1.f)*maxValue);
241
-        if( alpha != NULL )
242
-          imgBuffer[i++] = (unsigned short)(maxValue-clamp((*alpha)(pix),0.f,1.f)*maxValue);
243
+      int const channels(opt_alpha && alpha ? 4 : 3);
244
+      if (alpha)
245
+        VERBOSE_STR << "alpha channel found and " 
246
+                    << (channels > 3 ? "will be saved" : "ignored") 
247
+                    << std::endl;    
248
+      std::vector<Magick::Quantum> imgBuffer(pixelCount*channels);
249
+#pragma omp parallel for
250
+      for (int pix = 0; pix < pixelCount; ++pix)
251
+      {
252
+        int const i(pix*channels);
253
+        imgBuffer[i+0] = (Magick::Quantum)((*X)(pix)*QuantumRange);
254
+        imgBuffer[i+1] = (Magick::Quantum)((*Y)(pix)*QuantumRange);
255
+        imgBuffer[i+2] = (Magick::Quantum)((*Z)(pix)*QuantumRange);
256
+        if (channels > 3)
257
+          imgBuffer[i+3] = (Magick::Quantum)((*alpha)(pix)*QuantumRange);
258
       }
259
-      Magick::Image imImage( frame->getWidth(), frame->getHeight(),
260
-        (alpha == NULL ? "RGB" : "RGBA"), Magick::ShortPixel, imgBuffer );
261
-      imImage.quality( quality );
262
-      if( bitdepth != -1 )
263
-        imImage.depth( bitdepth );
264
-      imImage.write( ff.fileName );
265
-      delete[] imgBuffer;  
266
+      Magick::Image imImage(
267
+        frameWidth, frameHeight,
268
+        channels > 3 ? "RGBA" : "RGB", Magick::QuantumPixel, &imgBuffer[0]
269
+      );
270
+
271
+      // quantum format
272
+      imImage.defineValue("quantum", "format", opt_quantum);
273
+      VERBOSE_STR << "output quantum format: " 
274
+                  << imImage.defineValue("quantum", "format") 
275
+                  << std::endl;
276
+
277
+      if (bitdepth > 0)
278
+      {
279
+        imImage.depth(bitdepth);
280
+        //!!dirty hack: bug in void Magick::Image::depth(const size_t depth)
281
+        imImage.image()->depth = bitdepth;
282
+        imImage.imageInfo()->depth = bitdepth;
283
+        //!!dirty hack
284
+        VERBOSE_STR << "bit depth: " 
285
+                   // << bitdepth << "/" 
286
+                    << imImage.depth() 
287
+                    << std::endl;
288
+      }
289
+
290
+      // page geometry
291
+      char const *units = tags->getString("UNITS");
292
+      if (units)
293
+      {
294
+        int resolutionUnits(ParseCommandOption(MagickCore::MagickResolutionOptions, Magick::MagickFalse, units));
295
+        if (resolutionUnits < 0)
296
+          std::cerr << PROG_NAME " warning: unknown resolution units: '" << units << "', use default" << std::endl;
297
+        else
298
+          imImage.resolutionUnits((Magick::ResolutionType)resolutionUnits);
299
+      }
300
+      {
301
+        Magick::Geometry density(imImage.density());
302
+        char const *dxy = tags->getString("DENSITY");
303
+        char const *buf = tags->getString("DENSITY_X");
304
+        if (!buf || !*buf)
305
+          buf = dxy;
306
+        if (buf && *buf)
307
+          density.width(strtol(buf, NULL, 10));
308
+        buf = tags->getString("DENSITY_Y");
309
+        if (!buf || !*buf)
310
+          buf = dxy;
311
+        if (buf && *buf)
312
+          density.height(strtol(buf, NULL, 10));
313
+        imImage.density(density);
314
+      }
315
+      {
316
+        Magick::Geometry page(imImage.page());
317
+        char const *buf = tags->getString("PAGE_W");
318
+        if (buf && *buf)
319
+          page.width(strtol(buf, NULL, 10));
320
+        buf = tags->getString("PAGE_H");
321
+        if (buf && *buf)
322
+          page.height(strtol(buf, NULL, 10));
323
+        buf = tags->getString("PAGE_X");
324
+        if (buf && *buf)
325
+          page.xOff(strtol(buf, NULL, 10));
326
+        buf = tags->getString("PAGE_Y");
327
+        if (buf && *buf)
328
+          page.yOff(strtol(buf, NULL, 10));
329
+        imImage.page(page);
330
+      }
331
+
332
+      imImage.quality(quality);
333
+      VERBOSE_STR << "quality: " 
334
+                 // << quality << "%/" 
335
+                  << imImage.quality() << "%" 
336
+                  << std::endl;
337
+
338
+      imImage.compressType((MagickCore::CompressionType)compress);
339
+      VERBOSE_STR << "compression method: " 
340
+                  << CommandOptionToMnemonic(MagickCore::MagickCompressOptions, (ssize_t)imImage.compressType()) 
341
+                  << std::endl;
342
+
343
+      imImage.write(ff.fileName);
344
     }
345
-    pfsio.freeFrame( frame );
346
-        
347
+    pfsio.freeFrame(frame);
348
   }    
349
 }
350
 
351
@@ -211,11 +338,15 @@ int main( int argc, char* argv[] )
352
   try {
353
     writeFrames( argc, argv );
354
   }
355
-  catch( pfs::Exception ex ) {
356
+  catch( pfs::Exception const &ex ) {
357
     std::cerr << PROG_NAME << " error: " << ex.getMessage() << std::endl;
358
     return EXIT_FAILURE;
359
   }        
360
-  catch( Magick::Exception &ex ) { //This is comming from ImageMagick
361
+  catch( Magick::Exception const &ex ) { //This is comming from ImageMagick
362
+    std::cerr << PROG_NAME << " error: " << ex.what() << std::endl;
363
+    return EXIT_FAILURE;
364
+  }
365
+  catch( std::exception const &ex ) {
366
     std::cerr << PROG_NAME << " error: " << ex.what() << std::endl;
367
     return EXIT_FAILURE;
368
   }
(-)graphics/pfstools/files/patch-src_fileformat_pfsoutjpeghdr.cpp (+40 lines)
Line 0 Link Here
1
--- src/fileformat/pfsoutjpeghdr.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/fileformat/pfsoutjpeghdr.cpp
3
@@ -69,8 +69,7 @@ void writeHDRJPEGGray( FILE *fh, int wid
4
    jhinf.correction = correction;
5
    jpeg_stdio_dest(&jhinf.cinfo, fh);
6
    
7
-   image = (JHSAMPLE *)malloc(width * height *
8
-          sizeof(JHSAMPLE)*3);
9
+   image = new JHSAMPLE[width * height * 3];
10
    
11
    for(int i=0;i<width * height;i++)
12
    {
13
@@ -91,7 +90,7 @@ void writeHDRJPEGGray( FILE *fh, int wid
14
    // Or, assign jhinf.tmi 8-bit grayscale values in scanline order
15
    jpeghdr_do_compress(&jhinf);
16
    jpeghdr_destroy_compress(&jhinf);
17
-   fclose(fh);
18
+   delete[] image;
19
 }
20
 
21
 void writeHDRJPEGRGB( FILE *fh, int width, int height,
22
@@ -111,8 +110,7 @@ void writeHDRJPEGRGB( FILE *fh, int widt
23
    jhinf.beta = beta;
24
    jpeg_stdio_dest(&jhinf.cinfo, fh);
25
    
26
-   image = (JHSAMPLE *)malloc(width * height *
27
-          sizeof(JHSAMPLE)*3);
28
+   image = new JHSAMPLE[width * height * 3];
29
    
30
    for(int i=0;i<width * height;i++)
31
    {
32
@@ -135,7 +133,7 @@ void writeHDRJPEGRGB( FILE *fh, int widt
33
    jpeghdr_do_compress(&jhinf);
34
    jpeghdr_destroy_compress(&jhinf);
35
 
36
-   free( image );
37
+   delete[] image;
38
 }
39
 
40
 void writeFrames( int argc, char* argv[] )
(-)graphics/pfstools/files/patch-src_fileformat_pfsoutpfm.cpp (+20 lines)
Line 0 Link Here
1
--- src/fileformat/pfsoutpfm.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/fileformat/pfsoutpfm.cpp
3
@@ -85,7 +85,7 @@ void writePFMFileColor( FILE *fh, int wi
4
     }
5
     int written = fwrite( line, sizeof( float ), lineSize, fh );
6
     if( written != lineSize )
7
-      throw new pfs::Exception( "Unable to write data" );
8
+      throw pfs::Exception( "Unable to write data" );
9
   }
10
   delete[] line;  
11
 }
12
@@ -109,7 +109,7 @@ void writePFMFileGrayscale( FILE *fh, in
13
     }
14
     int written = fwrite( line, sizeof( float ), lineSize, fh );
15
     if( written != lineSize )
16
-      throw new pfs::Exception( "Unable to write data" );
17
+      throw pfs::Exception( "Unable to write data" );
18
   }
19
   delete[] line;  
20
 }
(-)graphics/pfstools/files/patch-src_fileformat_pfsoutyuv.cpp (+25 lines)
Line 0 Link Here
1
--- src/fileformat/pfsoutyuv.cpp.orig	2018-01-25 16:27:28 UTC
2
+++ src/fileformat/pfsoutyuv.cpp
3
@@ -215,7 +215,7 @@ class YUVWriter {
4
   }
5
 
6
   template<typename T>
7
-  bool writeYuvImage(pfs::Array2D *R, pfs::Array2D *G, pfs::Array2D *B){
8
+  void writeYuvImage(pfs::Array2D *R, pfs::Array2D *G, pfs::Array2D *B){
9
   //writes the entire image to fh R - Luminance, G - Cr, B - Cb
10
   unsigned int width_chroma = R->getCols();
11
   unsigned int height_chroma = R->getRows();
12
@@ -388,10 +388,11 @@ void writeFrames( int argc, char* argv[]
13
     }
14
     
15
   
16
-  if( srgb_input )
17
+  if( srgb_input ) {
18
     VERBOSE_STR << "Input data in sRGB (LDR) space" << std::endl;
19
-  else
20
+  } else {
21
     VERBOSE_STR << "Input data in absolute linear (HDR) space" << std::endl;
22
+  }
23
   
24
   MetaDataFrameFileIterator it(argc, argv, "wb", NULL, stdout, optstring, cmdLineOptions, width,
25
                                 height, bit_depth, colorSpaceStr, downscale_chroma ? "420" : "444", fps);
(-)graphics/pfstools/files/patch-src_filter_CMakeLists.txt (+11 lines)
Line 0 Link Here
1
--- src/filter/CMakeLists.txt.orig	2018-01-19 06:59:44 UTC
2
+++ src/filter/CMakeLists.txt
3
@@ -6,7 +6,7 @@ link_directories("${PROJECT_SOURCE_DIR}/
4
 
5
 set(PFS_FILT pfsgamma pfsclamp pfstag pfssize pfsextractchannels
6
 pfspanoramic pfsrotate pfsflip pfscut pfspad pfscat pfsabsolute pfsretime
7
-pfscolortransform) 
8
+pfscolortransform pfswb) 
9
 
10
 foreach(TRG ${PFS_FILT}) 
11
     add_executable(${TRG} ${TRG}.cpp "${GETOPT_OBJECT}")
(-)graphics/pfstools/files/patch-src_filter_pfscat.cpp (+37 lines)
Line 0 Link Here
1
--- src/filter/pfscat.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/filter/pfscat.cpp
3
@@ -27,6 +27,7 @@
4
 #include <pfs.h>
5
 #include <climits>
6
 #include <iostream>
7
+#include <vector>
8
 #include <getopt.h>
9
 #include <fcntl.h>
10
 #include <stdlib.h>
11
@@ -202,16 +203,12 @@ if (alignment==UNSP) throw pfs::Exceptio
12
 
13
 pfs::FrameFileIterator it ( argc, argv, "rb", NULL, NULL, optString, cmdLineOptions);
14
 int pipe_no = 0;
15
-pfs::FrameFile * ff;
16
-ff = (pfs::FrameFile *) malloc ((pipe_no+1) * sizeof(pfs::FrameFile));
17
-
18
+std::vector<pfs::FrameFile> ff;
19
 while (1) {
20
-    ff[pipe_no] = it.getNextFrameFile();
21
+    ff.push_back(it.getNextFrameFile());
22
     if (ff[pipe_no].fh == NULL) break; // no more files
23
     pipe_no++;
24
-    ff=(pfs::FrameFile *) realloc(ff, (pipe_no+1)*sizeof(pfs::FrameFile));
25
     }
26
-    
27
 if(pipe_no == 0) { // no named pipes
28
     pipe_no = 1;
29
     pipes = false;
30
@@ -408,7 +405,6 @@ if(!pipes) {
31
     }
32
 
33
 for (int i=0; i<pipe_no; i++) it.closeFrameFile(ff[i]);
34
-free(ff);
35
 }
36
 
37
 
(-)graphics/pfstools/files/patch-src_filter_pfsclamp.1 (+17 lines)
Line 0 Link Here
1
--- src/filter/pfsclamp.1.orig	2018-01-19 06:59:44 UTC
2
+++ src/filter/pfsclamp.1
3
@@ -16,12 +16,12 @@ The command operates directly on XYZ cha
4
 .TP
5
 --min <val>
6
 
7
-Lower bound for clamping. Default value: 0.0001 (10^-4)
8
+Lower bound for clamping. Default value: 1e-20 (10^-20)
9
 
10
 .TP
11
 --max <val>
12
 
13
-Upper bound for clamping. Default value: 100000000 (10^8)
14
+Upper bound for clamping. Default value: 1e20 (10^20)
15
 
16
 .TP
17
 --percentile, -p
(-)graphics/pfstools/files/patch-src_filter_pfsclamp.cpp (+13 lines)
Line 0 Link Here
1
--- src/filter/pfsclamp.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/filter/pfsclamp.cpp
3
@@ -153,8 +153,8 @@ void clampFrames( int argc, char* argv[]
4
   }
5
   else
6
   {
7
-    clampMin = (clampMin>1e-4) ? clampMin : 1e-4;
8
-    clampMax = (clampMax<1e8) ? clampMax : 1e8;
9
+    clampMin = (clampMin>1e-20) ? clampMin : 1e-20;
10
+    clampMax = (clampMax<1e+20) ? clampMax : 1e+20;
11
     if( clampMin >= clampMax )
12
       throw pfs::Exception("incorrect clamping range");
13
   }
(-)graphics/pfstools/files/patch-src_filter_pfstag.cpp (+57 lines)
Line 0 Link Here
1
--- src/filter/pfstag.cpp.orig	2018-01-26 13:15:24 UTC
2
+++ src/filter/pfstag.cpp
3
@@ -106,7 +106,7 @@ void setTagsOnFrames( int argc, char* ar
4
 
5
   int optionIndex = 0;
6
   while( 1 ) {
7
-    int c = getopt_long (argc, argv, "m:g:s:r:", cmdLineOptions, &optionIndex);
8
+    int c = getopt_long (argc, argv, "hvs:r:", cmdLineOptions, &optionIndex);
9
     if( c == -1 ) break;
10
     switch( c ) {
11
     case 'h':
12
@@ -141,10 +141,45 @@ void setTagsOnFrames( int argc, char* ar
13
   }
14
   
15
   
16
+  int fcount(0);
17
   while( true ) {
18
     pfs::Frame *frame = pfsio.readFrame( stdin );
19
     if( frame == NULL ) break; // No more frames
20
+    ++fcount;
21
 
22
+    if (verbose)
23
+    {
24
+      pfs::TagContainer const *tags = frame->getTags();
25
+      pfs::TagIteratorPtr tit(tags->getIterator());
26
+      if (tit->hasNext())
27
+        std::cerr << PROG_NAME ": frame " << fcount << " tags:" << std::endl;
28
+      while (tit->hasNext())
29
+      {
30
+        char const *name = tit->getNext();
31
+        std::cerr << PROG_NAME ":   " 
32
+                  << name << "=" << tags->getString(name) 
33
+                  << std::endl;
34
+      }
35
+      pfs::ChannelIteratorPtr cit(frame->getChannelIterator());
36
+      while (cit->hasNext())
37
+      {
38
+        pfs::Channel *channel = cit->getNext();
39
+        char const *cname = channel->getName();
40
+        pfs::TagContainer const *ctags = frame->getTags();
41
+        pfs::TagIteratorPtr ctit(ctags->getIterator());
42
+        //if (ctit->hasNext())
43
+        //  std::cerr << PROG_NAME ":   channel " << cname << " tags:" 
44
+        //            << std::endl;
45
+        while (ctit->hasNext())
46
+        {
47
+          char const *name = ctit->getNext();
48
+          std::cerr << PROG_NAME ":   " 
49
+                    << cname << ":" 
50
+                    << name << "=" << ctags->getString(name) 
51
+                    << std::endl;
52
+        }
53
+      }
54
+    }
55
     
56
     ListOfTags::iterator it;
57
     for( it = setTags.begin(); it != setTags.end(); it++ ) {
(-)graphics/pfstools/files/patch-src_hdrhtml_CMakeLists.txt (+13 lines)
Line 0 Link Here
1
--- src/hdrhtml/CMakeLists.txt.orig	2018-01-25 16:27:28 UTC
2
+++ src/hdrhtml/CMakeLists.txt
3
@@ -3,7 +3,9 @@ link_directories("${PROJECT_SOURCE_DIR}/
4
 
5
 add_executable(pfsouthdrhtml pfsouthdrhtml.cpp hdrhtml.cpp)
6
 target_link_libraries(pfsouthdrhtml pfs ${ImageMagick_LIBRARIES})
7
-set_target_properties(pfsouthdrhtml PROPERTIES COMPILE_FLAGS "-DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16")
8
+#set_target_properties(pfsouthdrhtml PROPERTIES COMPILE_FLAGS "-DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16")
9
+execute_process(COMMAND ${ImageMagick_EXECUTABLE_DIR}/Magick++-config --cflags OUTPUT_VARIABLE ImageMagick_CFLAGS)
10
+set_target_properties(pfsouthdrhtml PROPERTIES COMPILE_FLAGS "${ImageMagick_CFLAGS}")
11
 
12
 install (TARGETS pfsouthdrhtml DESTINATION bin)
13
 install (FILES pfsouthdrhtml.1 DESTINATION ${MAN_DIR})
(-)graphics/pfstools/files/patch-src_hdrhtml_hdrhtml.cpp (+183 lines)
Line 0 Link Here
1
--- src/hdrhtml/hdrhtml.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/hdrhtml/hdrhtml.cpp
3
@@ -27,6 +27,7 @@
4
 
5
 #include "hdrhtml.h"
6
 
7
+#include <limits>
8
 #include <algorithm>
9
 #include <math.h>
10
 #include <fstream>
11
@@ -50,6 +51,8 @@
12
 
13
 using namespace std;
14
 
15
+#define log2f(x)	((float)logf(x)/logf(2))
16
+
17
 // ================================================
18
 //        Parameters controllig the web page 
19
 // ================================================
20
@@ -96,8 +99,8 @@ public:
21
     
22
     if( min_val > max_val )             // missing min/max info
23
     {
24
-      min_val = numeric_limits<T>::max();
25
-      max_val = numeric_limits<T>::min();
26
+      min_val = std::numeric_limits<T>::max();
27
+      max_val = std::numeric_limits<T>::min();
28
 
29
       for( int k=0; k < d_size; k++ ) {
30
         if( data[k] > max_val ) max_val = data[k];
31
@@ -197,6 +200,7 @@ public:
32
     this->y_i = new float[lut_size];
33
     own_y_i = true;
34
     memcpy(this->y_i, other.y_i, lut_size * sizeof(float));
35
+    return *this;
36
   }
37
 
38
   ~UniformArrayLUT()
39
@@ -343,7 +347,7 @@ public:
40
     for( int k = 1; k < bin_n; k++ )
41
       hist.n[k] += hist.n[k-1];
42
 
43
-//    cerr << "d_size: " << d_size << "  hist.n: " << hist.n[bin_n-1] << "\n";
44
+//    std::cerr << "d_size: " << d_size << "  hist.n: " << hist.n[bin_n-1] << "\n";
45
     assert( hist.n[bin_n-1] == d_size );    
46
   }
47
 
48
@@ -363,7 +367,7 @@ public:
49
 //            Text template file utils
50
 // ================================================
51
 
52
-typedef void (*replace_callback)( ostream &out, void *user_data, const char *parameter );
53
+typedef void (*replace_callback)( std::ostream &out, void *user_data, const char *parameter );
54
 
55
 class ReplacePattern
56
 {
57
@@ -405,7 +409,7 @@ public:
58
   {
59
   }
60
   
61
-  virtual void write_replacement( ostream &out, const char *parameter = NULL )
62
+  virtual void write_replacement( std::ostream &out, const char *parameter = NULL )
63
   {
64
     if( callback != NULL )
65
       callback( out, user_data, parameter );
66
@@ -578,16 +582,16 @@ public:
67
           }
68
           len = std::string::npos;
69
         } else
70
-          len = new_pos-pos;
71
+          len = (size_t)(new_pos-pos);
72
         
73
         float value;
74
         if( len == 0 ) {
75
-          value = numeric_limits<float>::quiet_NaN();
76
+          value = std::numeric_limits<float>::quiet_NaN();
77
         } else {
78
           std::string token = line_str.substr( pos, len );
79
           const char *str_beg = token.c_str();
80
           char *str_end;
81
-//          cerr << "token: " << str_beg << "\n";
82
+//          std::cerr << "token: " << str_beg << "\n";
83
           value = strtof( str_beg, &str_end );
84
           if( str_beg == str_end ) {
85
             std::ostringstream error_message;
86
@@ -645,15 +649,15 @@ void HDRHTMLSet::add_image( int width, i
87
     basis_table.data[0][k] = log2f( basis_table.data[0][k] );
88
   
89
 // Fix zero and negative values in the image, convert to log2 space, find min and max values
90
-  float img_min = numeric_limits<float>::max();
91
-  float img_max = numeric_limits<float>::min();
92
+  float img_min = std::numeric_limits<float>::max();
93
+  float img_max = std::numeric_limits<float>::min();
94
   {
95
     float *arrays[] = { R, G, B, Y };
96
     int k;
97
 
98
     for( k = 0; k < 4; k++ ) {
99
       float *x = arrays[k];
100
-      float min_val = numeric_limits<float>::max(), max_val = numeric_limits<float>::min();
101
+      float min_val = std::numeric_limits<float>::max(), max_val = std::numeric_limits<float>::min();
102
       for( int i=0; i < pixels; i++ ) {
103
         if( x[i] < min_val && x[i] > 0)
104
           min_val = x[i];
105
@@ -743,7 +747,7 @@ void HDRHTMLSet::add_image( int width, i
106
   for( int k=1; k <= f8_stops+1; k++ ) {
107
 
108
 
109
-    float max_value = (float)numeric_limits<unsigned short>::max(); //(1<<16) -1;
110
+    float max_value = (float)std::numeric_limits<unsigned short>::max(); //(1<<16) -1;
111
 
112
     float exp_multip = log2f(1/powf( 2, l_start + k*8 ));
113
 
114
@@ -798,9 +802,9 @@ void HDRHTMLSet::add_image( int width, i
115
   
116
 }
117
 
118
-void print_image_objects( ostream &out, void *user_data, const char *parameter );
119
-void print_cf_table( ostream &out, void *user_data, const char *parameter );
120
-void print_image_htmlcode( ostream &out, void *user_data, const char *parameter );
121
+void print_image_objects( std::ostream &out, void *user_data, const char *parameter );
122
+void print_cf_table( std::ostream &out, void *user_data, const char *parameter );
123
+void print_image_htmlcode( std::ostream &out, void *user_data, const char *parameter );
124
 
125
 void HDRHTMLSet::generate_webpage( const char *page_template, const char *image_template,
126
   const char *object_output, const char *html_output)
127
@@ -854,11 +858,11 @@ void HDRHTMLSet::generate_webpage( const
128
   
129
 }
130
 
131
-void print_image_objects( ostream &out, void *user_data, const char *parameter )
132
+void print_image_objects( std::ostream &out, void *user_data, const char *parameter )
133
 {
134
   HDRHTMLSet *hdrhtml_set = (HDRHTMLSet*)user_data;
135
 
136
-  list<HDRHTMLImage>::iterator it;
137
+  std::list<HDRHTMLImage>::iterator it;
138
   for( it = hdrhtml_set->image_list.begin(); it != hdrhtml_set->image_list.end(); it++ ) {  
139
     std::string obj_name( "hdr_" );
140
     obj_name.append( it->base_name );
141
@@ -884,7 +888,7 @@ void print_image_objects( ostream &out, 
142
   
143
 }
144
 
145
-void print_image_htmlcode( ostream &out, HDRHTMLSet *hdrhtml_set, const HDRHTMLImage &it )
146
+void print_image_htmlcode( std::ostream &out, HDRHTMLSet *hdrhtml_set, const HDRHTMLImage &it )
147
 {
148
     std::string obj_name( "hdr_" );
149
     obj_name.append( it.base_name );
150
@@ -909,13 +913,13 @@ void print_image_htmlcode( ostream &out,
151
  
152
 }
153
 
154
-void print_image_htmlcode( ostream &out, void *user_data, const char *parameter )
155
+void print_image_htmlcode( std::ostream &out, void *user_data, const char *parameter )
156
 {
157
   HDRHTMLSet *hdrhtml_set = (HDRHTMLSet*)user_data;
158
 
159
   if( parameter != NULL ) {
160
 
161
-    list<HDRHTMLImage>::iterator it;
162
+    std::list<HDRHTMLImage>::iterator it;
163
     for( it = hdrhtml_set->image_list.begin(); it != hdrhtml_set->image_list.end(); it++ ) {
164
       if( it->base_name.compare( parameter ) == 0 )
165
         break;
166
@@ -927,7 +931,7 @@ void print_image_htmlcode( ostream &out,
167
     
168
   } else {
169
     
170
-    list<HDRHTMLImage>::iterator it;
171
+    std::list<HDRHTMLImage>::iterator it;
172
     for( it = hdrhtml_set->image_list.begin(); it != hdrhtml_set->image_list.end(); it++ ) {
173
       
174
       print_image_htmlcode( out, hdrhtml_set, *it );
175
@@ -937,7 +941,7 @@ void print_image_htmlcode( ostream &out,
176
   
177
 }
178
 
179
-void print_cf_table( ostream &out, void *user_data, const char *parameter )
180
+void print_cf_table( std::ostream &out, void *user_data, const char *parameter )
181
 {
182
   CSVTable *cf = (CSVTable*)user_data;
183
   
(-)graphics/pfstools/files/patch-src_octave_CMakeLists.txt (+11 lines)
Line 0 Link Here
1
--- src/octave/CMakeLists.txt.orig	2018-01-19 06:59:44 UTC
2
+++ src/octave/CMakeLists.txt
3
@@ -7,7 +7,7 @@ set(SRC_OCT pfsread pfswrite pfstransfor
4
 
5
 set(SRC_M pfsview.m pfsview_rgb.m pfsview_list.m pfs_read_rgb.m pfs_read_xyz.m pfs_read_luminance.m pfs_write_rgb.m pfssize.m pfs_open_frames.m pfs_close_frames.m)
6
 
7
-set(OCT_SCRIPTS pfsoctavelum pfsoctavergb pfsstat)
8
+set(OCT_SCRIPTS pfsoctavelum pfsoctavergb pfsstat pfssmoothresp pfsplotresp)
9
 
10
 set(CMAKE_CXXFLAGS "-cxx -largeArrayDims")
11
 set(ENV{CXXFLAGS} ${CMAKE_CXXFLAGS})
(-)graphics/pfstools/files/patch-src_octave_pfsstat (+17 lines)
Line 0 Link Here
1
--- src/octave/pfsstat.orig	2017-11-13 17:38:28 UTC
2
+++ src/octave/pfsstat
3
@@ -1,4 +1,4 @@
4
-#!/usr/bin/octave -q
5
+#!/usr/local/bin/octave-cli -qf
6
 #  
7
 # This file is a part of PFSTOOLS package.
8
 #  ---------------------------------------------------------------------- 
9
@@ -25,6 +25,8 @@
10
 #
11
 # See man page for more information
12
 
13
+pkg load signal;
14
+
15
 pin = pfsopen( "stdin" );
16
 
17
 #fprintf( stderr, "l = %d\n", length( argv ) );
(-)graphics/pfstools/files/patch-src_pfs_CMakeLists.txt (+11 lines)
Line 0 Link Here
1
--- src/pfs/CMakeLists.txt.orig	2018-01-19 06:59:44 UTC
2
+++ src/pfs/CMakeLists.txt
3
@@ -29,7 +29,7 @@ install (TARGETS pfs 
4
 
5
 #install (FILES ${CMAKE_CURRENT_BINARY_DIR}/cygpfs.dll DESTINATION bin)
6
 install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/pfs.h ${CMAKE_CURRENT_SOURCE_DIR}/array2d.h DESTINATION include/pfs)
7
-install (FILES ${CMAKE_CURRENT_BINARY_DIR}/pfs.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig)
8
+install (FILES ${CMAKE_CURRENT_BINARY_DIR}/pfs.pc DESTINATION libdata/pkgconfig)
9
 	
10
 #install (FILES pfsoutppm.1 DESTINATION ${MAN_DIR})
11
 
(-)graphics/pfstools/files/patch-src_pfs_pfs.cpp (+40 lines)
Line 0 Link Here
1
--- src/pfs/pfs.cpp.orig	2018-01-26 11:40:37 UTC
2
+++ src/pfs/pfs.cpp
3
@@ -159,6 +159,16 @@ public:
4
     }
5
     return it;
6
   }
7
+  
8
+  TagList::const_iterator findTag( const char *tagName ) const
9
+  {
10
+    size_t tagNameLen = strlen( tagName );
11
+    TagList::const_iterator it;
12
+    for( it = tagList.begin(); it != tagList.end(); it++ ) {
13
+      if( !memcmp( tagName, it->c_str(), tagNameLen ) ) break; // Found
14
+    }
15
+    return it;
16
+  }
17
 
18
   void setTag( const char *tagName, const char *tagValue )
19
   {
20
@@ -174,9 +184,9 @@ public:
21
     }
22
   }
23
 
24
-  const char *getTag( const char *tagName )
25
+  const char *getTag( const char *tagName ) const
26
   {
27
-    TagList::iterator element = findTag( tagName );
28
+    TagList::const_iterator element = findTag( tagName );
29
     if( element == tagList.end() ) return NULL;
30
 
31
     string::size_type equalSign = element->find( '=' );
32
@@ -187,7 +197,7 @@ public:
33
 
34
 
35
   //Implementation of TagContainer
36
-  const char* getString( const char *tagName )
37
+  const char* getString( const char *tagName ) const
38
   {
39
     return getTag( tagName );
40
   }
(-)graphics/pfstools/files/patch-src_pfs_pfs.h (+45 lines)
Line 0 Link Here
1
--- src/pfs/pfs.h.orig	2018-01-26 11:18:46 UTC
2
+++ src/pfs/pfs.h
3
@@ -141,12 +141,13 @@ namespace pfs
4
   class TagContainer
5
     {
6
     public:
7
+      virtual ~TagContainer() {};
8
       /**
9
        * Get a string tag of the name tagName from the TagContainer.
10
        * @param tagName name of the tag to retrieve
11
        * @return tag value or NULL if tag was not found
12
        */
13
-      virtual const char* getString( const char *tagName ) = 0;
14
+      virtual const char* getString( const char *tagName ) const = 0;
15
 
16
       /**
17
        * Set or add a string tag of the name tagName. 
18
@@ -187,6 +188,7 @@ namespace pfs
19
  */
20
   class Channel : public Array2D {
21
   public:
22
+    virtual ~Channel() {};
23
     /**
24
      * Gets width of the channel (in pixels).
25
      * This is a synonym for Array2D::getCols().
26
@@ -596,7 +598,9 @@ namespace pfs
27
        */
28
       Exception( const char* const message )
29
 	{
30
-          strcpy( msg, message );
31
+          const size_t s = sizeof(msg)/sizeof(msg[0]) - 1;
32
+          strncpy( msg, message, s );
33
+          msg[s] = '\0';
34
 	}
35
 			
36
       ~Exception() {};
37
@@ -606,7 +610,7 @@ namespace pfs
38
        *
39
        * @return text description of the cause for the exception
40
        */
41
-      const char* getMessage()
42
+      const char* getMessage() const throw()
43
         {
44
           return msg;
45
 	}
(-)graphics/pfstools/files/patch-src_pfs_pfsutils.cpp (+16 lines)
Line 0 Link Here
1
--- src/pfs/pfsutils.cpp.orig	2018-01-25 17:09:12 UTC
2
+++ src/pfs/pfsutils.cpp
3
@@ -57,7 +57,13 @@ string getColorspaceString(ColorSpace cs
4
         return "HLG YCbCr 2020";
5
     case CS_RGB2020:
6
         return "RGB2020";
7
+    case CS_YUV:
8
+        return "YUV";
9
+    case CS_Yxy:
10
+        return "Yxy";
11
+    default: ;
12
   }
13
+  return "(unknown)";
14
 }
15
 
16
 string intToString(int a){
(-)graphics/pfstools/files/patch-src_pfsglview_m__histogram.cpp (+11 lines)
Line 0 Link Here
1
--- src/pfsglview/m_histogram.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/pfsglview/m_histogram.cpp
3
@@ -176,7 +176,7 @@ void M_Histogram::drawHistogram() {
4
 
5
 	int array_pos ;
6
 	int ch = 0 ;
7
-	if(!strcmp(channel, "XYZ") == 0)
8
+	if(!(strcmp(channel, "XYZ") == 0))
9
 			switch(channel[0]) {
10
 			case 'X': ch = 1 ; break ;
11
 			case 'Y': ch = 2 ; break ;
(-)graphics/pfstools/files/patch-src_pfsview_pfsview__widget.cpp (+22 lines)
Line 0 Link Here
1
--- src/pfsview/pfsview_widget.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/pfsview/pfsview_widget.cpp
3
@@ -147,7 +147,7 @@ void PFSViewWidget::setFrame( pfs::Frame
4
     // Chose first available channel
5
     pfs::ChannelIterator *it = frame->getChannels();
6
     if( !it->hasNext() )      // TODO: failover
7
-      throw new pfs::Exception( "No channels available!" );
8
+      throw pfs::Exception( "No channels available!" );
9
     visibleChannel = it->getNext()->getName();
10
   } else if( visibleChannel != COLOR_CHANNELS ) {
11
     // Get a new pointer, as the old frame object
12
@@ -340,8 +340,8 @@ static void mapFrameToImage( pfs::Array2
13
   assert( !color || (color && B != NULL) );
14
 
15
   
16
-  float lutPixFloor[257*2];
17
-  QRgb lutPixel[257*2];
18
+  float lutPixFloor[257*2+1];
19
+  QRgb lutPixel[257*2+1];
20
   int lutSize;
21
   if( !color && ( negativeTreatment == NEGATIVE_GREEN_SCALE ||
22
         negativeTreatment == NEGATIVE_ABSOLUTE ) ) { // Handle negative numbers
(-)graphics/pfstools/files/patch-src_tmo_durand02_fastbilateral.cpp (+27 lines)
Line 0 Link Here
1
--- src/tmo/durand02/fastbilateral.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/tmo/durand02/fastbilateral.cpp
3
@@ -67,11 +67,11 @@ public:
4
   {
5
     int ox = nx;
6
     int oy = ny/2 + 1;            // saves half of the data
7
-    const int osize = ox * oy;
8
-    source =  (float*)fftwf_malloc(sizeof(float) * nx * 2 * (ny/2+1) );
9
+    const size_t osize = ox * oy;
10
+    source =  (float*)fftwf_malloc(sizeof(float) * (size_t)nx * 2 * ((size_t)ny/2+1) );
11
     freq = (fftwf_complex*) fftwf_malloc(sizeof(fftwf_complex) * osize);
12
-//    if( source == NULL || freq == NULL )
13
-    //TODO: throw exception
14
+    if( source == NULL || freq == NULL )
15
+        throw std::bad_alloc();
16
     fplan_fw = fftwf_plan_dft_r2c_2d(nx, ny, source, freq, FFTW_ESTIMATE);
17
     fplan_in = fftwf_plan_dft_c2r_2d(nx, ny, freq, source, FFTW_ESTIMATE);    
18
   }
19
@@ -101,7 +101,7 @@ public:
20
     for( x=0 ; x<ox/2 ; x++ )
21
       for( y=0 ; y<oy ; y++ )
22
       {
23
-        float d2 = x*x + y*y;
24
+        float d2 = (float)x*x + (float)y*y;
25
         float kernel = exp( -d2 / sig2 );
26
         
27
         freq[x*oy+y][0] *= kernel;
(-)graphics/pfstools/files/patch-src_tmo_fattal02_pde.cpp (+196 lines)
Line 0 Link Here
1
--- src/tmo/fattal02/pde.cpp.orig	2018-01-25 16:27:28 UTC
2
+++ src/tmo/fattal02/pde.cpp
3
@@ -72,15 +72,15 @@ using namespace std;
4
 // precision
5
 #define EPS 1.0e-12
6
 
7
-void linbcg(unsigned long n, float b[], float x[], int itol, float tol,
8
+static void linbcg(unsigned long n, float b[], float x[], int itol, float tol,
9
   int itmax, int *iter, float *err);
10
 
11
-inline float max( float a, float b )
12
+static inline float max( float a, float b )
13
 {
14
   return a > b ? a : b;
15
 }
16
 
17
-inline float min( float a, float b )
18
+static inline float min( float a, float b )
19
 {
20
   return a < b ? a : b;
21
 }
22
@@ -111,7 +111,7 @@ inline float min( float a, float b )
23
 // Full Multigrid Algorithm for solving partial differential equations
24
 //////////////////////////////////////////////////////////////////////
25
 
26
-void restrict( const pfstmo::Array2D *in, pfstmo::Array2D *out )
27
+static void restrict( const pfstmo::Array2D *in, pfstmo::Array2D *out )
28
 {
29
   const float inRows = in->getRows();
30
   const float inCols = in->getCols();
31
@@ -174,7 +174,7 @@ void restrict( const pfstmo::Array2D *in
32
 // }
33
 
34
 
35
-void prolongate( const pfstmo::Array2D *in, pfstmo::Array2D *out )
36
+static void prolongate( const pfstmo::Array2D *in, pfstmo::Array2D *out )
37
 {
38
   float dx = (float)in->getCols() / (float)out->getCols();
39
   float dy = (float)in->getRows() / (float)out->getRows();
40
@@ -218,7 +218,7 @@ void prolongate( const pfstmo::Array2D *
41
 }
42
 
43
 // to_level<from_level, from_size<to_size
44
-void prolongate_old( pfstmo::Array2D *F, pfstmo::Array2D *T )
45
+static void prolongate_old( pfstmo::Array2D *F, pfstmo::Array2D *T )
46
 {
47
 //   DEBUG_STR << "prolongate" << endl;
48
 
49
@@ -279,7 +279,7 @@ void prolongate_old( pfstmo::Array2D *F,
50
     }
51
 }
52
 
53
-void exact_sollution( pfstmo::Array2D *F, pfstmo::Array2D *U )
54
+static void exact_sollution( pfstmo::Array2D *F, pfstmo::Array2D *U )
55
 {
56
 //   DEBUG_STR << "exact sollution" << endl;
57
 
58
@@ -316,13 +316,13 @@ void exact_sollution( pfstmo::Array2D *F
59
 
60
 static int rows, cols;
61
 
62
-inline int idx( int r, int c )
63
+static inline int idx( int r, int c )
64
 {
65
   return r*cols+c+1;
66
 }
67
 
68
 // smooth u using f at level
69
-void smooth( pfstmo::Array2D *U, pfstmo::Array2D *F )
70
+static void smooth( pfstmo::Array2D *U, pfstmo::Array2D *F )
71
 {
72
 //   DEBUG_STR << "smooth" << endl;
73
   
74
@@ -371,7 +371,7 @@ void smooth( pfstmo::Array2D *U, pfstmo:
75
 //   }
76
 }
77
 
78
-void calculate_defect( pfstmo::Array2D *D, pfstmo::Array2D *U, pfstmo::Array2D *F )
79
+static void calculate_defect( pfstmo::Array2D *D, pfstmo::Array2D *U, pfstmo::Array2D *F )
80
 {
81
 //   DEBUG_STR << "calculate defect" << endl;
82
 
83
@@ -397,7 +397,7 @@ void calculate_defect( pfstmo::Array2D *
84
   
85
 }
86
 
87
-void add_correction( pfstmo::Array2D *U, pfstmo::Array2D *C )
88
+static void add_correction( pfstmo::Array2D *U, pfstmo::Array2D *C )
89
 {
90
 //   DEBUG_STR << "add_correction" << endl;
91
 
92
@@ -634,8 +634,9 @@ void solve_pde_sor( pfstmo::Array2D *F, 
93
       omega = ( n==1 && ipass==1 ? 1.0 / (1.0 - 0.5 * rjac * rjac)
94
         : 1.0 / (1.0 - 0.25 * rjac * rjac * omega));
95
     }
96
-    if( !(n%100) || n==1)
97
+    if( !(n%100) || n==1) {
98
       DEBUG_STR << "SOR:> " << n << "\tAnorm: " << anorm << "\n";
99
+    }
100
     if (anorm < EPS * anormf ) {
101
       DEBUG_STR << "SOR:> solved.\n";
102
       return;
103
@@ -648,7 +649,7 @@ void solve_pde_sor( pfstmo::Array2D *F, 
104
 
105
 //#define EPS 1.0e-14
106
 
107
-void asolve(unsigned long n, float b[], float x[], int itrnsp)
108
+static void asolve(float b[], float x[])
109
 {
110
     for( int r = 0; r < rows; r++ )
111
       for( int c = 0; c < cols; c++ ) {
112
@@ -656,7 +657,7 @@ void asolve(unsigned long n, float b[], 
113
       }
114
 }
115
 
116
-void atimes(unsigned long n, float x[], float res[], int itrnsp)
117
+static void atimes(float x[], float res[])
118
 {
119
   for( int r = 1; r < rows-1; r++ )
120
     for( int c = 1; c < cols-1; c++ ) {
121
@@ -684,7 +685,7 @@ void atimes(unsigned long n, float x[], 
122
     - 2*x[idx(rows-1,cols-1)];  
123
 }
124
 
125
-float snrm(unsigned long n, float sx[], int itol)
126
+static float snrm(unsigned long n, float sx[], int itol)
127
 {
128
 	unsigned long i,isamax;
129
 	float ans;
130
@@ -706,7 +707,7 @@ float snrm(unsigned long n, float sx[], 
131
  * Biconjugate Gradient Method
132
  * from Numerical Recipes in C
133
  */
134
-void linbcg(unsigned long n, float b[], float x[], int itol, float tol,	int itmax, int *iter, float *err)
135
+static void linbcg(unsigned long n, float b[], float x[], int itol, float tol,	int itmax, int *iter, float *err)
136
 {	
137
 	unsigned long j;
138
 	float ak,akden,bk,bkden,bknum,bnrm,dxnrm,xnrm,zm1nrm,znrm;
139
@@ -720,30 +721,30 @@ void linbcg(unsigned long n, float b[], 
140
 	zz=new float[n+1];
141
 
142
 	*iter=0;
143
-	atimes(n,x,r,0);
144
+	atimes(x,r);
145
 	for (j=1;j<=n;j++) {
146
 		r[j]=b[j]-r[j];
147
 		rr[j]=r[j];
148
 	}
149
-	atimes(n,r,rr,0);       // minimum residual
150
+	atimes(r,rr);       // minimum residual
151
         znrm=1.0;
152
 	if (itol == 1) bnrm=snrm(n,b,itol);
153
 	else if (itol == 2) {
154
-		asolve(n,b,z,0);
155
+		asolve(b,z);
156
 		bnrm=snrm(n,z,itol);
157
 	}
158
 	else if (itol == 3 || itol == 4) {
159
-		asolve(n,b,z,0);
160
+		asolve(b,z);
161
 		bnrm=snrm(n,z,itol);
162
-		asolve(n,r,z,0);
163
+		asolve(r,z);
164
 		znrm=snrm(n,z,itol);
165
 	} else printf("illegal itol in linbcg");
166
-	asolve(n,r,z,0);        
167
+	asolve(r,z);        
168
 
169
 	while (*iter <= itmax) {
170
 		++(*iter);
171
 		zm1nrm=znrm;
172
-		asolve(n,rr,zz,1);
173
+		asolve(rr,zz);
174
 		for (bknum=0.0,j=1;j<=n;j++) bknum += z[j]*rr[j];
175
 		if (*iter == 1) {
176
 			for (j=1;j<=n;j++) {
177
@@ -759,16 +760,16 @@ void linbcg(unsigned long n, float b[], 
178
 			}
179
 		}                
180
 		bkden=bknum;
181
-		atimes(n,p,z,0);
182
+		atimes(p,z);
183
 		for (akden=0.0,j=1;j<=n;j++) akden += z[j]*pp[j];
184
 		ak=bknum/akden;
185
-		atimes(n,pp,zz,1);
186
+		atimes(pp,zz);
187
 		for (j=1;j<=n;j++) {
188
 			x[j] += ak*p[j];
189
 			r[j] -= ak*z[j];
190
 			rr[j] -= ak*zz[j];
191
 		}
192
-		asolve(n,r,z,0);
193
+		asolve(r,z);
194
 		if (itol == 1 || itol == 2) {
195
 			znrm=1.0;
196
 			*err=snrm(n,r,itol)/bnrm;
(-)graphics/pfstools/files/patch-src_tmo_fattal02_tmo__fattal02.cpp (+10 lines)
Line 0 Link Here
1
--- src/tmo/fattal02/tmo_fattal02.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/tmo/fattal02/tmo_fattal02.cpp
3
@@ -105,7 +105,6 @@ void gaussianBlur( pfstmo::Array2D* I, p
4
 {
5
   int width = I->getCols();
6
   int height = I->getRows();
7
-  int size = width*height;
8
   int x,y;
9
 
10
   pfstmo::Array2D* T = new pfstmo::Array2D(width,height);
(-)graphics/pfstools/files/patch-src_tmo_ferradans11_pfstmo__ferradans11.cpp (+17 lines)
Line 0 Link Here
1
--- src/tmo/ferradans11/pfstmo_ferradans11.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/tmo/ferradans11/pfstmo_ferradans11.cpp
3
@@ -66,12 +66,13 @@ void pfstmo_ferradans11( int argc, char*
4
     
5
   static struct option cmdLineOptions[] = {
6
     { "help", no_argument, NULL, 'h' },
7
+    { "verbose", no_argument, NULL, 'v' },
8
     { "rho", required_argument, NULL, 'r' },
9
     { "inv_alpha", required_argument, NULL, 'a' },
10
     { NULL, 0, NULL, 0 }
11
   };
12
 
13
-  static const char optstring[] = "hr:a:";
14
+  static const char optstring[] = "hvr:a:";
15
     
16
   int optionIndex = 0;
17
   while( 1 ) {
(-)graphics/pfstools/files/patch-src_tmo_mantiuk06_CMakeLists.txt (+14 lines)
Line 0 Link Here
1
--- src/tmo/mantiuk06/CMakeLists.txt.orig	2018-01-25 16:09:20 UTC
2
+++ src/tmo/mantiuk06/CMakeLists.txt
3
@@ -5,6 +5,11 @@ if( NOT HAS_GETOPT )
4
 endif( NOT HAS_GETOPT )
5
 link_directories("${PROJECT_SOURCE_DIR}/src/pfs")
6
 
7
+if(OPENMP_FOUND)
8
+  set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" )
9
+  set( CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}" )
10
+endif(OPENMP_FOUND)
11
+
12
 set(TRG pfstmo_mantiuk06)
13
 add_executable(${TRG} ${TRG}.cpp contrast_domain.cpp "${GETOPT_OBJECT}")
14
 target_link_libraries(${TRG} pfs)
(-)graphics/pfstools/files/patch-src_tmo_mantiuk06_contrast__domain.cpp (+263 lines)
Line 0 Link Here
1
--- src/tmo/mantiuk06/contrast_domain.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/tmo/mantiuk06/contrast_domain.cpp
3
@@ -74,8 +74,6 @@ static void matrix_subtract(const int n,
4
 static void matrix_copy(const int n, const float* const a, float* const b);
5
 static void matrix_multiply_const(const int n, float* const a, const float val);
6
 static void matrix_divide(const int n, const float* const a, float* const b);
7
-static float* matrix_alloc(const int size);
8
-static void matrix_free(float* m);
9
 static float matrix_DotProduct(const int n, const float* const a, const float* const b);
10
 static void matrix_zero(const int n, float* const m);
11
 static void calculate_and_add_divergence(const int rows, const int cols, const float* const Gx, const float* const Gy, float* const divG);
12
@@ -317,24 +315,6 @@ static inline void matrix_divide(const i
13
 }
14
 
15
 
16
-// alloc memory for the float table
17
-static inline float* matrix_alloc(int size){
18
-
19
-  float* m = (float*)malloc(sizeof(float)*size);
20
-  if(m == NULL){
21
-    fprintf(stderr, "ERROR: malloc in matrix_alloc() (size:%d)", size);
22
-    exit(155);
23
-  }
24
-
25
-  return m;
26
-}
27
-
28
-// free memory for matrix
29
-static inline void matrix_free(float* m){
30
-  if(m != NULL)
31
-    free(m);
32
-}
33
-
34
 // multiply vector by vector (each vector should have one dimension equal to 1)
35
 static inline float matrix_DotProduct(const int n, const float* const a, const float* const b){
36
   float val = 0;
37
@@ -382,7 +362,7 @@ static inline void calculate_and_add_div
38
 // temp is a temporary matrix of size (cols, rows), assumed to already be allocated
39
 static void pyramid_calculate_divergence_sum(pyramid_t* pyramid, float* divG_sum)
40
 {
41
-  float* temp = matrix_alloc(pyramid->rows*pyramid->cols);
42
+  float* temp = new float[pyramid->rows*pyramid->cols];
43
 
44
   // Find the coarsest pyramid, and the number of pyramid levels
45
   int levels = 1;
46
@@ -426,7 +406,7 @@ static void pyramid_calculate_divergence
47
       pyramid = pyramid->prev;
48
     }
49
 
50
-  matrix_free(temp);
51
+  delete[] temp;
52
 }
53
 
54
 // calculate scale factors (Cx,Cy) for gradients (Gx,Gy)
55
@@ -495,20 +475,10 @@ static void pyramid_free(pyramid_t* pyra
56
 {
57
   while (pyramid)
58
     {
59
-      if(pyramid->Gx != NULL)
60
-	{
61
-	  free(pyramid->Gx);
62
-	  pyramid->Gx = NULL;
63
-	}
64
-      if(pyramid->Gy != NULL)
65
-	{
66
-	  free(pyramid->Gy);
67
-	  pyramid->Gy = NULL;
68
-	}
69
+      delete[] pyramid->Gx;
70
+      delete[] pyramid->Gy;
71
       pyramid_t* const next = pyramid->next;
72
-      pyramid->prev = NULL;
73
-      pyramid->next = NULL;
74
-      free(pyramid);
75
+      delete pyramid;
76
       pyramid = next;
77
     }			
78
 }
79
@@ -523,19 +493,14 @@ static pyramid_t * pyramid_allocate(int 
80
 
81
   while(rows >= PYRAMID_MIN_PIXELS && cols >= PYRAMID_MIN_PIXELS)
82
     {
83
-      level = (pyramid_t *) malloc(sizeof(pyramid_t));
84
-      if(level == NULL)
85
-	{
86
-	  fprintf(stderr, "ERROR: malloc in pyramid_alloc() (size:%d)", (int)sizeof(pyramid_t));
87
-	  exit(155);
88
-	}
89
+      level = new pyramid_t;
90
       memset( level, 0, sizeof(pyramid_t) );
91
       
92
       level->rows = rows;
93
       level->cols = cols;
94
       const int size = level->rows * level->cols;
95
-      level->Gx = matrix_alloc(size);
96
-      level->Gy = matrix_alloc(size);
97
+      level->Gx = new float[size];
98
+      level->Gy = new float[size];
99
       
100
       level->prev = prev;
101
       if(prev != NULL)
102
@@ -598,7 +563,7 @@ static void dump_matrix_to_file(const in
103
 // lum_temp gets overwritten!
104
 static void pyramid_calculate_gradient(pyramid_t* pyramid, float* lum_temp)
105
 {
106
-  float* temp = matrix_alloc((pyramid->rows/2)*(pyramid->cols/2));
107
+  float* temp = new float[(pyramid->rows/2)*(pyramid->cols/2)];
108
   float* const temp_saved = temp;
109
 
110
   calculate_gradient(pyramid->cols, pyramid->rows, lum_temp, pyramid->Gx, pyramid->Gy);	
111
@@ -626,7 +591,7 @@ static void pyramid_calculate_gradient(p
112
       pyramid = pyramid->next;
113
   }
114
 
115
-  matrix_free(temp_saved);
116
+  delete[] temp_saved;
117
 }
118
 
119
 
120
@@ -658,13 +623,13 @@ static void linbcg(pyramid_t* pyramid, p
121
   const int n = rows*cols;
122
   const float tol2 = tol*tol;
123
 	
124
-  float* const z = matrix_alloc(n);
125
-  float* const zz = matrix_alloc(n);
126
-  float* const p = matrix_alloc(n);
127
-  float* const pp = matrix_alloc(n);
128
-  float* const r = matrix_alloc(n);
129
-  float* const rr = matrix_alloc(n);	
130
-  float* const x_save = matrix_alloc(n);	
131
+  float* const z = new float[n];
132
+  float* const zz = new float[n];
133
+  float* const p = new float[n];
134
+  float* const pp = new float[n];
135
+  float* const r = new float[n];
136
+  float* const rr = new float[n];	
137
+  float* const x_save = new float[n];	
138
 	
139
   const float bnrm2 = matrix_DotProduct(n, b, b);
140
 	
141
@@ -799,13 +764,13 @@ static void linbcg(pyramid_t* pyramid, p
142
     progress_cb(100);
143
     
144
   
145
-  matrix_free(x_save);
146
-  matrix_free(p);
147
-  matrix_free(pp);
148
-  matrix_free(z);
149
-  matrix_free(zz);
150
-  matrix_free(r);
151
-  matrix_free(rr);
152
+  delete[] x_save;
153
+  delete[] p;
154
+  delete[] pp;
155
+  delete[] z;
156
+  delete[] zz;
157
+  delete[] r;
158
+  delete[] rr;
159
 }
160
 
161
 
162
@@ -818,10 +783,10 @@ static void lincg(pyramid_t* pyramid, py
163
   const int n = rows*cols;
164
   const float tol2 = tol*tol;
165
 	
166
-  float* const x_save = matrix_alloc(n);
167
-  float* const r = matrix_alloc(n);
168
-  float* const p = matrix_alloc(n);
169
-  float* const Ap = matrix_alloc(n);	
170
+  float* const x_save = new float[n];
171
+  float* const r = new float[n];
172
+  float* const p = new float[n];
173
+  float* const Ap = new float[n];	
174
 	
175
   // bnrm2 = ||b||
176
   const float bnrm2 = matrix_DotProduct(n, b, b);
177
@@ -943,10 +908,10 @@ static void lincg(pyramid_t* pyramid, py
178
   else if (progress_cb != NULL)
179
     progress_cb(100);
180
     
181
-  matrix_free(x_save);
182
-  matrix_free(p);
183
-  matrix_free(Ap);
184
-  matrix_free(r);
185
+  delete[] x_save;
186
+  delete[] p;
187
+  delete[] Ap;
188
+  delete[] r;
189
 }
190
 
191
 
192
@@ -1070,7 +1035,7 @@ static void transform_to_luminance(pyram
193
   pyramid_calculate_scale_factor(pp, pC); // calculate (Cx,Cy)
194
   pyramid_scale_gradient(pp, pC); // scale small gradients by (Cx,Cy);
195
 
196
-  float* b = matrix_alloc(pp->cols * pp->rows);
197
+  float* b = new float[pp->cols * pp->rows];
198
   pyramid_calculate_divergence_sum(pp, b); // calculate the sum of divergences (equal to b)
199
   
200
   // calculate luminances from gradients
201
@@ -1079,7 +1044,7 @@ static void transform_to_luminance(pyram
202
   else
203
     lincg(pp, pC, b, x, itmax, tol, progress_cb);
204
   
205
-  matrix_free(b);
206
+  delete[] b;
207
   pyramid_free(pC);
208
 }
209
 
210
@@ -1121,12 +1086,7 @@ static void contrast_equalization( pyram
211
     }
212
   
213
   // Allocate memory
214
-  struct hist_data* hist = (struct hist_data*) malloc(sizeof(struct hist_data) * total_pixels);
215
-  if (hist == NULL)
216
-    {
217
-      fprintf(stderr, "ERROR: malloc in contrast_equalization() (size:%d)", (int)sizeof(struct hist_data) * total_pixels);
218
-      exit(155);
219
-    }
220
+  struct hist_data* hist = new hist_data[total_pixels];
221
     
222
   // Build histogram info
223
   l = pp;
224
@@ -1175,7 +1135,7 @@ static void contrast_equalization( pyram
225
     l = l->next;
226
   }
227
 
228
-  free(hist);
229
+  delete[] hist;
230
 }
231
 
232
 
233
@@ -1211,10 +1171,10 @@ int tmo_mantiuk06_contmap(const int c, c
234
     }
235
 	
236
   pyramid_t* pp = pyramid_allocate(c,r); // create pyramid
237
-  float* tY = matrix_alloc(n);
238
+  float* tY = new float[n];
239
   matrix_copy(n, Y, tY); // copy Y to tY
240
   pyramid_calculate_gradient(pp,tY); // calculate gradients for pyramid, destroys tY
241
-  matrix_free(tY);
242
+  delete[] tY;
243
   pyramid_transform_to_R(pp); // transform gradients to R
244
 
245
   /* Contrast map */
246
@@ -1228,7 +1188,7 @@ int tmo_mantiuk06_contmap(const int c, c
247
   pyramid_free(pp);
248
 
249
   /* Renormalize luminance */
250
-  float* temp = matrix_alloc(n);
251
+  float* temp = new float[n];
252
 	
253
   matrix_copy(n, Y, temp); // copy Y to temp
254
   qsort(temp, n, sizeof(float), sort_float); // sort temp in ascending order
255
@@ -1244,7 +1204,7 @@ int tmo_mantiuk06_contmap(const int c, c
256
   delta = trim - floorf(trim);
257
   const float l_max = temp[(int)floorf(trim)] * delta + temp[(int)ceilf(trim)] * (1.0f-delta);	
258
 	
259
-  matrix_free(temp);
260
+  delete[] temp;
261
 	
262
   const float disp_dyn_range = 2.3f;
263
 #pragma omp parallel for schedule(static)
(-)graphics/pfstools/files/patch-src_tmo_mantiuk06_pfstmo__mantiuk06.cpp (+17 lines)
Line 0 Link Here
1
--- src/tmo/mantiuk06/pfstmo_mantiuk06.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/tmo/mantiuk06/pfstmo_mantiuk06.cpp
3
@@ -219,6 +219,14 @@ int main( int argc, char* argv[] )
4
   try {
5
     tmo_mantiuk06( argc, argv );
6
   }
7
+  catch (std::bad_alloc ex) {
8
+    fprintf(stderr, PROG_NAME " error: out of memory\n");
9
+    return EXIT_FAILURE;
10
+  }
11
+  catch (std::exception ex) {
12
+    fprintf(stderr, PROG_NAME " error: %s\n", ex.what());
13
+    return EXIT_FAILURE;
14
+  }
15
   catch( pfs::Exception ex ) {
16
     fprintf( stderr, PROG_NAME " error: %s\n", ex.getMessage() );
17
     return EXIT_FAILURE;
(-)graphics/pfstools/files/patch-src_tmo_mantiuk08_display__adaptive__tmo.cpp (+86 lines)
Line 0 Link Here
1
--- src/tmo/mantiuk08/display_adaptive_tmo.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/tmo/mantiuk08/display_adaptive_tmo.cpp
3
@@ -36,6 +36,9 @@
4
 #include <memory.h>
5
 #include <assert.h>
6
 #include <memory>
7
+#include <vector>
8
+
9
+#include <pfs.h>
10
 
11
 #include "display_adaptive_tmo.h"
12
 
13
@@ -158,12 +161,16 @@ public:
14
     }
15
   }
16
 
17
-  UniformArrayLUT() : x_i( 0 ), y_i(0), lut_size( 0 ), delta( 0. ) {}
18
+  UniformArrayLUT() : x_i(0), own_y_i(false), y_i(0), lut_size(0), delta(0.) {}
19
 
20
   UniformArrayLUT(const UniformArrayLUT& other) : x_i( other.x_i ), lut_size( other.lut_size ), delta( other.delta )
21
   {
22
      this->y_i = new double[lut_size];
23
      own_y_i = true;
24
+     if (!other.y_i)
25
+     {
26
+       throw pfs::Exception("UniformArrayLUT copy constructor: source y_i is uninitialized");
27
+     }
28
      memcpy(this->y_i, other.y_i, lut_size * sizeof(double));
29
   }
30
 
31
@@ -172,6 +179,10 @@ public:
32
          this->lut_size = other.lut_size;
33
          this->delta = other.delta;
34
          this->x_i = other.x_i;
35
+         if (!other.y_i)
36
+         {
37
+           throw pfs::Exception("UniformArrayLUT = operator: source y_i is uninitialized");
38
+         }
39
 	 this->y_i = new double[lut_size];
40
 	 own_y_i = true;
41
 	 memcpy(this->y_i, other.y_i, lut_size * sizeof(double));
42
@@ -203,7 +214,7 @@ public:
43
   
44
 };
45
 
46
-#define PFSEOL "\x0a"
47
+/*#define PFSEOL "\x0a"
48
 static void dumpPFS( const char *fileName, const int width, const int height, float *data, const char *channelName )
49
 {
50
   FILE *fh = fopen( fileName, "wb" );
51
@@ -218,7 +229,7 @@ static void dumpPFS( const char *fileNam
52
     }
53
   
54
   fclose( fh );
55
-}
56
+}*/
57
 
58
 
59
 void compute_gaussian_level( const int width, const int height, const pfstmo::Array2D& in, pfstmo::Array2D& out, int level, pfstmo::Array2D& temp )
60
@@ -594,7 +605,7 @@ double contrast_transducer_kulikowski( d
61
     float Mt = std::min( 0.99, 1./sensitivity ); // threshold as Michelson contrast
62
     float Gt = 0.5 * log10( (Mt+1)/(1-Mt) ); // threshold as log contrast
63
 
64
-    return sign(C) * powf( abs(C)-Gt+1, 0.5 );
65
+    return sign(C) * powf( fabs(C)-Gt+1, 0.5 );
66
   } else {
67
     return C * sensitivity;    
68
   }  
69
@@ -748,7 +759,7 @@ int optimize_tonecurve( datmoConditional
70
   double d_dr = log10( dm->display( 1.f )/dm->display( 0.f ) ); // display dynamic range
71
 
72
   // Create LUTs for CSF to speed up computations
73
-  UniformArrayLUT *csf_lut = new UniformArrayLUT[C->f_count];
74
+  std::vector<UniformArrayLUT> csf_lut(C->f_count);
75
   for( int f = 0; f < C->f_count; f++ ) {
76
     csf_lut[f] = UniformArrayLUT( C->x_count, C->x_scale );
77
     for( int i=0; i < C->x_count; i++ )
78
@@ -1005,7 +1016,7 @@ int optimize_tonecurve( datmoConditional
79
 
80
   compute_y( y, x, skip_lut, C->x_count, L, dm->display(0), dm->display(1) );
81
 
82
-  delete [] csf_lut;
83
+  //delete [] csf_lut;
84
 
85
   return PFSTMO_OK;
86
 }
(-)graphics/pfstools/files/patch-src_tmo_mantiuk08_pfstmo__mantiuk08.cpp (+45 lines)
Line 0 Link Here
1
--- src/tmo/mantiuk08/pfstmo_mantiuk08.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/tmo/mantiuk08/pfstmo_mantiuk08.cpp
3
@@ -31,7 +31,6 @@
4
 
5
 #include <config.h>
6
 
7
-#include <iostream>
8
 #include <stdio.h>
9
 #include <stdlib.h>
10
 #include <math.h>
11
@@ -395,16 +394,28 @@ bool read_tone_curve( FILE *fh, datmoTon
12
 
13
 
14
 
15
-int main( int argc, char* argv[] )
16
+int main(int argc, char* argv[])
17
 {
18
   try {
19
-    tmo_mantiuk08( argc, argv );
20
+    tmo_mantiuk08(argc, argv);
21
   }
22
-  catch( pfs::Exception ex ) {
23
-    fprintf( stderr, PROG_NAME " error: %s\n", ex.getMessage() );
24
+  catch (const std::bad_alloc &ex) {
25
+    fprintf(stderr, PROG_NAME " error: out of memory (%s)\n", ex.what());
26
     return EXIT_FAILURE;
27
-  }        
28
-  catch( QuietException  ex ) {
29
+  }
30
+  catch (const std::exception &ex) {
31
+    fprintf(stderr, PROG_NAME " error: %s\n", ex.what());
32
+    return EXIT_FAILURE;
33
+  }
34
+  catch (const pfs::Exception &ex) {
35
+    fprintf(stderr, PROG_NAME " error: %s\n", ex.getMessage());
36
+    return EXIT_FAILURE;
37
+  }
38
+  catch (const QuietException &) {
39
+    return EXIT_FAILURE;
40
+  }
41
+  catch (...) {
42
+    fprintf(stderr, PROG_NAME " something wrong...\n");
43
     return EXIT_FAILURE;
44
   }        
45
   return EXIT_SUCCESS;
(-)graphics/pfstools/files/patch-src_tmo_reinhard02_approx.cpp (+223 lines)
Line 0 Link Here
1
--- src/tmo/reinhard02/approx.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/tmo/reinhard02/approx.cpp
3
@@ -17,36 +17,36 @@
4
 #include <stdio.h>
5
 #include <math.h>
6
 
7
+#include <pfstmo.h>
8
+
9
 // interpolated version of approximation (always use this one!) (:krawczyk)
10
 #define INTERPOLATED
11
 
12
-extern double **luminance; 
13
-int      ImageWidth, ImageHeight;
14
+extern pfstmo::Array2D *lum;
15
+extern int             width, height;
16
 
17
-double ***Pyramid;
18
-int       PyramidHeight;
19
-int       PyramidWidth0;
20
+int PyramidHeight;
21
 
22
-void build_pyramid( double **luminance, int ImageWidth, int ImageHeight );
23
-double V1( int x, int y, int level );
24
+static float ***Pyramid;
25
+static int   PyramidWidth0;
26
 
27
-int div2( const unsigned int n )
28
+static int div2( const unsigned int n )
29
 {
30
   const int q = n/2;
31
   return(2*q < n ? q + 1 : q);
32
 }
33
 
34
-double pyramid_lookup( int x, int y, int level )
35
+static float pyramid_lookup( int x, int y, int level )
36
   /* PRE:  */
37
 {
38
   int n, s;
39
   
40
   /* Level 0 is a special case, the value is just the image */
41
   if (level == 0) {
42
-    if ( (x < 0) || (y < 0) || (x >= ImageWidth) || (y >= ImageHeight) )
43
+    if ( (x < 0) || (y < 0) || (x >= width) || (y >= height) )
44
       return(0.0);
45
     else
46
-      return(luminance[y][x]);
47
+      return((*lum)(x,y));
48
   }
49
 
50
   /* Compute the size of the slice */
51
@@ -58,25 +58,24 @@ double pyramid_lookup( int x, int y, int
52
   //y = y >> level;
53
 
54
   if ( (x < 0) || (y < 0) || (x >= s) || (y >= s) )
55
-    return(0.0);
56
+    return(0.0f);
57
   else
58
     return(Pyramid[level][y][x]);
59
 }
60
 
61
-void build_pyramid( double **luminance, int image_width, int image_height )
62
+void build_pyramid()
63
 {
64
   int k;
65
   int x, y;
66
   int i, j;
67
-  int width, height;
68
   int max_dim;
69
-  int pyramid_height;
70
-  double sum = 0;
71
+  int pyramid_width;
72
+  double sum = 0.f;
73
   
74
-  double a = 0.4;
75
-  double b = 0.25;
76
-  double c = b - a/2;
77
-  double w[5];
78
+  float a = 0.4f;
79
+  float b = 0.25f;
80
+  float c = b - a/2.f;
81
+  float w[5];
82
 
83
   /* Compute the "filter kernel" */
84
   w[0] = c;
85
@@ -90,50 +89,35 @@ void build_pyramid( double **luminance, 
86
   /* For simplicity, the first level is padded to a square whose side is a */
87
   /* power of two.                                                         */
88
 
89
-  ImageWidth = image_width;
90
-  ImageHeight = image_height;
91
-  
92
   /* Compute the size of the Pyramid array */
93
-  max_dim = (ImageHeight > ImageWidth ? ImageHeight : ImageWidth);
94
-  PyramidHeight = (int) floor(log(max_dim - 0.5)/log(2)) + 1;
95
+  max_dim = (height > width ? height : width);
96
+  PyramidHeight = (int)floorf(logf(max_dim - 0.5f)/logf(2)) + 1;
97
 
98
   /* Compute the dimensions of the first level */
99
-  width = 1 << (PyramidHeight - 1);
100
-  PyramidWidth0 = width;
101
+  pyramid_width = 1 << (PyramidHeight - 1);
102
+  PyramidWidth0 = pyramid_width;
103
 
104
 //  fprintf(stderr, "max_dim %d   height %d\n", max_dim, PyramidHeight);
105
   
106
   /* Allocate the outer Pyramid array */
107
-  Pyramid = (double***) calloc(PyramidHeight, sizeof(double**));
108
-  if (!Pyramid) {
109
-    fprintf(stderr, "Unable to allocate pyramid array.\n");
110
-    exit(1);
111
-  }
112
+  Pyramid = new float**[PyramidHeight];
113
 
114
   /* Allocate and assign the Pyramid slices */
115
   k = 0;
116
   
117
-  while (width) {
118
+  while (pyramid_width) {
119
 
120
 //    fprintf(stderr, "level %d, width = %d\n", k, width);
121
     
122
     /* Allocate the slice */
123
-    Pyramid[k] = (double**) calloc(width, sizeof(double*));
124
-    if (!Pyramid[k]) {
125
-      fprintf(stderr, "Unable to allocate pyramid array.\n");
126
-      exit(1);
127
-    }
128
-    for (y = 0; y < width; y++) {
129
-      Pyramid[k][y] = (double*) calloc(width, sizeof(double));
130
-      if (!Pyramid[k][y]) {
131
-        fprintf(stderr, "Unable to allocate pyramid array.\n");
132
-        exit(1);
133
-      }
134
+    Pyramid[k] = new float*[pyramid_width];
135
+    for (y = 0; y < pyramid_width; y++) {
136
+      Pyramid[k][y] = new float[pyramid_width];
137
     }
138
 
139
     /* Compute the values in the slice */
140
-    for (y = 0; y < width; y++) {
141
-      for (x = 0; x < width; x++) {
142
+    for (y = 0; y < pyramid_width; y++) {
143
+      for (x = 0; x < pyramid_width; x++) {
144
 
145
         sum = 0;
146
         for (i = 0; i < 5; i++) {
147
@@ -146,7 +130,7 @@ void build_pyramid( double **luminance, 
148
     }
149
 
150
     /* compute the width of the next slice */
151
-    width /= 2;
152
+    pyramid_width /= 2;
153
     k++;
154
   }
155
 }
156
@@ -154,27 +138,27 @@ void build_pyramid( double **luminance, 
157
 void clean_pyramid()
158
 {
159
   int k=0;
160
-  int width = PyramidWidth0;
161
-  while(width)
162
+  int pyramid_width = PyramidWidth0;
163
+  while(pyramid_width)
164
   {
165
-    for( int y=0 ; y<width ; y++ )
166
-      free(Pyramid[k][y]);
167
-    free(Pyramid[k]);
168
+    for( int y=0 ; y<pyramid_width ; y++ )
169
+      delete[] Pyramid[k][y];
170
+    delete[] Pyramid[k];
171
     k++;
172
-    width /= 2;
173
+    pyramid_width /= 2;
174
   }
175
-  free(Pyramid);
176
+  delete[] Pyramid;
177
 }
178
 
179
 #ifndef INTERPOLATED
180
-double V1( int x, int y, int level )
181
+float V1( int x, int y, int level )
182
   /* PRE:  */
183
 {
184
   int n, s;
185
 
186
   /* Level 0 is a special case, the value is just the image */
187
   if (level <= 0)
188
-      return(luminance[y][x]);
189
+      return((*lum)(x,y));
190
 
191
   /* Compute the size of the slice */
192
   
193
@@ -184,16 +168,16 @@ double V1( int x, int y, int level )
194
   return(Pyramid[level-1][y][x]);
195
 }
196
 #else
197
-double V1( int x, int y, int level )
198
+float V1( int x, int y, int level )
199
   /* PRE:  */
200
 {
201
   int x0, y0;
202
   int l, size;
203
-  double s, t;
204
+  float s, t;
205
   
206
   /* Level 0 is a special case, the value is just the image */
207
   if (level == 0)
208
-      return(luminance[y][x]);
209
+      return((*lum)(x,y));
210
 
211
   /* Compute the size of the slice */
212
   l = 1 << level;
213
@@ -204,8 +188,8 @@ double V1( int x, int y, int level )
214
   x0 = (x0 >= size ? size - 1 : x0);
215
   y0 = (y0 >= size ? size - 1 : y0);
216
   
217
-  s = (double)(x - x0*l)/(double)l;
218
-  t = (double)(y - y0*l)/(double)l;
219
+  s = (float)(x - x0*l)/(float)l;
220
+  t = (float)(y - y0*l)/(float)l;
221
   
222
   level--;
223
 
(-)graphics/pfstools/files/patch-src_tmo_reinhard02_pfstmo__reinhard02.1 (+63 lines)
Line 0 Link Here
1
--- src/tmo/reinhard02/pfstmo_reinhard02.1.orig	2018-01-19 06:59:44 UTC
2
+++ src/tmo/reinhard02/pfstmo_reinhard02.1
3
@@ -6,6 +6,7 @@ pfstmo_reinhard02 \- Photographic Tone R
4
 [--scales] [--key <val>] [--phi <val>]
5
 [--range <val>] [--lower <val>] [--upper <val>]
6
 [--temporal-coherent]
7
+[--border <val>]
8
 [--verbose] [--help]
9
 .SH DESCRIPTION
10
 This command implements a tone mapping operator as described in:
11
@@ -17,32 +18,32 @@ In ACM Transactions on Graphics, 2002.
12
 According to the paper, results of this TMO require gamma correction.
13
 .SH OPTIONS
14
 .TP
15
-[--scales] 
16
+[--scales] [-s]
17
 
18
 Use scales to calculate local adaptation. That means: use local
19
 version of this operator. By default, global version is used.
20
 .TP
21
-[--key <val>] 
22
+[--key <val>] [-k <val>]
23
 
24
 Set key value for the image (refer to paper for details).
25
 Default value: 0.18, accepted range <0..1>.
26
 .TP
27
-[--phi <val>]
28
+[--phi <val>] [-p <val>]
29
 
30
 Set phi value (refer to paper for details).
31
 Default value: 1.0, accepted range >=0.0.
32
 .TP
33
-[--range <val>] 
34
+[--range <val>] [-r <val>]
35
 
36
 Set range size (refer to paper for details).
37
 Default value: 8, accepted range >1.
38
 .TP
39
-[--lower <val>] 
40
+[--lower <val>] [-l <val>]
41
 
42
 Set lower scale size (refer to paper for details).
43
 Default value: 1, accepted range >=1.
44
 .TP
45
-[--upper <val>]
46
+[--upper <val>] [-u <val>]
47
 
48
 Set upper scale size (refer to paper for details).
49
 Default value: 43, accepted range >=1.
50
@@ -54,6 +55,13 @@ sequences. Currently the option imposes 
51
 luminance value can change at most by 1% between two consecutive
52
 frames.
53
 .TP
54
+[--border <val>] [-b <val>]
55
+
56
+Use border mechanism with specified relative border width.
57
+Actual border size will be calculated as the minimal size of the image
58
+(width or height) multiplied on relative border width.
59
+Default value: 0 (don't use border mechanism), accepted range: 0 >= b < 0.5.
60
+.TP
61
 --verbose
62
 
63
 Print additional information during program execution.
(-)graphics/pfstools/files/patch-src_tmo_reinhard02_pfstmo__reinhard02.cpp (+139 lines)
Line 0 Link Here
1
--- src/tmo/reinhard02/pfstmo_reinhard02.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/tmo/reinhard02/pfstmo_reinhard02.cpp
3
@@ -33,6 +33,7 @@
4
 
5
 #include <config.h>
6
 
7
+#include <exception>
8
 #include <iostream>
9
 #include <stdio.h>
10
 #include <stdlib.h>
11
@@ -40,6 +41,7 @@
12
 #include <math.h>
13
 
14
 #include <pfs.h>
15
+#include <pfstmo.h>
16
 
17
 #include "tmo_reinhard02.h"
18
 
19
@@ -61,6 +63,7 @@ void printHelp()
20
     "\t[--key <val>] [--phi <val>] \n"
21
     "\t[--range <val>] [--lower <val>] [--upper <val>] \n"
22
     "\t[--temporal-coherent]\n"
23
+    "\t[--border <val>] \n"
24
     "\t[--verbose] [--help] \n"
25
     "See man page for more information.\n" );
26
 }
27
@@ -77,6 +80,7 @@ void pfstmo_reinhard02( int argc, char* 
28
   int high = 43;
29
   bool use_scales = false;
30
   bool temporal_coherent = false;  
31
+  float border = 0.f;
32
 
33
   static struct option cmdLineOptions[] = {
34
     { "help", no_argument, NULL, 'h' },
35
@@ -88,12 +92,13 @@ void pfstmo_reinhard02( int argc, char* 
36
     { "lower", required_argument, NULL, 'l' },
37
     { "upper", required_argument, NULL, 'u' },
38
     { "temporal-coherent", no_argument, NULL, 't' },
39
+    { "border", required_argument, NULL, 'b' },
40
     { NULL, 0, NULL, 0 }
41
   };
42
 
43
   int optionIndex = 0;
44
   while( 1 ) {
45
-    int c = getopt_long (argc, argv, "hvsk:p:r:l:u:t", cmdLineOptions, &optionIndex);
46
+    int c = getopt_long (argc, argv, "hvsk:p:r:l:u:tb:", cmdLineOptions, &optionIndex);
47
     if( c == -1 ) break;
48
     switch( c ) {
49
     case 'h':
50
@@ -133,6 +138,11 @@ void pfstmo_reinhard02( int argc, char* 
51
     case 't':
52
       temporal_coherent = true;
53
       break;
54
+    case 'b':
55
+      border = (float)strtod( optarg, NULL );
56
+      if( border<0.0f || border>=0.5f )
57
+        throw pfs::Exception("border width value out of range, should be >=0 and <0.5");
58
+      break;
59
     case '?':
60
       throw QuietException();
61
     case ':':
62
@@ -140,17 +150,23 @@ void pfstmo_reinhard02( int argc, char* 
63
     }
64
   }
65
 
66
-  VERBOSE_STR << "use scales: " << (use_scales ? "yes" : "no" ) << endl;
67
   VERBOSE_STR << "key value: " << key << endl;
68
-  VERBOSE_STR << "phi value: " << phi << endl;
69
+  VERBOSE_STR << "use scales: " << (use_scales ? "yes" : "no" ) << endl;
70
   if( use_scales )
71
   {
72
-    VERBOSE_STR << "number of scales: " << num << endl;
73
-    VERBOSE_STR << "lower scale size: " << low << endl;
74
-    VERBOSE_STR << "upper scale size: " << high << endl;
75
 #ifndef HAVE_ZFFT
76
     VERBOSE_STR << "approximate implementation of scales" << endl;
77
 #endif
78
+    VERBOSE_STR << "number of scales: " << num << endl;
79
+    VERBOSE_STR << "lower scale size: " << low << endl;
80
+    VERBOSE_STR << "upper scale size: " << high << endl;
81
+    VERBOSE_STR << "phi value: " << phi << endl;
82
+  }
83
+  VERBOSE_STR << "temporal coherent: " << (temporal_coherent ? "yes" : "no" ) << endl;
84
+  VERBOSE_STR << "use border: " << (border>0.f ? "yes" : "no" ) << endl;
85
+  if( border>0.f )
86
+  {
87
+    VERBOSE_STR << "border width: " << border << endl;
88
   }
89
 
90
   while( true ) 
91
@@ -169,21 +185,19 @@ void pfstmo_reinhard02( int argc, char* 
92
     // tone mapping
93
     int w = Y->getCols();
94
     int h = Y->getRows();
95
-    pfs::Array2DImpl* L = new pfs::Array2DImpl(w,h);
96
-
97
-    tmo_reinhard02( w, h, Y->getRawData(), L->getRawData(), use_scales, key, phi, num, low, high, temporal_coherent );
98
+    const pfstmo::Array2D ay(w, h, const_cast<float*>(Y->getRawData()));
99
+    pfstmo::Array2D al(w,h);
100
+    tmo_reinhard02( &ay, &al, use_scales, key, phi, num, low, high, temporal_coherent, border );
101
 
102
     for( int x=0 ; x<w ; x++ )
103
       for( int y=0 ; y<h ; y++ )
104
       {
105
-        float scale = (*L)(x,y) / (*Y)(x,y);
106
+        float scale = al(x,y) / ay(x,y);
107
         (*Y)(x,y) *= scale;
108
         (*X)(x,y) *= scale;
109
         (*Z)(x,y) *= scale;
110
       }
111
 
112
-    delete L;
113
-
114
     //---
115
     pfsio.writeFrame( frame, stdout );
116
     pfsio.freeFrame( frame );        
117
@@ -195,11 +209,19 @@ int main( int argc, char* argv[] )
118
   try {
119
     pfstmo_reinhard02( argc, argv );
120
   }
121
-  catch( pfs::Exception ex ) {
122
-    fprintf( stderr, PROG_NAME " error: %s\n", ex.getMessage() );
123
+  catch (std::bad_alloc ex) {
124
+    fprintf(stderr, PROG_NAME " error: out of memory\n");
125
     return EXIT_FAILURE;
126
   }        
127
-  catch( QuietException  ex ) {
128
+  catch (std::exception ex) {
129
+    fprintf(stderr, PROG_NAME " error: %s\n", ex.what());
130
+    return EXIT_FAILURE;
131
+  }        
132
+  catch (pfs::Exception ex) {
133
+    fprintf(stderr, PROG_NAME " error: %s\n", ex.getMessage());
134
+    return EXIT_FAILURE;
135
+  }        
136
+  catch (QuietException  ex) {
137
     return EXIT_FAILURE;
138
   }        
139
   return EXIT_SUCCESS;
(-)graphics/pfstools/files/patch-src_tmo_reinhard02_tmo__reinhard02.cpp (+722 lines)
Line 0 Link Here
1
--- src/tmo/reinhard02/tmo_reinhard02.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/tmo/reinhard02/tmo_reinhard02.cpp
3
@@ -17,11 +17,12 @@
4
 
5
 #include <config.h>
6
 
7
+#include <memory>
8
 #include <stdlib.h>
9
 #include <stdio.h>
10
 #include <math.h>
11
 
12
-#include "pfstmo.h"
13
+#include <pfstmo.h>
14
 
15
 #ifdef HAVE_ZFFT
16
 #include <fft.h>
17
@@ -30,53 +31,44 @@
18
 #define APPROXIMATE
19
 #endif
20
 
21
-//--- from defines.h
22
-typedef struct {
23
-  int     xmax, ymax;     /* image dimensions */
24
-} CVTS;
25
-
26
-typedef double  COLOR[3];       /* red, green, blue (or X,Y,Z) */
27
-//--- end of defines.h
28
 
29
+static int                      scale;
30
+static float                    sigma_0, sigma_1;
31
+static pfstmo::Array2D          *img = 0;
32
+pfstmo::Array2D                 *lum = 0;
33
+int                             width, height;
34
 
35
-static int       width, height, scale;
36
-static COLOR   **image;
37
-static double ***convolved_image;
38
-static double    sigma_0, sigma_1;
39
-double         **luminance;
40
-
41
-static double    k                = 1. / (2. * 1.4142136);
42
-static double    key              = 0.18;
43
-static double    threshold        = 0.05;
44
-static double    phi              = 8.;
45
-static double    white            = 1e20;
46
-static int       scale_low        = 1;
47
-static int       scale_high       = 43;  // 1.6^8 = 43
48
-static int       range            = 8;
49
-static int       use_scales       = 0;
50
-static int       use_border       = 0;
51
-static CVTS      cvts             = {0, 0};
52
+static float    k               = 1.f / (2.f * 1.4142136f);
53
+static float    key             = 0.18f;
54
+static float    threshold       = 0.05f;
55
+static float    phi             = 8.f;
56
+static float    white           = 1e20f;
57
+static int      scale_low       = 1;
58
+static int      scale_high      = 43;  // 1.6^8 = 43
59
+static int      range           = 8;
60
+static int      use_scales      = 0;
61
+static float    border          = 0.f;
62
 
63
 static bool temporal_coherent;
64
 
65
 #ifdef APPROXIMATE
66
 extern int PyramidHeight; // set by build_pyramid, defines actual pyramid size
67
-extern double V1 (int x, int y, int level);
68
-extern void build_pyramid (double **luminance, int image_width, int image_height);
69
-extern void clean_pyramid ();
70
+extern float V1(int x, int y, int level);
71
+extern void build_pyramid();
72
+extern void clean_pyramid();
73
 #else
74
-
75
+static double ***convolved_image;
76
 static zomplex **filter_fft;
77
 static zomplex  *image_fft, *coeff;
78
 
79
-#define V1(x,y,i)        (convolved_image[i][x][y])
80
+#define V1(x,y,i)       ((float)convolved_image[i][x][y])
81
 
82
 #endif
83
 
84
-#define SIGMA_I(i)       (sigma_0 + ((double)i/(double)range)*(sigma_1 - sigma_0))
85
-#define S_I(i)           (exp (SIGMA_I(i)))
86
-#define V2(x,y,i)        (V1(x,y,i+1))
87
-#define ACTIVITY(x,y,i)  ((V1(x,y,i) - V2(x,y,i)) / (((key * pow (2., phi))/(S_I(i)*S_I(i))) + V1(x,y,i)))
88
+#define SIGMA_I(i)      (sigma_0 + ((float)i/(float)range)*(sigma_1 - sigma_0))
89
+#define S_I(i)          (expf(SIGMA_I(i)))
90
+#define V2(x,y,i)       (V1(x,y,i+1))
91
+#define ACTIVITY(x,y,i) ((V1(x,y,i) - V2(x,y,i)) / (((key * powf(2.f, phi))/(S_I(i)*S_I(i))) + V1(x,y,i)))
92
 
93
 
94
 
95
@@ -119,32 +111,32 @@ public:
96
 };
97
 
98
 
99
-static TemporalSmoothVariable<double> avg_luminance, max_luminance;
100
+static TemporalSmoothVariable<float> avg_luminance, max_luminance;
101
 
102
 
103
 /*
104
  * Kaiser-Bessel stuff
105
  */
106
 
107
-static double   alpha = 2.;         /* Kaiser-Bessel window parameter   */
108
-static double   bbeta;              /* Will contain bessel (PI * alpha) */
109
+static float   alpha = 2.f;        /* Kaiser-Bessel window parameter   */
110
+static float   bbeta;              /* Will contain bessel (PI * alpha) */
111
 
112
 /*
113
  * Modified zeroeth order bessel function of the first kind
114
  */
115
 
116
-double bessel (double x)
117
+static float bessel (float x)
118
 {
119
-  const double f = 1e-9;
120
+  const float f = 1e-9f;
121
   int          n = 1;
122
-  double       s = 1.;
123
-  double       d = 1.;
124
+  float       s = 1.f;
125
+  float       d = 1.f;
126
 
127
-  double t;
128
+  float t;
129
 
130
   while (d > f * s)
131
   {
132
-    t = x / (2. * n);
133
+    t = x / (2.f * n);
134
     n++;
135
     d *= t * t;
136
     s += d;
137
@@ -156,7 +148,7 @@ double bessel (double x)
138
  * Initialiser for Kaiser-Bessel computations
139
  */
140
 
141
-void compute_bessel ()
142
+static void compute_bessel ()
143
 {
144
   bbeta = bessel (M_PI * alpha);
145
 }
146
@@ -166,12 +158,12 @@ void compute_bessel ()
147
  * Window length M = min (width, height) / 2
148
  */
149
 
150
-double kaiserbessel (double x, double y, double M)
151
+static float kaiserbessel (float x, float y, float M)
152
 {
153
-  double d = 1. - ((x*x + y*y) / (M * M));
154
-  if (d <= 0.)
155
-    return 0.;
156
-  return bessel (M_PI * alpha * sqrt (d)) / bbeta;
157
+  float d = 1.f - ((x*x + y*y) / (M * M));
158
+  if (d <= 0.f)
159
+    return 0.f;
160
+  return bessel(M_PI * alpha * sqrtf(d)) / bbeta;
161
 }
162
 
163
 
164
@@ -180,57 +172,57 @@ double kaiserbessel (double x, double y,
165
  */
166
 #ifdef HAVE_ZFFT
167
 
168
-void initialise_fft (int width, int height)
169
+static void initialise_fft (int width, int height)
170
 {
171
   coeff = zfft2di (width, height, NULL);
172
 }
173
 
174
-void compute_fft (zomplex *array, int width, int height)
175
+static void compute_fft (zomplex *array, int width, int height)
176
 {
177
   zfft2d (-1, width, height, array, width, coeff);
178
 }
179
 
180
-void compute_inverse_fft (zomplex *array, int width, int height)
181
+static void compute_inverse_fft (zomplex *array, int width, int height)
182
 {
183
   zfft2d (1, width, height, array, width, coeff);
184
 }
185
 
186
 
187
 // Compute Gaussian blurred images
188
-void gaussian_filter (zomplex *filter, double scale, double k )
189
+static void gaussian_filter (zomplex *filter, double scale, double k )
190
 {
191
   int    x, y;
192
   double x1, y1, s;
193
   double a = 1. / (k * scale);
194
   double c = 1. / 4.;
195
 
196
-  for (y = 0; y < cvts.ymax; y++)
197
+  for (y = 0; y < height; y++)
198
   {
199
-    y1 = (y >= cvts.ymax / 2) ? y - cvts.ymax : y;
200
+    y1 = (y >= height / 2) ? y - height : y;
201
     s  = erf (a * (y1 - .5)) - erf (a * (y1 + .5));
202
-    for (x = 0; x < cvts.xmax; x++)
203
+    for (x = 0; x < width; x++)
204
     {
205
-      x1 = (x >= cvts.xmax / 2) ? x - cvts.xmax : x;
206
-      filter[y*cvts.xmax + x].re = s * (erf (a * (x1 - .5)) - erf (a * (x1 + .5))) * c;
207
-      filter[y*cvts.xmax + x].im = 0.;
208
+      x1 = (x >= width / 2) ? x - width : x;
209
+      filter[y*width + x].re = s * (erf (a * (x1 - .5)) - erf (a * (x1 + .5))) * c;
210
+      filter[y*width + x].im = 0.;
211
     }
212
   }
213
 }
214
 
215
-void build_gaussian_fft ()
216
+static void build_gaussian_fft ()
217
 {
218
-  int    i;
219
-  double length    = cvts.xmax * cvts.ymax;
220
-  double fft_scale = 1. / sqrt (length);
221
-  filter_fft      = (zomplex**) calloc (range, sizeof (zomplex*));
222
+  int i;
223
+  int length = width * height;
224
+  double fft_scale = 1. / sqrt((double)length);
225
+  filter_fft = new zomplex*[range];
226
 
227
   for (scale = 0; scale < range; scale++)
228
   {
229
     fprintf (stderr, "Computing FFT of Gaussian at scale %i (size %i x %i)%c", 
230
-	     scale, cvts.xmax, cvts.ymax, (char)13);
231
-    filter_fft[scale] = (zomplex*) calloc (length, sizeof (zomplex));
232
+	     scale, width, height, (char)13);
233
+    filter_fft[scale] = new zomplex[length];
234
     gaussian_filter (filter_fft[scale], S_I(scale), k);
235
-    compute_fft     (filter_fft[scale], cvts.xmax, cvts.ymax);
236
+    compute_fft     (filter_fft[scale], width, height);
237
     for (i = 0; i < length; i++)
238
     {
239
       filter_fft[scale][i].re *= fft_scale;
240
@@ -240,20 +232,20 @@ void build_gaussian_fft ()
241
   fprintf (stderr, "\n");
242
 }
243
 
244
-void build_image_fft ()
245
+static void build_image_fft ()
246
 {
247
-  int    i, x, y;
248
-  double length    = cvts.xmax * cvts.ymax;
249
-  double fft_scale = 1. / sqrt (length);
250
+  int i, x, y;
251
+  int length = width * height;
252
+  double fft_scale = 1. / sqrt((double)length);
253
 
254
   fprintf (stderr, "Computing image FFT\n");
255
-  image_fft = (zomplex*) calloc (length, sizeof (zomplex));
256
+  image_fft = new zomplex[length];
257
 
258
-  for (y = 0; y < cvts.ymax; y++)
259
-    for (x = 0; x < cvts.xmax; x++)
260
-      image_fft[y*cvts.xmax + x].re = luminance[y][x];
261
+  for (y = 0; y < height; y++)
262
+    for (x = 0; x < width; x++)
263
+      image_fft[y*width + x].re = (*lum)(x,y);
264
 
265
-  compute_fft (image_fft, cvts.xmax, cvts.ymax);
266
+  compute_fft (image_fft, width, height);
267
   for (i = 0; i < length; i++)
268
   {
269
     image_fft[i].re *= fft_scale;
270
@@ -261,47 +253,61 @@ void build_image_fft ()
271
   }
272
 }
273
 
274
-void convolve_filter (int scale, zomplex *convolution_fft)
275
+static void convolve_filter (int scale, zomplex *convolution_fft)
276
 {
277
   int i, x, y;
278
 
279
-  for (i = 0; i < cvts.xmax * cvts.ymax; i++)
280
+  for (i = 0; i < width * height; i++)
281
   {
282
     convolution_fft[i].re = image_fft[i].re * filter_fft[scale][i].re -
283
                             image_fft[i].im * filter_fft[scale][i].im;
284
     convolution_fft[i].im = image_fft[i].re * filter_fft[scale][i].im +
285
                             image_fft[i].im * filter_fft[scale][i].re;
286
   }
287
-  compute_inverse_fft (convolution_fft, cvts.xmax, cvts.ymax);
288
+  compute_inverse_fft (convolution_fft, width, height);
289
   i = 0;
290
-  for (y = 0; y < cvts.ymax; y++)
291
-    for (x = 0; x < cvts.xmax; x++)
292
+  for (y = 0; y < height; y++)
293
+    for (x = 0; x < width; x++)
294
       convolved_image[scale][x][y] = convolution_fft[i++].re;
295
 }
296
 
297
-void compute_fourier_convolution ()
298
+static void compute_fourier_convolution ()
299
 {
300
   int x;
301
   zomplex *convolution_fft;
302
 
303
-  initialise_fft     (cvts.xmax, cvts.ymax);
304
+  initialise_fft     (width, height);
305
   build_image_fft    ();
306
   build_gaussian_fft ();
307
-  convolved_image =  (double ***) malloc (range * sizeof (double **));
308
+  convolved_image =  new double**[range];
309
 
310
-  convolution_fft =  (zomplex *) calloc (cvts.xmax * cvts.ymax, sizeof (zomplex));
311
+  convolution_fft =  new zomplex[width * height];
312
   for (scale = 0; scale < range; scale++)
313
   {
314
     fprintf (stderr, "Computing convolved image at scale %i%c", scale, (char)13);
315
-    convolved_image[scale] = (double **) malloc (cvts.xmax * sizeof (double *));
316
-    for (x = 0; x < cvts.xmax; x++)
317
-      convolved_image[scale][x] = (double *) malloc (cvts.ymax * sizeof (double));
318
+    convolved_image[scale] = new double*[width];
319
+    for (x = 0; x < width; x++)
320
+      convolved_image[scale][x] = new double[height];
321
     convolve_filter (scale, convolution_fft);
322
-    free (filter_fft[scale]);
323
+    delete[] filter_fft[scale];
324
   }
325
+  delete[] filter_fft;
326
   fprintf (stderr, "\n");
327
-  free (convolution_fft);
328
-  free (image_fft);
329
+  delete[] convolution_fft;
330
+  delete[] image_fft;
331
+}
332
+
333
+static void clean_convolved_image()
334
+{
335
+  for (scale = 0; scale < range; scale++)
336
+  {
337
+    for (x = 0; x < width; x++)
338
+    {
339
+      delete[] convolved_image[scale][x];
340
+    }
341
+    delete[] convolved_image[scale];
342
+  }
343
+  delete[] convolved_image;
344
 }
345
 
346
 #endif // #ifdef HAVE_ZFFT
347
@@ -312,188 +318,141 @@ void compute_fourier_convolution ()
348
  * Tonemapping routines
349
  */
350
 
351
-double get_maxvalue ()
352
-{
353
-  double max = 0.;
354
-  int    x, y;
355
-
356
-  for (y = 0; y < cvts.ymax; y++)
357
-    for (x = 0; x < cvts.xmax; x++)
358
-      max = (max < image[y][x][0]) ? image[y][x][0] : max;
359
-  return max;
360
-}
361
-
362
-void tonemap_image ()
363
+static void tonemap()
364
 {
365
-  double Lmax2;
366
-  int    x, y;
367
-  int    scale, prefscale;
368
-
369
-  if (white < 1e20)
370
-    Lmax2 = white * white;
371
-  else
372
+  for (int y = 0; y<height; y++)
373
   {
374
-    if( temporal_coherent ) {
375
-      max_luminance.set( get_maxvalue() );
376
-      Lmax2 = max_luminance.get();
377
-    } else Lmax2  = get_maxvalue();
378
-    Lmax2 *= Lmax2;
379
-  }
380
-
381
-  for (y = 0; y < cvts.ymax; y++)
382
-    for (x = 0; x < cvts.xmax; x++)
383
+    for (int x = 0; x<width; x++)
384
     {
385
-      if (use_scales)
386
+      int prefscale = range-1;
387
+      for (int scale = 0; scale<range-1; scale++)
388
       {
389
-	prefscale = range - 1;
390
-	for (scale = 0; scale < range - 1; scale++)
391
-	  if ( scale >= PyramidHeight || fabs (ACTIVITY(x,y,scale)) > threshold)
392
+	  if (scale>=PyramidHeight || fabsf(ACTIVITY(x,y,scale))>threshold)
393
 	  {
394
 	    prefscale = scale;
395
 	    break;
396
 	  }
397
-	image[y][x][0] /= 1. + V1(x,y,prefscale);
398
       }
399
-      else
400
-	image[y][x][0] = image[y][x][0] * (1. + (image[y][x][0] / Lmax2)) / (1. + image[y][x][0]);
401
-      // image[y][x][0] /= (1. + image[y][x][0]);
402
+      (*img)(x,y) = (*lum)(x,y)/(1.f+V1(x,y,prefscale));
403
     }
404
+  }
405
 }
406
 
407
-/*
408
- * Miscellaneous functions
409
- */
410
-
411
-void clamp_image ()
412
+static float get_maxvalue()
413
 {
414
-  int x, y;
415
+  float max = 0.f;
416
+  int   x, y;
417
+  for (int i = width*height; i--; )
418
+  {
419
+    float l = (*img)(i);
420
+    if (max<l) max = l;
421
+  }
422
+  return max;
423
+}
424
 
425
-  for (y = 0; y < cvts.ymax; y++)
426
-    for (x = 0; x < cvts.xmax; x++)
427
+static void tonecompress()
428
+{
429
+  float Lmax2;
430
+  if (white<1e20f)
431
+  {
432
+    Lmax2 = white;
433
+  }
434
+  else
435
+  {
436
+    if (temporal_coherent)
437
     {
438
-      image[y][x][0] = (image[y][x][0] > 1.) ? 1. : image[y][x][0];
439
-      image[y][x][1] = (image[y][x][1] > 1.) ? 1. : image[y][x][1];
440
-      image[y][x][2] = (image[y][x][2] > 1.) ? 1. : image[y][x][2];
441
+      max_luminance.set(get_maxvalue());
442
+      Lmax2 = max_luminance.get();
443
     }
444
+    else
445
+    {
446
+      Lmax2  = get_maxvalue();
447
+    }
448
+  }
449
+  Lmax2 *= Lmax2;
450
+  for (int i = width*height; i--; )
451
+  {
452
+    (*img)(i) = (*lum)(i)*(1.f+(*lum)(i)/Lmax2)/(1.f+(*lum)(i));
453
+  }
454
 }
455
 
456
-double log_average ()
457
+/*
458
+ * Miscellaneous functions
459
+ */
460
+
461
+static float log_average()
462
 {
463
-  int    x, y;
464
   double sum = 0.;
465
-
466
-  for (y = 0; y < cvts.ymax; y++)
467
-    for (x = 0; x < cvts.xmax; x++)
468
-      sum += log (0.00001 + luminance[y][x]);
469
-  return exp (sum / (double)(cvts.xmax * cvts.ymax));
470
+  int s = width*height;
471
+  for (int i = s; i--; )
472
+  {
473
+    sum += log(0.00001+(*lum)(i));
474
+  }
475
+  return expf((float)sum/(float)s);
476
 }
477
 
478
-void scale_to_midtone ()
479
+static void scale_to_midtone()
480
 {
481
-  int    x, y, u, v, d;
482
-  double factor;
483
-  double scale_factor;
484
-  double low_tone    = key / 3.;
485
-  int    border_size = (cvts.xmax < cvts.ymax) ? int(cvts.xmax / 5.) : int(cvts.ymax / 5.);
486
-  int    hw          = cvts.xmax >> 1;
487
-  int    hh          = cvts.ymax >> 1;
488
+  float avg, scale_factor;
489
+  int   border_size = (int)(((width<height) ? width : height)*border);
490
 
491
-  double avg;
492
-  if( temporal_coherent ) {
493
-    avg_luminance.set( log_average() );
494
+  avg = log_average();
495
+  if (temporal_coherent)
496
+  {
497
+    avg_luminance.set(avg);
498
     avg = avg_luminance.get();
499
-  } else avg = log_average();
500
+  }
501
   
502
-  scale_factor = 1.0 / avg;
503
-  for (y = 0; y < cvts.ymax; y++)
504
-    for (x = 0; x < cvts.xmax; x++)
505
+  scale_factor = key / avg;
506
+  for (int i = width*height; i--; )
507
+  {
508
+    (*lum)(i) *= scale_factor;
509
+  }
510
+  if (border_size)
511
+  {
512
+    int hw = width >> 1;
513
+    int hh = height >> 1;
514
+    for (int y = 0; y < height; y++)
515
     {
516
-      if (use_border)
517
+      int v = (y > hh) ? height - y : y;
518
+      for (int x = 0; x < width; x++)
519
       {
520
-	u              = (x > hw) ? cvts.xmax - x : x;
521
-	v              = (y > hh) ? cvts.ymax - y : y;
522
-	d              = (u < v) ? u : v;	
523
-	factor         = (d < border_size) ? (key - low_tone) * 
524
-	                  kaiserbessel (border_size - d, 0, border_size) + 
525
-                          low_tone : key;
526
+	int u = (x > hw) ? width - x : x;
527
+	int d = (u < v) ? u : v;	
528
+        if (d < border_size) 
529
+          (*lum)(x,y) *= 
530
+            (2.f * kaiserbessel(border_size - d, 0, border_size) + 1.f) / 3.f;
531
       }
532
-      else
533
-	factor         = key;
534
-      image[y][x][0]  *= scale_factor * factor;
535
-      luminance[y][x] *= scale_factor * factor;
536
     }
537
-}
538
-
539
-void copy_luminance ()
540
-{
541
-  int x, y;
542
-
543
-  for (x = 0; x < cvts.xmax; x++)
544
-    for (y = 0; y < cvts.ymax; y++)
545
-      luminance[y][x] = image[y][x][0];
546
-}
547
-
548
-/*
549
- * Memory allocation
550
- */
551
-void allocate_memory ()
552
-{
553
-  int y;
554
-
555
-  luminance = (double **) malloc (cvts.ymax * sizeof (double *));
556
-  image     = (COLOR **) malloc (cvts.ymax * sizeof (COLOR *));
557
-  for (y = 0; y < cvts.ymax; y++)
558
-  {
559
-    luminance[y] = (double *) malloc (cvts.xmax * sizeof (double));
560
-    image[y]     = (COLOR *) malloc (cvts.xmax * sizeof (COLOR));
561
   }
562
 }
563
 
564
-void deallocate_memory ()
565
+static void dynamic_range()
566
 {
567
-  int y;
568
-
569
-  for (y = 0; y < cvts.ymax; y++)
570
+  float min =  1e20f;
571
+  float max = -1e20f;
572
+  for (int i = width*height; i--; )
573
   {
574
-    free(luminance[y]);
575
-    free(image[y]);
576
+    float l = (*lum)(i);
577
+    if (min>l && l>0.f) min = l;
578
+    if (max<l) max = l;
579
   }
580
-  free( luminance );
581
-  free( image );
582
-}
583
-
584
-
585
-void dynamic_range ()
586
-{
587
-  int x, y;
588
-  double minval =  1e20;
589
-  double maxval = -1e20;
590
-
591
-  for (x = 0; x < cvts.xmax; x++)
592
-    for (y = 0; y < cvts.ymax; y++)
593
-    {
594
-      if ((luminance[y][x] < minval) &&
595
-	  (luminance[y][x] > 0.0))
596
-	minval = luminance[y][x];
597
-      if (luminance[y][x] > maxval)
598
-	maxval = luminance[y][x];
599
-    }
600
-  fprintf (stderr, "\tRange of values  = %9.8f - %9.8f\n", minval, maxval);
601
-  fprintf (stderr, "\tDynamic range    = %i:1\n", (int)(maxval/minval));
602
+  fprintf(stderr, "\tRange of values  = %9.8f - %9.8f\n", min, max);
603
+  fprintf(stderr, "\tDynamic range    = %i:1\n", (int)(max/min));
604
 }
605
 
606
-void print_parameter_settings ()
607
+static void print_parameter_settings()
608
 {
609
-  fprintf (stderr, "\tImage size       = %i %i\n", cvts.xmax, cvts.ymax);
610
-  fprintf (stderr, "\tLowest scale     = %i pixels\t\t(-low <integer>)\n", scale_low);
611
-  fprintf (stderr, "\tHighest scale    = %i pixels\t\t(-high <integer>)\n", scale_high);
612
-  fprintf (stderr, "\tNumber of scales = %i\t\t\t(-num <integer>)\n", range);
613
-  fprintf (stderr, "\tScale spacing    = %f\n", S_I(1) / S_I(0));
614
-  fprintf (stderr, "\tKey value        = %f\t\t(-key <float>)\n", key);
615
-  fprintf (stderr, "\tWhite value      = %f\t\t(-white <float>)\n", white);
616
-  fprintf (stderr, "\tPhi              = %f\t\t(-phi <float>)\n", phi);
617
-  fprintf (stderr, "\tThreshold        = %f\t\t(-threshold <float>)\n", threshold);
618
-  dynamic_range ();
619
+  fprintf(stderr, "\tImage size       = %i %i\n", width, height);
620
+  fprintf(stderr, "\tLowest scale     = %i pixels\t\t(-low <integer>)\n", scale_low);
621
+  fprintf(stderr, "\tHighest scale    = %i pixels\t\t(-high <integer>)\n", scale_high);
622
+  fprintf(stderr, "\tNumber of scales = %i\t\t\t(-num <integer>)\n", range);
623
+  fprintf(stderr, "\tScale spacing    = %f\n", S_I(1) / S_I(0));
624
+  fprintf(stderr, "\tKey value        = %f\t\t(-key <float>)\n", key);
625
+  fprintf(stderr, "\tWhite value      = %f\t\t(-white <float>)\n", white);
626
+  fprintf(stderr, "\tPhi              = %f\t\t(-phi <float>)\n", phi);
627
+  fprintf(stderr, "\tThreshold        = %f\t\t(-threshold <float>)\n", threshold);
628
+  dynamic_range();
629
 }
630
 
631
 /*
632
@@ -507,16 +466,15 @@ void print_parameter_settings ()
633
  * @param num number of scales to use in computation (default: 8)
634
  * @param low size in pixels of smallest scale (should be kept at 1)
635
  * @param high size in pixels of largest scale (default 1.6^8 = 43)
636
+ * @param temporal_coherent tone mapping is time coherent for video sequences
637
+ * @param border relative width of image area scaled to midtone separately (default: 0 - use key for whole image)
638
  */
639
 void tmo_reinhard02(
640
-  unsigned int width, unsigned int height,
641
-  const float *nY, float *nL, 
642
+  const pfstmo::Array2D *Y, pfstmo::Array2D *L, 
643
   bool use_scales, float key, float phi, 
644
-  int num, int low, int high, bool temporal_coherent )
645
+  int num, int low, int high, bool temporal_coherent, float border)
646
 {
647
-  const pfstmo::Array2D* Y = new pfstmo::Array2D(width, height, const_cast<float*>(nY));
648
-  pfstmo::Array2D* L = new pfstmo::Array2D(width, height, nL);
649
-
650
+  std::auto_ptr<pfstmo::Array2D> l(0);
651
   int x,y;
652
 
653
   ::key = key;
654
@@ -526,45 +484,45 @@ void tmo_reinhard02(
655
   ::scale_high = high;
656
   ::use_scales = (use_scales) ? 1 : 0;
657
   ::temporal_coherent = temporal_coherent;
658
+  ::border = border;
659
 
660
-  cvts.xmax = Y->getCols();
661
-  cvts.ymax = Y->getRows();
662
+  width = Y->getCols();
663
+  height = Y->getRows();
664
 
665
-  sigma_0      = log (scale_low);
666
-  sigma_1      = log (scale_high);
667
+  sigma_0 = logf(scale_low);
668
+  sigma_1 = logf(scale_high);
669
 
670
   compute_bessel();
671
-  allocate_memory ();
672
 
673
-  // reading image
674
-  for( y=0 ; y<cvts.ymax ; y++ )
675
-    for( x=0 ; x<cvts.xmax ; x++ )
676
-      image[y][x][0] = (*Y)(x,y);
677
+  img = lum = L;
678
+  if (use_scales)
679
+  {
680
+    l.reset(new pfstmo::Array2D(width,height));
681
+    lum = l.get();
682
+  }
683
+  copyArray(Y,lum);
684
 
685
-  copy_luminance();
686
   scale_to_midtone();
687
 
688
-  if( use_scales )
689
+  if (use_scales)
690
   {
691
 #ifdef APPROXIMATE
692
-    build_pyramid(luminance, cvts.xmax, cvts.ymax);
693
+    build_pyramid();
694
 #else
695
     compute_fourier_convolution();
696
 #endif
697
+    tonemap();
698
+  }
699
+  else
700
+  {
701
+    tonecompress();
702
   }
703
-
704
-  tonemap_image();
705
-
706
-  // saving image
707
-  for( y=0 ; y<cvts.ymax ; y++ )
708
-    for( x=0 ; x<cvts.xmax ; x++ )
709
-      (*L)(x,y) = image[y][x][0];
710
 
711
 //  print_parameter_settings();
712
 
713
-  deallocate_memory();
714
+#ifdef APPROXIMATE
715
   clean_pyramid();
716
-
717
-  delete L;
718
-  delete Y;
719
+#else
720
+  clean_convolved_image();
721
+#endif
722
 }
(-)graphics/pfstools/files/patch-src_tmo_reinhard02_tmo__reinhard02.h (+27 lines)
Line 0 Link Here
1
--- src/tmo/reinhard02/tmo_reinhard02.h.orig	2018-01-19 06:59:44 UTC
2
+++ src/tmo/reinhard02/tmo_reinhard02.h
3
@@ -13,8 +13,6 @@
4
 /*
5
  * @brief Photographic tone-reproduction
6
  *
7
- * @param width image width
8
- * @param height image height
9
  * @param Y input luminance
10
  * @param L output tonemapped intensities
11
  * @param use_scales true: local version, false: global version of TMO
12
@@ -23,10 +21,12 @@
13
  * @param num number of scales to use in computation (default: 8)
14
  * @param low size in pixels of smallest scale (should be kept at 1)
15
  * @param high size in pixels of largest scale (default 1.6^8 = 43)
16
+ * @param temporal_coherent tone mapping is time coherent for video sequences
17
+ * @param border relative width of image area scaled to midtone separately (default: 0 - use key for whole image)
18
  */
19
-void tmo_reinhard02(unsigned int width, unsigned int height, 
20
-  const float *Y, float *L, 
21
+void tmo_reinhard02(
22
+  const pfstmo::Array2D *Y, pfstmo::Array2D *L, 
23
   bool use_scales, float key, float phi, 
24
-  int num, int low, int high, bool temporal_coherent );
25
+  int num, int low, int high, bool temporal_coherent, float border = 0.f);
26
 
27
 #endif /* _tmo_reinhard02_h_ */
(-)graphics/pfstools/files/patch-src_tmo_reinhard05_pfstmo__reinhard05.cpp (+17 lines)
Line 0 Link Here
1
--- src/tmo/reinhard05/pfstmo_reinhard05.cpp.orig	2018-01-19 06:59:44 UTC
2
+++ src/tmo/reinhard05/pfstmo_reinhard05.cpp
3
@@ -157,6 +157,14 @@ int main( int argc, char* argv[] )
4
   try {
5
     pfstmo_reinhard05( argc, argv );
6
   }
7
+  catch (std::bad_alloc ex) {
8
+    fprintf(stderr, PROG_NAME " error: out of memory\n");
9
+    return EXIT_FAILURE;
10
+  }        
11
+  catch (std::exception ex) {
12
+    fprintf(stderr, PROG_NAME " error: %s\n", ex.what());
13
+    return EXIT_FAILURE;
14
+  }        
15
   catch( pfs::Exception ex ) {
16
     fprintf( stderr, PROG_NAME " error: %s\n", ex.getMessage() );
17
     return EXIT_FAILURE;
(-)graphics/pfstools/files/port/src/camera/robertson02old.cpp (+340 lines)
Line 0 Link Here
1
/**
2
 * @brief Robertson02 algorithm for automatic self-calibration.
3
 *
4
 * 
5
 * This file is a part of PFS CALIBRATION package.
6
 * ---------------------------------------------------------------------- 
7
 * Copyright (C) 2004 Grzegorz Krawczyk
8
 * 
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program; if not, write to the Free Software
21
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
 * ---------------------------------------------------------------------- 
23
 * 
24
 * @author Grzegorz Krawczyk, <gkrawczyk@users.sourceforge.net>
25
 *
26
 * $Id: robertson02.cpp,v 1.7 2006/11/16 15:06:17 gkrawczyk Exp $
27
 */
28
29
30
#include <config.h>
31
32
#include <iostream>
33
#include <vector>
34
#include <cstdlib>
35
36
#include <math.h>
37
38
#include <responses.h>
39
#include <robertson02old.h>
40
41
#define PROG_NAME "robertson02"
42
43
// maximum iterations after algorithm accepts local minima
44
#define MAXIT 500
45
46
// maximum accepted error
47
#define MAX_DELTA 1e-5f
48
49
extern bool verbose; /* verbose should be declared for each standalone code */
50
51
static float normalizeI(float *I, int M);
52
53
54
int robertson02old_applyResponse(pfs::Array2D *xj, ExposureList const &imgs, float const *I, int Mr, float const *w, int Mw)
55
{
56
  float const rfactor(Mr);
57
  float const wfactor(Mw);
58
  float const rwfactor(rfactor/wfactor);
59
  // number of exposures
60
  int N = imgs.size();
61
62
  // frame size
63
  int width = xj->getCols();
64
  int height = xj->getRows();
65
66
  // number of saturated pixels
67
  int saturated_pixels = 0;
68
69
  // --- anti saturation: calculate trusted camera output range
70
  int minM = 0;
71
  for( int wm=0 ; wm<Mw ; ++wm )
72
    if( w[wm]>0 )
73
    {
74
      minM = wm;
75
      break;
76
    }
77
  int maxM = Mw-1;
78
  for( int wm=Mw-1 ; wm>=0 ; --wm )
79
    if( w[wm]>0 )
80
    {
81
      maxM = wm;
82
      break;
83
    }
84
  
85
  // --- anti ghosting: for each image i, find images with
86
  // the immediately higher and lower exposure times
87
  int* i_lower = new int[N];
88
  int* i_upper = new int[N];
89
  for( int i=0 ; i<N ; i++ )
90
  {
91
    i_lower[i]=-1;
92
    i_upper[i]=-1;
93
    float ti = imgs[i].ti;
94
    float ti_upper = imgs[0].ti;
95
    float ti_lower = imgs[0].ti;
96
97
    for( int j=0 ; j<N ; j++ )
98
      if( i!=j )
99
      {
100
        if( imgs[j].ti>ti && imgs[j].ti<ti_upper )
101
        {
102
          ti_upper=imgs[j].ti;
103
          i_upper[i]=j;
104
        }
105
        if( imgs[j].ti<ti && imgs[j].ti>ti_lower )
106
        {
107
          ti_lower=imgs[j].ti;
108
          i_lower[i]=j;
109
        }
110
      }
111
    if( i_lower[i]==-1 )
112
      i_lower[i]=i;
113
    if( i_upper[i]==-1 )
114
      i_upper[i]=i;
115
  }
116
  
117
  
118
  // all pixels
119
  for( int j=0 ; j<width*height ; j++ )
120
  {
121
    // all exposures for each pixel
122
    float sum = 0.0f;
123
    float div = 0.0f;
124
125
    float maxti = -1e6f;
126
    float minti = +1e6f;
127
    
128
    for( int i=0 ; i<N ; i++ )
129
    {
130
      float v = (*imgs[i].yi)(j);
131
      int  rm = (int) ((v - std::numeric_limits<float>::epsilon()) * rfactor);
132
      int  wm = (int) ((v - std::numeric_limits<float>::epsilon()) * wfactor);
133
      float ti = imgs[i].ti;
134
135
      // --- anti saturation: observe minimum exposure time at which
136
      // saturated value is present, and maximum exp time at which
137
      // black value is present
138
      if( wm>maxM )
139
        minti = fminf(minti,ti);
140
      if( wm<minM )
141
        maxti = fmaxf(maxti,ti);
142
      
143
      // --- anti ghosting: monotonous increase in time should result
144
      // in monotonous increase in intensity; make forward and
145
      // backward check, ignore value if condition not satisfied
146
      //int m_lower = (int) (*imgs[i_lower[i]].yi)(j);
147
      //int m_upper = (int) (*imgs[i_upper[i]].yi)(j);
148
      //if( m_lower>m || m_upper<m)
149
      if ((*imgs[i_lower[i]].yi)(j) > v || (*imgs[i_upper[i]].yi)(j) < v)
150
        continue;
151
      
152
      sum += w[wm] * ti * I[rm];
153
      div += w[wm] * ti * ti;
154
    }
155
156
    // --- anti saturation: if a meaningful representation of pixel
157
    // was not found, replace it with information from observed data
158
    if( div==0.0f )
159
      saturated_pixels++;
160
    if( div==0.0f && maxti>-1e6f )
161
    {
162
      int  rm = (int) (minM * rwfactor);
163
      sum = I[rm];
164
      div = maxti;
165
    }
166
    if( div==0.0f && minti<+1e6f )
167
    {
168
      int  rm = (int) (maxM * rwfactor);
169
      sum = I[rm];
170
      div = minti;
171
    }
172
      
173
    if( div!=0.0f )
174
      (*xj)(j) = sum/div;
175
    else
176
      (*xj)(j) = 0.0f;
177
  }
178
179
  delete[] i_lower;
180
  delete[] i_upper;
181
  
182
  return saturated_pixels;
183
}
184
185
186
int robertson02old_getResponse(pfs::Array2D *xj, ExposureList const &imgs, float *I, int Mr, float const *w, int Mw)
187
{
188
  float const rfactor(Mr);
189
  //float const wfactor(Mw);
190
  // number of exposures
191
  int N = imgs.size();
192
    
193
  // frame size
194
  int width = imgs[0].yi->getCols();
195
  int height = imgs[0].yi->getRows();
196
197
  // number of saturated pixels
198
  int saturated_pixels = 0;
199
200
  // indexes
201
  int i,j;
202
  
203
  float* Ip = new float[Mr];	// previous response
204
  if( Ip==NULL )
205
  {
206
    std::cerr << "robertson02: could not allocate memory for camera response" << std::endl;
207
    exit(1);
208
  }
209
210
  // 0. Initialization
211
  normalizeI( I, Mr );
212
  for( int rm=0 ; rm<Mr ; ++rm )
213
    Ip[rm] = I[rm];
214
215
  robertson02old_applyResponse( xj, imgs, I, Mr, w, Mw );
216
217
  // Optimization process
218
  bool converged=false;
219
  long* cardEm = new long[Mr];
220
  float* sum = new float[Mr];
221
  if( sum==NULL || cardEm==NULL )
222
  {
223
    std::cerr << "robertson02: could not allocate memory for optimization process" << std::endl;
224
    exit(1);
225
  }
226
    
227
  int cur_it = 0;
228
  float pdelta= 0.0f;
229
  while( !converged )
230
  {
231
    // 1. Minimize with respect to I
232
    for( int rm=0 ; rm<Mr ; ++rm )
233
    {
234
      cardEm[rm]=0;
235
      sum[rm]=0.0f;
236
    }
237
    
238
    for( i=0 ; i<N ; i++ )
239
    {
240
      pfs::Array2D* yi = imgs[i].yi;
241
      float ti = imgs[i].ti;
242
      for( j=0 ; j<width*height ; j++ )
243
      {
244
        float v = (*yi)(j);
245
	int  rm = (int) ((v - std::numeric_limits<float>::epsilon()) * rfactor);
246
	//int  wm = (int) ((v - std::numeric_limits<float>::epsilon()) * wfactor);
247
	if( rm<Mr && rm>=0 )
248
	{
249
	  sum[rm] += ti * (*xj)(j);
250
	  cardEm[rm]++;
251
	}
252
  	else
253
  	  std::cerr << "robertson02: m out of range: " << rm << std::endl;
254
      }
255
    }
256
257
    for( int rm=0 ; rm<Mr ; ++rm )
258
      if( cardEm[rm]!=0 )
259
	I[rm] = sum[rm] / cardEm[rm];
260
      else
261
	I[rm] = 0.0f;
262
    
263
    // 2. Normalize I
264
    float middle_response = normalizeI( I, Mr );
265
266
    // 3. Apply new response
267
    saturated_pixels = robertson02old_applyResponse( xj, imgs, I, Mr, w, Mw );
268
269
    // 4. Check stopping condition
270
    float delta = 0.0f;
271
    int hits=0;
272
    for( int rm=0 ; rm<Mr ; ++rm )
273
      if( I[rm]!=0.0f )
274
      {
275
	float diff = I[rm]-Ip[rm];;
276
	delta += diff * diff;
277
	Ip[rm] = I[rm];
278
	hits++;
279
      }
280
    delta /= hits;
281
282
    VERBOSE_STR << " #" << cur_it
283
                << " delta=" << delta
284
                << " (coverage: " << 100*hits/Mr << "%)\n";
285
    
286
    if( delta < MAX_DELTA )
287
      converged=true;
288
    else if( isnan(delta) || (cur_it>MAXIT && pdelta<delta) )
289
    {
290
      VERBOSE_STR << "algorithm failed to converge, too noisy data in range\n";
291
      break;
292
    }
293
294
    pdelta = delta;
295
    cur_it++;
296
  }
297
298
  if( converged )
299
    VERBOSE_STR << " #" << cur_it
300
                << " delta=" << pdelta << " <- converged\n";
301
302
  delete[] Ip;
303
  delete[] cardEm;
304
  delete[] sum;
305
  
306
  return saturated_pixels;
307
}
308
309
310
//----------------------------------------------------------
311
// private part
312
313
static float normalizeI(float *I, int M)
314
{
315
  int Mmin, Mmax;
316
  // find min max
317
  for( Mmin=0 ; Mmin<M && I[Mmin]==0 ; Mmin++ );
318
  for( Mmax=M-1 ; Mmax>0 && I[Mmax]==0 ; Mmax-- );
319
  
320
  int Mmid = Mmin+(Mmax-Mmin)/2;
321
  float mid = I[Mmid];
322
323
//   std::cerr << "robertson02: middle response, mid=" << mid
324
//             << " [" << Mmid << "]"
325
//             << " " << Mmin << ".." << Mmax << std::endl;
326
  
327
  if( mid==0.0f )
328
  {
329
    // find first non-zero middle response
330
    while( Mmid<Mmax && I[Mmid]==0.0f )
331
      Mmid++;
332
    mid = I[Mmid];
333
  }
334
335
  if( mid!=0.0f )
336
    for( int m=0 ; m<M ; m++ )
337
      I[m] /= mid;
338
  return mid;
339
}
340
(-)graphics/pfstools/files/port/src/camera/robertson02old.h (+61 lines)
Line 0 Link Here
1
/**
2
 * @brief Robertson02 algorithm for automatic self-calibration.
3
 *
4
 * 
5
 * This file is a part of PFS CALIBRATION package.
6
 * ---------------------------------------------------------------------- 
7
 * Copyright (C) 2004 Grzegorz Krawczyk
8
 * 
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program; if not, write to the Free Software
21
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
 * ---------------------------------------------------------------------- 
23
 * 
24
 * @author Grzegorz Krawczyk, <gkrawczyk@users.sourceforge.net>
25
 *
26
 * $Id: robertson02.h,v 1.3 2006/09/13 11:52:56 gkrawczyk Exp $
27
 */
28
29
#ifndef _robertson02old_h_
30
#define _robertson02old_h_
31
32
#include <responses.h>
33
34
/**
35
 * @brief Calculate camera response using Robertson02 algorithm
36
 *
37
 * @param xj [out]  estimated luminance values
38
 * @param imgs reference to vector containing source exposures
39
 * @param I [out] array to put response function
40
 * @param w weights
41
 * @param M max camera output (no of discrete steps)
42
 * @return number of saturated pixels in the HDR image (0: all OK)
43
 */
44
int robertson02old_getResponse(pfs::Array2D *xj, ExposureList const &imgs, float *I, int Mr, float const *w, int Mw);
45
46
47
/**
48
 * @brief Create HDR image by applying response curve to given images
49
 * taken with different exposures
50
 *
51
 * @param xj [out] HDR image
52
 * @param imgs reference to vector containing source exposures
53
 * @param I camera response function (array size of M)
54
 * @param w weighting function for camera output values (array size of M)
55
 * @param M number of camera output levels
56
 * @return number of saturated pixels in the HDR image (0: all OK)
57
 */
58
int robertson02old_applyResponse(pfs::Array2D *xj, ExposureList const &imgs, float const *I, int Mr, float const *w, int Mw);
59
60
61
#endif /* #ifndef _robertson02old_h_ */
(-)graphics/pfstools/files/port/src/filter/pfswb.1 (+110 lines)
Line 0 Link Here
1
.TH "pfswb" 1
2
.SH NAME
3
pfswb \- Change white balance.
4
.SH SYNOPSIS
5
.B pfswb
6
[--red <val>] [--green <val>] [--blue <val>]
7
[--auto] [--x <val>] [--y <val>] [--width <val>] [--height <val>]
8
[--keep-lum]
9
[--verbose] [--help]
10
.SH DESCRIPTION
11
Use this command to change white balance in the RGB color space.
12
13
The command converts image(s) from XYZ colorspace to RGB, apply red,
14
green and blue multipliers and convet the result back to XYZ.
15
16
Multipliers are calculated as: <base value> * <auto value>.
17
The base values for each channel can be set by --red, --green and --blue
18
options, default is 1. The auto values will be calculated on the rectangle
19
defined by --x, --y, --width and --height options when --auto option was
20
given, othervice auto values sets to 1.
21
.SH OPTIONS
22
.TP
23
--red <val>, -r <val>
24
25
Base red multiplier. Default value: 1.0
26
27
.TP
28
--green <val>, -g <val>
29
30
Base green multiplier. Default value: 1.0
31
32
.TP
33
--blue <val>, -b <val>
34
35
Base blue multiplier. Default value: 1.0
36
37
.TP
38
--auto, -a
39
40
Auto WB. Calculate auto multipliers using rectangle given by --x, --y,
41
--width and --height options. Default values of auto multipliers are 1.0
42
43
.TP
44
--x <val>, -X <val>
45
46
Horizontal offset of the auto WB rectangle. Default value: 0
47
48
.TP
49
--y <val>, -Y <val>
50
51
Vertical offset of the auto WB rectangle. Default value: 0
52
53
.TP
54
--width <val>, -W <val>
55
56
Width of the auto WB rectangle.
57
Default value: <frame width> - <horizontal offset>
58
59
.TP
60
--height <val>, -H <val>
61
62
Height of the auto WB rectangle.
63
Default value: <frame height> - <vertical offset>
64
65
.TP
66
--keep-lum, -k
67
68
Keep luminance range of the original frame.
69
70
.TP
71
--verbose, -v
72
73
Print additional info to stderr.
74
75
.TP
76
--help, -h
77
78
Print short help an exit.
79
80
.SH EXAMPLES
81
.TP
82
pfsin memorial.hdr | pfswb -r 1.005 -g 0.999 -b 1.003 | pfsout memorial_cl.hdr
83
84
Adjust WB using 1.005,0.999,1.003 base multipliers. Effective multipliers
85
will be the same as the base ones. Luminance range of the original frame
86
will not be kept.
87
88
.TP
89
pfsin memorial.hdr | pfswb -v -a | pfsout memorial_cl.hdr
90
91
Auto adjust WB using frame rectangle to calculate multipliers. Base
92
multipliers are 1,1,1. Effective multipliers will be the same as auto
93
ones. Auto-calculated (and effective) multipliers will be printed
94
to stderr. Luminance range of the original frame will not be kept.
95
96
.TP
97
pfsin memorial.hdr \
98
| pfswb -v -a -r 1.005 -g 0.999 -b 1.003 -k \
99
| pfsout memorial_cl.hdr
100
101
Auto adjust WB using frame rectangle to calculate multipliers. Base
102
multipliers are 1.005,0.999,1.003. Effective multipliers will be 
103
calculated as multiplication of base and auto ones. Multipliers will
104
be printed to stderr. Luminance range of the original frame will be
105
kept.
106
.SH "SEE ALSO"
107
.BR pfsin (1)
108
.BR pfsout (1)
109
.SH BUGS
110
Please report bugs and comments to Iouri Ivliev <fbsd@any.com.ru>
(-)graphics/pfstools/files/port/src/filter/pfswb.cpp (+299 lines)
Line 0 Link Here
1
/**
2
 * @file pfswb.cpp
3
 * @brief Adjust white balance in RGB color space
4
 *
5
 * This file is a part of PFSTOOLS package.
6
 * ---------------------------------------------------------------------- 
7
 * Copyright (C) 2008-2016 Iouri V. Ivliev
8
 * 
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program; if not, write to the Free Software
21
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
 * ---------------------------------------------------------------------- 
23
 * 
24
 * @author Iouri V. Ivliev <fbsd@any.com.ru>
25
 *
26
 * $Id: $
27
 */
28
29
#include <config.h>
30
31
#include <exception>
32
#include <iostream>
33
#include <sys/limits.h>
34
#include <stdlib.h>
35
#include <getopt.h>
36
37
#include <pfs.h>
38
39
#define PROG_NAME "pfswb"
40
41
class QuietException 
42
{
43
};
44
45
static void printHelp()
46
{
47
  std::cerr << PROG_NAME " (" PACKAGE_STRING ") :\n" 
48
    "\t[--red <val>] [--green <val>] [--blue <val>]\n"
49
    "\t[--auto] [--x <val>] [--y <val>] [--width <val>] [--height <val>]\n"
50
    "\t[--keep-lum]\n"
51
    "\t[--verbose] [--help]\n"
52
    "See man page for more information.\n";
53
}
54
55
// verbose mode
56
static bool verbose = false;
57
58
// auto WB
59
static bool autowb = false;
60
// default gray box bounds
61
static int x = 0;
62
static int y = 0;
63
static int width = INT_MAX/2;
64
static int height = INT_MAX/2;
65
66
// keep original luminance
67
static bool keep = false;
68
69
// default WB multipliers
70
static float red = 1.f;
71
static float green = 1.f;
72
static float blue = 1.f;
73
74
static void multipliers(
75
    const pfs::Array2D &R, const pfs::Array2D &G, const pfs::Array2D &B, 
76
    float &r, float &g, float &b)
77
{
78
  r = red;
79
  g = green;
80
  b = blue;
81
  if (!autowb) return;
82
  // auto WB gray box
83
  int w = R.getCols();
84
  int h = R.getRows();
85
  if (x>=w || y>=h)
86
    throw pfs::Exception("gray box is out of frame bounds");
87
  int x1 = width+x;
88
  if (x1>w) x1 = w;
89
  int y1 = height+y;
90
  if (y1>h) y1 = h;
91
  VERBOSE_STR 
92
    << "auto WB gray box: " 
93
    << (x1-x) << "x" << (y1-y) << "+" << x << "+" << y << std::endl;
94
  // auto WB multipliers
95
  double ar = 0.;
96
  double ag = 0.;
97
  double ab = 0.;
98
  for (int y0=y; y0<y1; ++y0)
99
  {
100
    for (int x0=x; x0<x1; ++x0)
101
    {
102
      ar += R(x0,y0);
103
      ag += G(x0,y0);
104
      ab += B(x0,y0);
105
    }
106
  }
107
  int n = (x1-x)*(y1-y);
108
  ar /= n;
109
  ag /= n;
110
  ab /= n;
111
  VERBOSE_STR << "average red value: " << ar << std::endl;
112
  VERBOSE_STR << "average green value: " << ag << std::endl;
113
  VERBOSE_STR << "average blue value: " << ab << std::endl;
114
  float a = (float)((ar+ag+ab)/3.);
115
  r *= a/ar;
116
  g *= a/ag;
117
  b *= a/ab;
118
}
119
120
static void pfswb()
121
{
122
  pfs::DOMIO pfsio;
123
  VERBOSE_STR << "auto WB: " << (autowb ? "yes" : "no" ) << std::endl;
124
  VERBOSE_STR << "base red multiplier value: " << red << std::endl;
125
  VERBOSE_STR << "base green multiplier value: " << green << std::endl;
126
  VERBOSE_STR << "base blue multiplier value: " << blue << std::endl;
127
  VERBOSE_STR << "keep original luminance: " << (keep ? "yes" : "no" ) << std::endl;
128
  while (true) 
129
  {
130
    // Read frame
131
    pfs::Frame *frame = pfsio.readFrame( stdin );
132
    if (!frame)
133
    {
134
      break; // No more frames
135
    }
136
    // Get channels
137
    pfs::Channel *X, *Y, *Z;
138
    frame->getXYZChannels(X, Y, Z);
139
    if (!(Y && X && Z))
140
    {
141
      throw pfs::Exception( "Missing X, Y, Z channels in the PFS stream" );
142
    }
143
    int w = Y->getCols();
144
    int h = Y->getRows();
145
    int s = w*h;
146
    float min = 1e20, max = -1e20;
147
    for (int i=s; i--; )
148
    {
149
      float const &l = (*Y)(i);
150
      if (min > l) min = l;
151
      if (max < l) max = l;
152
    }
153
    VERBOSE_STR << "luminance range of original frame: " << min << ":" << max << std::endl;
154
    // Convert from XYZ to RGB
155
    pfs::transformColorSpace(pfs::CS_XYZ, X, Y, Z, pfs::CS_RGB, X, Y, Z);
156
    // WB adjustment
157
    float r, g, b;
158
    multipliers(*X,*Y,*Z,r,g,b);
159
    VERBOSE_STR << "red multiplier value: " << r << std::endl;
160
    VERBOSE_STR << "green multiplier value: " << g << std::endl;
161
    VERBOSE_STR << "blue multiplier value: " << b << std::endl;
162
    for (int i=s; i--; )
163
    {
164
      (*X)(i) *= r;
165
      (*Y)(i) *= g;
166
      (*Z)(i) *= b;
167
    }
168
    // Convert back to XYZ
169
    pfs::transformColorSpace(pfs::CS_RGB, X, Y, Z, pfs::CS_XYZ, X, Y, Z);
170
    float amin = 1e20, amax = -1e20;
171
    for (int i=s; i--; )
172
    {
173
      float const &l = (*Y)(i);
174
      if (amin > l) amin = l;
175
      if (amax < l) amax = l;
176
    }
177
    VERBOSE_STR << "luminance range of adjusted frame: " << amin << ":" << amax << std::endl;
178
    if (keep)
179
    {
180
      float k = (max-min)/(amax-amin);
181
      float nmin = 1e20, nmax = -1e20;
182
      for (int i=s; i--; )
183
      {
184
        float const &l = ((*Y)(i)-amin)*k+min;
185
        if (nmin > l) nmin = l;
186
        if (nmax < l) nmax = l;
187
        (*Y)(i) = l;
188
        (*X)(i) *= k;
189
        (*Z)(i) *= k;
190
      }
191
      VERBOSE_STR << "restored luminance range: " << nmin << ":" << nmax << std::endl;
192
    }
193
    // Write frame
194
    pfsio.writeFrame(frame, stdout);
195
    pfsio.freeFrame(frame);        
196
  }
197
}
198
199
int main(int argc, char *const argv[])
200
{
201
  static const struct option cmdLineOptions[] = {
202
    { "help", no_argument, NULL, 'h' },
203
    { "verbose", no_argument, NULL, 'v' },
204
    { "auto", no_argument, NULL, 'A' },
205
    { "x", required_argument, NULL, 'X' },
206
    { "y", required_argument, NULL, 'Y' },
207
    { "width", required_argument, NULL, 'W' },
208
    { "height", required_argument, NULL, 'H' },
209
    { "keep-lum", no_argument, NULL, 'k' },
210
    { "red", required_argument, NULL, 'r' },
211
    { "green", required_argument, NULL, 'g' },
212
    { "blue", required_argument, NULL, 'b' },
213
    { NULL, 0, NULL, 0 }
214
  };
215
216
  try
217
  {
218
    int optionIndex = 0;
219
    while (true)
220
    {
221
      int c = getopt_long(argc, argv, "hvAX:Y:W:H:kr:g:b:", cmdLineOptions, &optionIndex);
222
      if (c == -1)
223
      {
224
        break;
225
      }
226
      switch (c)
227
      {
228
      case 'h':
229
        printHelp();
230
        throw QuietException();
231
      case 'v':
232
        verbose = true;
233
        break;
234
      case 'A':
235
        autowb = true;
236
        break;
237
      case 'X':
238
        x = (int)strtol(optarg, NULL, 10);
239
        if (x<=0)
240
          throw pfs::Exception("gray box x value out of range, should be >0");
241
      break;
242
      case 'Y':
243
        y = (int)strtol(optarg, NULL, 10);
244
        if (y<=0)
245
          throw pfs::Exception("gray box y value out of range, should be >0");
246
        break;
247
      case 'W':
248
        width = (int)strtol(optarg, NULL, 10);
249
        if (width<=0)
250
          throw pfs::Exception("gray box width value out of range, should be >0");
251
        break;
252
      case 'H':
253
      height = (int)strtol(optarg, NULL, 10);
254
        if (height<=0)
255
          throw pfs::Exception("gray box height value out of range, should be >0");
256
        break;
257
      case 'k':
258
        keep = true;
259
        break;
260
      case 'r':
261
        red = strtof(optarg, NULL);
262
        if (red<=0.0f)
263
        throw pfs::Exception("red multiplier value out of range, should be >0");
264
        break;
265
      case 'g':
266
        green = strtof(optarg, NULL);
267
        if (green<=0.0f)
268
          throw pfs::Exception("green multiplier value out of range, should be >0");
269
        break;
270
      case 'b':
271
        blue = strtof(optarg, NULL);
272
        if (blue<=0.0f)
273
        throw pfs::Exception("blue multiplier value out of range, should be >0");
274
        break;
275
      case '?':
276
        throw QuietException();
277
      case ':':
278
        throw QuietException();
279
      }
280
    }
281
282
    pfswb();
283
  }
284
  catch (std::exception const &ex)
285
  {
286
    std::cerr << PROG_NAME" error (std): " << ex.what() << std::endl;
287
    return EXIT_FAILURE;
288
  }        
289
  catch (pfs::Exception const &ex)
290
  {
291
    std::cerr << PROG_NAME" error (pfs): " << ex.getMessage() << std::endl;
292
    return EXIT_FAILURE;
293
  }        
294
  catch (QuietException const &ex)
295
  {
296
    return EXIT_FAILURE;
297
  }        
298
  return EXIT_SUCCESS;
299
}
(-)graphics/pfstools/files/port/src/octave/pfsplotresp (+34 lines)
Line 0 Link Here
1
#!/usr/bin/octave -qf
2
3
if (nargin < 1 || nargin > 2)
4
    error("Expecting arguments:\n\t<response> [<print options>]\n"); 
5
endif
6
arg_list = argv();
7
8
IY = [];
9
10
load(arg_list{1});
11
12
WM=W(max(find(W(:,1))),2);
13
Wm=W(min(find(W(:,1))),2);
14
15
#graphics_toolkit('gnuplot');
16
figure(1);
17
clf();
18
grid on;
19
grid minor on;
20
21
if rows(IY) > 0
22
    RM=max(IY(:,3));
23
    plot(IY(:,2),IY(:,3),'-g', W(:,2),W(:,1),'-k', [Wm Wm],[0 RM],'-k',[WM WM],[0 RM],'-k');
24
else
25
    RM=max(max([IR(:,3) IG(:,3) IB(:,3)]));
26
    plot(IR(:,2),IR(:,3),'-r', IG(:,2),IG(:,3),'-g', IB(:,2),IB(:,3),'-b', W(:,2),W(:,1),'-k', [Wm Wm],[0 RM],'-k',[WM WM],[0 RM],'-k');
27
endif
28
29
if nargin == 2
30
    eval(["print " arg_list{2}]);
31
else
32
    pause;
33
endif
34
close;
(-)graphics/pfstools/files/port/src/octave/pfsplotresp.1 (+33 lines)
Line 0 Link Here
1
.TH "pfsplotresp" 1
2
.SH NAME
3
pfsplotresp \- Plot response curve and weighting function using GNU Octave.
4
.SH SYNOPSIS
5
.B pfsplotresp
6
<response> [<print options>]
7
.SH DESCRIPTION
8
Use this command to polt charts of response curves and weighting functions.
9
10
Response argument is a name of file containing response produced by
11
pfshdrcalibrate(1) command with -s key.
12
13
For details about print options see GNU Octave help on print function.
14
15
.SH EXAMPLES
16
.TP
17
pfsplotresp response.m
18
19
Chart of response curve and weighting function from response.m file
20
well be plotted and displayed it using gnuplot or internal Octave
21
plotting tool.
22
23
.TP
24
pfsplotresp response.m response.png
25
26
Chart of response curve and weighting function from response.m file
27
well be plotted and displayed.
28
Also chart will be saved as a response.png image file.
29
.SH "SEE ALSO"
30
.BR pfshdrcalibrate (1)
31
.BR pfssmoothresp (1)
32
.SH BUGS
33
Please report bugs and comments to Iouri Ivliev <fbsd@any.com.ru>
(-)graphics/pfstools/files/port/src/octave/pfssmoothresp (+89 lines)
Line 0 Link Here
1
#!/usr/bin/octave -qf
2
3
pkg load signal;
4
5
if (nargin < 2 || nargin > 5)
6
    error("Expecting arguments:\n\t<src-response> <dst-response> [<levels> [<length> [<polynomial order>]]]\n"); 
7
endif
8
arg_list = argv();
9
10
l = -1;
11
if (nargin > 2)
12
    l = sscanf(arg_list{3},"%d");
13
endif
14
n = -1;
15
if (nargin > 3)
16
    n = sscanf(arg_list{4},"%d");
17
endif
18
p = 1;
19
if (nargin == 5)
20
    p = sscanf(arg_list{5},"%d");
21
endif
22
23
interp = getenv("INTERP");
24
if length(interp) == 0
25
    interp = "cubic";
26
endif
27
28
zero = 1e-31;
29
IY = [];
30
31
load(arg_list{1});
32
33
r = rows(W);
34
if l == -1
35
    l = r;
36
endif
37
if n == -1
38
    n = l/32-1;
39
endif
40
k = l/r;
41
o = 0;
42
if k > 1
43
    o = k/2;
44
endif
45
R1 = [0:r-1]'.*k.+o;
46
R2 = [0:l-1]';
47
48
fprintf(stderr,"src response levels: %d\n",rows(R1));
49
fprintf(stderr,"dst response levels: %d\n",rows(R2));
50
if k != 1
51
    fprintf(stderr,"interpolation: %s\n",interp);
52
endif
53
fprintf(stderr,"polynomial order: %d; length: %d\n",p,n);
54
55
if rows(IY) > 0
56
    IY = sgolayfilt(IY(:,3),p,(n+1)/k-1);
57
    IY(find(IY<zero)) = zero;
58
    if k != 1
59
        IY = interp1(R1,IY,R2,interp,0);
60
        W = [interp1(R1,W(:,1),R2,interp,0),R2];
61
        IY = sgolayfilt(IY,p,n);
62
        IY(find(IY<zero)) = zero;
63
    endif
64
    IY = [log10(IY),R2,IY];
65
    save(arg_list{2},'IY','W');
66
else
67
    IR = sgolayfilt(IR(:,3),p,(n+1)/k-1);
68
    IR(find(IR<zero)) = zero;
69
    IG = sgolayfilt(IG(:,3),p,(n+1)/k-1);
70
    IG(find(IG<zero)) = zero;
71
    IB = sgolayfilt(IB(:,3),p,(n+1)/k-1);
72
    IB(find(IB<zero)) = zero;
73
    if k != 1
74
        IR = interp1(R1,IR,R2,interp,0);
75
        IG = interp1(R1,IG,R2,interp,0);
76
        IB = interp1(R1,IB,R2,interp,0);
77
        W = [interp1(R1,W(:,1),R2,interp,0),R2];
78
        IR = sgolayfilt(IR,p,n);
79
        IR(find(IR<zero)) = zero;
80
        IG = sgolayfilt(IG,p,n);
81
        IG(find(IG<zero)) = zero;
82
        IB = sgolayfilt(IB,p,n);
83
        IB(find(IB<zero)) = zero;
84
    endif
85
    IR = [log10(IR),R2,IR];
86
    IG = [log10(IG),R2,IG];
87
    IB = [log10(IB),R2,IB];
88
    save(arg_list{2},'IR','IG','IB','W');
89
endif
(-)graphics/pfstools/files/port/src/octave/pfssmoothresp.1 (+46 lines)
Line 0 Link Here
1
.TH "pfssmoothresp" 1
2
.SH NAME
3
pfssmoothresp \- Smooth response curve with a Savitsky-Golay smoothing filter.
4
.SH SYNOPSIS
5
.B pfssmoothresp
6
<src-response> <dst-response> [<out-levels> [<length> [<polynomial order>]]]
7
.SH DESCRIPTION
8
Use this command to sommoth the response curves generated by pfshdrcalibrate(1).
9
When the number of output levels given by the 3rd argument does not match
10
the input, the response curve and the weighing function will be interpolated.
11
12
Sourse and destination response arguments are the file names. Sourse
13
contains response produced by pfshdrcalibrate(1) command with -s key.
14
Smoothed response will be saved into destination.
15
16
Output levels argument sets the number of levels for output response curve
17
and weighing function. Default is the same as input.
18
19
Length and polynomial order arguments are parameters of Savitsky-Golay
20
smoothing filter. For more details see GNU Octave help on sgolayfilt
21
function. Default lentgth is <out-levels>/32-1. Default polynomial order
22
is 1.
23
24
.SH ENVIRONMENT
25
.TP
26
INTERP
27
Interpolation method. For more details see GNU Octave help on interp1
28
function. Default is cubic.
29
30
.SH EXAMPLES
31
.TP
32
pfssmoothresp response.m smoothed.m
33
34
Smooth response curve from response.m file and save result into smoothed.m
35
file.
36
37
.TP
38
env INTERP=spline pfssmoothresp response.m smoothed.m $((1<<12))
39
40
Smooth response curve from response.m file and save result into smoothed.m
41
file. Response curve and weighing function will be interpolated for 4096
42
levels (12 bpp) using spline interpolation algorithm.
43
.SH "SEE ALSO"
44
.BR pfshdrcalibrate (1)
45
.SH BUGS
46
Please report bugs and comments to Iouri Ivliev <fbsd@any.com.ru>
(-)graphics/pfstools/pkg-plist (-90 / +120 lines)
Lines 1-134 Link Here
1
bin/pfsinrgbe
1
bin/dcraw2hdrgen
2
bin/pfsoutrgbe
2
bin/jpeg2hdrgen
3
bin/pfsinpfm
3
bin/pfsabsolute
4
bin/pfsoutpfm
4
%%ALIGN%%bin/pfsalign
5
bin/pfsin
5
bin/pfscat
6
bin/pfsout
7
bin/pfsoutffmpeg
8
bin/pfsinmulti
9
bin/pfsindcraw
10
bin/pfsclamp
6
bin/pfsclamp
11
bin/pfsgamma
7
bin/pfscolortransform
12
bin/pfstag
8
bin/pfscut
13
bin/pfssize
9
bin/pfsdisplayfunction
14
bin/pfsextractchannels
10
bin/pfsextractchannels
15
bin/pfspanoramic
16
bin/pfsrotate
17
bin/pfsflip
11
bin/pfsflip
18
bin/pfscut
12
bin/pfsgamma
19
bin/pfspad
13
%%GLVIEW%%bin/pfsglview
20
bin/pfscat
14
bin/pfshdrcalibrate
21
bin/pfsabsolute
15
bin/pfsin
22
bin/pfsdisplayfunction
16
bin/pfsindcraw
23
bin/pfswb
24
%%IMAGEMAGICK%%bin/pfsouthdrhtml
25
%%NETPBM%%bin/pfsinppm
26
%%NETPBM%%bin/pfsoutppm
27
%%OPENEXR%%bin/pfsinexr
17
%%OPENEXR%%bin/pfsinexr
28
%%OPENEXR%%bin/pfsoutexr
18
bin/pfsinhdrgen
19
%%IMAGEMAGICK%%bin/pfsinimgmagick
20
bin/pfsinme
21
bin/pfsinpfm
22
%%TIFF%%%%NETPBM%%bin/pfsinppm
23
bin/pfsinrgbe
29
%%TIFF%%bin/pfsintiff
24
%%TIFF%%bin/pfsintiff
30
%%TIFF%%bin/pfsouttiff
25
bin/pfsinyuv
31
%%IMAGEMAGICK%%bin/pfsinimgmagick
32
%%IMAGEMAGICK%%bin/pfsoutimgmagick
33
%%QT%%bin/pfsview
34
%%QT%%bin/pfsv
35
%%OCTAVE%%bin/pfsoctavelum
26
%%OCTAVE%%bin/pfsoctavelum
36
%%OCTAVE%%bin/pfsoctavergb
27
%%OCTAVE%%bin/pfsoctavergb
28
bin/pfsout
29
%%OPENEXR%%bin/pfsoutexr
30
%%IMAGEMAGICK%%bin/pfsouthdrhtml
31
%%IMAGEMAGICK%%bin/pfsoutimgmagick
32
bin/pfsoutpfm
33
%%TIFF%%%%NETPBM%%bin/pfsoutppm
34
bin/pfsoutrgbe
35
%%TIFF%%bin/pfsouttiff
36
bin/pfsoutyuv
37
bin/pfspad
38
bin/pfspanoramic
39
%%OCTAVE%%bin/pfsplotresp
40
bin/pfsplotresponse
41
bin/pfsretime
42
bin/pfsrotate
43
bin/pfssize
44
%%OCTAVE%%bin/pfssmoothresp
37
%%OCTAVE%%bin/pfsstat
45
%%OCTAVE%%bin/pfsstat
38
%%OPENGL%%bin/pfsglview
46
bin/pfstag
39
%%GDAL%%bin/pfsingdal
47
bin/pfstmo_drago03
40
include/pfs-1.2/pfs.h
48
bin/pfstmo_durand02
41
include/pfs-1.2/array2d.h
49
bin/pfstmo_fattal02
42
lib/libpfs-1.2.so.0.0.0
50
%%FFTW%%bin/pfstmo_ferradans11
43
lib/libpfs-1.2.so.0
51
bin/pfstmo_mai11
44
lib/libpfs-1.2.so
52
bin/pfstmo_mantiuk06
45
lib/libpfs-1.2.a
53
%%GSL%%bin/pfstmo_mantiuk08
54
bin/pfstmo_pattanaik00
55
bin/pfstmo_reinhard02
56
bin/pfstmo_reinhard05
57
%%VIEW%%bin/pfsv
58
%%VIEW%%bin/pfsview
59
bin/pfswb
60
include/pfs/array2d.h
61
include/pfs/pfs.h
62
lib/libpfs.so
63
lib/libpfs.so.2
64
lib/libpfs.so.2.0.0
65
%%OCTAVE%%%%OCTAVE_SITE_OCT%%/pfstools/pfsclose.oct
66
%%OCTAVE%%%%OCTAVE_SITE_OCT%%/pfstools/pfsget.oct
67
%%OCTAVE%%%%OCTAVE_SITE_OCT%%/pfstools/pfsopen.oct
68
%%OCTAVE%%%%OCTAVE_SITE_OCT%%/pfstools/pfsput.oct
69
%%OCTAVE%%%%OCTAVE_SITE_OCT%%/pfstools/pfsread.oct
70
%%OCTAVE%%%%OCTAVE_SITE_OCT%%/pfstools/pfstransform_colorspace.oct
71
%%OCTAVE%%%%OCTAVE_SITE_OCT%%/pfstools/pfswrite.oct
46
libdata/pkgconfig/pfs.pc
72
libdata/pkgconfig/pfs.pc
73
man/man1/dcraw2hdrgen.1.gz
74
man/man1/jpeg2hdrgen.1.gz
47
man/man1/pfsabsolute.1.gz
75
man/man1/pfsabsolute.1.gz
76
%%ALIGN%%man/man1/pfsalign.1.gz
48
man/man1/pfscat.1.gz
77
man/man1/pfscat.1.gz
49
man/man1/pfsclamp.1.gz
78
man/man1/pfsclamp.1.gz
79
man/man1/pfscolortransform.1.gz
50
man/man1/pfscut.1.gz
80
man/man1/pfscut.1.gz
51
man/man1/pfsdisplayfunction.1.gz
81
man/man1/pfsdisplayfunction.1.gz
52
man/man1/pfsextractchannels.1.gz
82
man/man1/pfsextractchannels.1.gz
53
man/man1/pfsflip.1.gz
83
man/man1/pfsflip.1.gz
54
man/man1/pfsgamma.1.gz
84
man/man1/pfsgamma.1.gz
55
%%OPENGL%%man/man1/pfsglview.1.gz
85
%%GLVIEW%%man/man1/pfsglview.1.gz
86
man/man1/pfshdrcalibrate.1.gz
56
man/man1/pfsin.1.gz
87
man/man1/pfsin.1.gz
57
man/man1/pfsindcraw.1.gz
88
man/man1/pfsindcraw.1.gz
58
man/man1/pfsinexr.1.gz
89
%%OPENEXR%%man/man1/pfsinexr.1.gz
59
man/man1/pfsingdal.1.gz
90
man/man1/pfsinhdrgen.1.gz
60
man/man1/pfsinimgmagick.1.gz
91
%%IMAGEMAGICK%%man/man1/pfsinimgmagick.1.gz
61
man/man1/pfsinjpeghdr.1.gz
92
man/man1/pfsinme.1.gz
62
man/man1/pfsinmulti.1.gz
63
man/man1/pfsinpfm.1.gz
93
man/man1/pfsinpfm.1.gz
64
man/man1/pfsinppm.1.gz
94
%%TIFF%%%%NETPBM%%man/man1/pfsinppm.1.gz
65
man/man1/pfsinrgbe.1.gz
95
man/man1/pfsinrgbe.1.gz
66
man/man1/pfsintiff.1.gz
96
%%TIFF%%man/man1/pfsintiff.1.gz
97
man/man1/pfsinyuv.1.gz
67
%%OCTAVE%%man/man1/pfsoctavelum.1.gz
98
%%OCTAVE%%man/man1/pfsoctavelum.1.gz
68
%%OCTAVE%%man/man1/pfsoctavergb.1.gz
99
%%OCTAVE%%man/man1/pfsoctavergb.1.gz
69
man/man1/pfsout.1.gz
100
man/man1/pfsout.1.gz
70
man/man1/pfsoutexr.1.gz
101
%%OPENEXR%%man/man1/pfsoutexr.1.gz
71
man/man1/pfsoutffmpeg.1.gz
72
%%IMAGEMAGICK%%man/man1/pfsouthdrhtml.1.gz
102
%%IMAGEMAGICK%%man/man1/pfsouthdrhtml.1.gz
73
man/man1/pfsoutimgmagick.1.gz
103
%%IMAGEMAGICK%%man/man1/pfsoutimgmagick.1.gz
74
man/man1/pfsoutjpeghdr.1.gz
75
man/man1/pfsoutpfm.1.gz
104
man/man1/pfsoutpfm.1.gz
76
man/man1/pfsoutppm.1.gz
105
%%TIFF%%%%NETPBM%%man/man1/pfsoutppm.1.gz
77
man/man1/pfsoutrgbe.1.gz
106
man/man1/pfsoutrgbe.1.gz
78
man/man1/pfsouttiff.1.gz
107
%%TIFF%%man/man1/pfsouttiff.1.gz
108
man/man1/pfsoutyuv.1.gz
79
man/man1/pfspad.1.gz
109
man/man1/pfspad.1.gz
80
man/man1/pfspanoramic.1.gz
110
man/man1/pfspanoramic.1.gz
111
%%OCTAVE%%man/man1/pfsplotresp.1.gz
112
man/man1/pfsplotresponse.1.gz
113
man/man1/pfsretime.1.gz
81
man/man1/pfsrotate.1.gz
114
man/man1/pfsrotate.1.gz
82
man/man1/pfssize.1.gz
115
man/man1/pfssize.1.gz
116
%%OCTAVE%%man/man1/pfssmoothresp.1.gz
83
%%OCTAVE%%man/man1/pfsstat.1.gz
117
%%OCTAVE%%man/man1/pfsstat.1.gz
84
man/man1/pfstag.1.gz
118
man/man1/pfstag.1.gz
85
%%QT%%man/man1/pfsv.1.gz
119
man/man1/pfstmo_drago03.1.gz
86
%%QT%%man/man1/pfsview.1.gz
120
man/man1/pfstmo_durand02.1.gz
121
man/man1/pfstmo_fattal02.1.gz
122
%%FFTW%%man/man1/pfstmo_ferradans11.1.gz
123
man/man1/pfstmo_mai11.1.gz
124
man/man1/pfstmo_mantiuk06.1.gz
125
%%GSL%%man/man1/pfstmo_mantiuk08.1.gz
126
man/man1/pfstmo_pattanaik00.1.gz
127
man/man1/pfstmo_reinhard02.1.gz
128
man/man1/pfstmo_reinhard05.1.gz
129
%%VIEW%%man/man1/pfsview.1.gz
130
man/man1/pfswb.1.gz
131
%%OCTAVE%%%%OCTAVE_SITE_M%%/pfstools/pfs_close_frames.m
132
%%OCTAVE%%%%OCTAVE_SITE_M%%/pfstools/pfs_open_frames.m
133
%%OCTAVE%%%%OCTAVE_SITE_M%%/pfstools/pfs_read_luminance.m
134
%%OCTAVE%%%%OCTAVE_SITE_M%%/pfstools/pfs_read_rgb.m
135
%%OCTAVE%%%%OCTAVE_SITE_M%%/pfstools/pfs_read_xyz.m
136
%%OCTAVE%%%%OCTAVE_SITE_M%%/pfstools/pfs_write_rgb.m
137
%%OCTAVE%%%%OCTAVE_SITE_M%%/pfstools/pfssize.m
138
%%OCTAVE%%%%OCTAVE_SITE_M%%/pfstools/pfsview.m
139
%%OCTAVE%%%%OCTAVE_SITE_M%%/pfstools/pfsview_list.m
140
%%OCTAVE%%%%OCTAVE_SITE_M%%/pfstools/pfsview_rgb.m
87
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_c_b2.csv
141
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_c_b2.csv
88
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_t_b2.csv
89
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_c_b3.csv
142
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_c_b3.csv
90
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_t_b3.csv
91
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_c_b4.csv
143
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_c_b4.csv
92
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_t_b4.csv
93
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_c_b5.csv
144
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_c_b5.csv
94
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_t_b5.csv
145
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_default_templ/hdrhtml_image_templ.html
95
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_default_templ/hdrhtml_page_templ.html
146
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_default_templ/hdrhtml_page_templ.html
96
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_default_templ/hdrhtml_image_templ.html
147
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/hdr_viewer.css
97
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/loading-spinner.gif
148
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/hdr_viewer.js
98
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/information-red.png
149
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/information-red.png
99
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/slider-red.png
100
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/hdr_viewer.js
101
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/slider-black.png
102
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/information.png
150
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/information.png
151
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/loading-spinner.gif
152
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/mootools-1.2.4.js
103
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/mouse2touch.js
153
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/mouse2touch.js
104
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/mootools-1.2.4.js
154
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/slider-black.png
105
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/hdr_viewer.css
155
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/slider-red.png
106
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/slider-white.png
156
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets/slider-white.png
157
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_image_templ.html
158
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_image_templ_slider-above.html
107
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_page_templ.html
159
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_page_templ.html
108
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_image_templ_slider-above.html
109
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_image_templ.html
110
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_page_templ_short.html
160
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_page_templ_short.html
111
@dir include/pfs-1.2
161
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_t_b2.csv
112
%%IMAGEMAGICK%%@dir %%DATADIR%%/hdrhtml_hdrlabs_templ/hdrhtml_assets
162
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_t_b3.csv
113
%%IMAGEMAGICK%%@dir %%DATADIR%%/hdrhtml_hdrlabs_templ
163
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_t_b4.csv
114
%%IMAGEMAGICK%%@dir %%DATADIR%%/hdrhtml_default_templ
164
%%IMAGEMAGICK%%%%DATADIR%%/hdrhtml_t_b5.csv
115
%%IMAGEMAGICK%%@dir %%DATADIR%%
116
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_OCT%%/pfstools/pfsclose.oct
117
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_OCT%%/pfstools/pfsget.oct
118
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_OCT%%/pfstools/pfsopen.oct
119
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_OCT%%/pfstools/pfsput.oct
120
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_OCT%%/pfstools/pfsread.oct
121
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_OCT%%/pfstools/pfstransform_colorspace.oct
122
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_OCT%%/pfstools/pfswrite.oct
123
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_M%%/pfstools/pfs_close_frames.m
124
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_M%%/pfstools/pfs_open_frames.m
125
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_M%%/pfstools/pfs_read_luminance.m
126
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_M%%/pfstools/pfs_read_rgb.m
127
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_M%%/pfstools/pfs_read_xyz.m
128
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_M%%/pfstools/pfs_write_rgb.m
129
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_M%%/pfstools/pfssize.m
130
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_M%%/pfstools/pfsview.m
131
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_M%%/pfstools/pfsview_list.m
132
%%OCTAVE%%%%OCTAVE_BASE%%/%%OCTAVE_SITE_M%%/pfstools/pfsview_rgb.m
133
%%OCTAVE%%@dir %%OCTAVE_SITE_OCT%%/pfstools
134
%%OCTAVE%%@dir %%OCTAVE_SITE_M%%/pfstools

Return to bug 226185