~ubuntu-branches/ubuntu/jaunty/freeimage/jaunty

« back to all changes in this revision

Viewing changes to FreeImage/Source/FreeImage/ToneMapping.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Federico Di Gregorio
  • Date: 2007-05-07 15:35:21 UTC
  • Revision ID: james.westby@ubuntu.com-20070507153521-m4lx765bzxxug9qf
Tags: upstream-3.9.3
Import upstream version 3.9.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ==========================================================
 
2
// Tone mapping operators
 
3
//
 
4
// Design and implementation by
 
5
// - Herv� Drolon (drolon@infonie.fr)
 
6
//
 
7
// This file is part of FreeImage 3
 
8
//
 
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
 
17
// THIS DISCLAIMER.
 
18
//
 
19
// Use at your own risk!
 
20
// ==========================================================
 
21
 
 
22
#include "FreeImage.h"
 
23
#include "Utilities.h"
 
24
 
 
25
/**
 
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
 
34
*/ 
 
35
FIBITMAP * DLL_CALLCONV
 
36
FreeImage_ToneMapping(FIBITMAP *dib, FREE_IMAGE_TMO tmo, double first_param, double second_param) {
 
37
        if(dib) {
 
38
                switch(tmo) {
 
39
                        // Adaptive logarithmic mapping (F. Drago, 2003)
 
40
                        case FITMO_DRAGO03:
 
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);
 
44
                                } else {
 
45
                                        // use user's value
 
46
                                        return FreeImage_TmoDrago03(dib, first_param, second_param);
 
47
                                }
 
48
                                break;
 
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);
 
54
                                } else {
 
55
                                        // use user's value
 
56
                                        return FreeImage_TmoReinhard05(dib, first_param, second_param);
 
57
                                }
 
58
                                break;
 
59
                }
 
60
        }
 
61
 
 
62
        return NULL;
 
63
}
 
64
 
 
65