a3a92abf1ca043aaaaaa79381afa316abaa00ace
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

1) /*
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

2)  * EtherPix library
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

3)  *
Stefan Schuermans removed version information...

Stefan Schuermans authored 13 years ago

4)  * Copyright 2010-2011 Stefan Schuermans <stefan schuermans info>
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

5)  *
6)  * This program is free software: you can redistribute it and/or modify
7)  * it under the terms of the GNU General Public License as published by
8)  * the Free Software Foundation, version 3 of the License.
9)  *
10)  *
11)  * This program is distributed in the hope that it will be useful,
12)  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13)  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14)  * GNU General Public License for more details.
15)  *
16)  * You should have received a copy of the GNU Lesser General Public License
17)  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18)  */
19) 
20) #include <math.h>
21) 
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

22) #include <etherpix/types.h>
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

23) #include <intern/mapping.h>
24) #include <intern/types.h>
25) 
26) /**
27)  * \brief precalculate mapping table
28)  *
29)  * updates the internal lookup table according to the parameters
30)  *
31)  * \param[in,out] p_mapping mapping to precalculate
32)  */
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

33) void etp_mapping_precalc(etp_mapping_t *p_mapping)
Stefan Schuermans v1.0.0

Stefan Schuermans authored 13 years ago

34) {
35)   double gamma_1;
36)   int v;
37) 
38)   /* precalculate 1 / gamma */
39)   gamma_1 = 1.0 / p_mapping->gamma;
40) 
41)   /* map all values */
42)   for (v = 0; v < 256; v++) {
43)     double val = p_mapping->base
44)                + p_mapping->factor * pow((double)v / 255.0, gamma_1);
45)     if (val < 0.0)
46)       p_mapping->table[v] = 0;
47)     else if (val > 1.0)
48)       p_mapping->table[v] = 255;
49)     else
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

50)       p_mapping->table[v] = (etp_u8_t)(val * 255.0 + 0.5);