1
// ==========================================================
2
// Tone mapping operators
4
// Design and implementation by
5
// - Herv� Drolon (drolon@infonie.fr)
7
// This file is part of FreeImage 3
9
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
10
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
11
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
12
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
13
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
14
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
15
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
16
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
19
// Use at your own risk!
20
// ==========================================================
22
#include "FreeImage.h"
23
#include "Utilities.h"
26
Performs a tone mapping on a 48-bit RGB or a 96-bit RGBF image and returns a 24-bit image.
27
The meaning of the parameters depends on the choosen algorithm.
28
When both parameters are set to zero, a default set of parameters is used.
29
@param dib Input RGB/RGBF image
30
@param tmo Tone mapping operator
31
@param first_param First parameter of the algorithm
32
@param second_param Second parameter of the algorithm
33
return Returns a 24-bit tone mapped image if successful, returns NULL otherwise
35
FIBITMAP * DLL_CALLCONV
36
FreeImage_ToneMapping(FIBITMAP *dib, FREE_IMAGE_TMO tmo, double first_param, double second_param) {
39
// Adaptive logarithmic mapping (F. Drago, 2003)
41
if((first_param == 0) && (second_param == 0)) {
42
// use default values (gamma = 2.2, exposure = 0)
43
return FreeImage_TmoDrago03(dib, 2.2, 0);
46
return FreeImage_TmoDrago03(dib, first_param, second_param);
49
// Dynamic range reduction inspired by photoreceptor phhysiology (E. Reinhard, 2005)
50
case FITMO_REINHARD05:
51
if((first_param == 0) && (second_param == 0)) {
52
// use default values by setting intensity to 0 and contrast to 0
53
return FreeImage_TmoReinhard05(dib, 0, 0);
56
return FreeImage_TmoReinhard05(dib, first_param, second_param);