1 /*
2  *  ColourBrightness
3  *
4  *  Based on the program PTStitcher by Helmut Dersch.
5  *
6  *  It is intended to duplicate the functionality of original program
7  *
8  *  Dec 2005
9  *
10  *  This program is free software; you can redistribute it and/or
11  *  modify it under the terms of the GNU General Public
12  *  License as published by the Free Software Foundation; either
13  *  version 2 of the License, or (at your option) any later version.
14  *
15  *  This software is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  *  General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with this software; see the file COPYING.  If not, a copy
22  *  can be downloaded from http://www.gnu.org/licenses/gpl.html, or
23  *  obtained by writing to the Free Software Foundation, Inc.,
24  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25  *
26  *
27  *  Author: Daniel M German dmgerman at uvic doooot ca
28  *
29  */
30 
31 
32 
33 
34 #ifndef __COLOUR_BRIGHTNESS__
35 
36 typedef double (*calla_function)(double [], double, int);
37 typedef double *magnolia_array;
38 
39 typedef struct {
40   int components; // number of components
41   magnolia_array fieldx04[6]; // pointer to arrays  double[fieldx00]
42   calla_function function; // a function //offset 0x1c
43 } magnolia_struct;
44 
45 
46 typedef int *(histogram_type[6]);
47 
48 
49 typedef struct  {
50   int overlappingPixels; //initialy zero
51   int bytesPerSample; // bytesPerSample
52   int numberDifferentValues; //used as a size to allocate pointers below
53   int baseImageNumber; // image number
54   int otherImageNumber;
55   histogram_type ptrBaseHistograms; // array of pointers 6
56   // it seems to get the "raw" histogram
57   histogram_type ptrOtherHistograms; // array of 6 pointers
58   // this has some processing done
59 } histograms_struct;
60 
61 typedef struct {
62   fullPath * fullPathImages; //<- the struct starts here (size 20)
63   int numberImages;   // int counterImages
64   int indexReferenceImage;   // contains nfix
65   histograms_struct *ptrHistograms;   // seems to be a pointer to an array of pointers, returned by Unknown34
66   magnolia_struct *magnolia;  // This looks like a pointer to  array of counterImages * magnolia_struct,
67   // returned by Initialize_Magnolia
68 } calla_struct;
69 
70 
71 PANO13_IMPEX histograms_struct*ReadHistograms (fullPath *fullPathImages, int counterImages);
72 PANO13_IMPEX int               ComputeColourBrightnessCorrection(calla_struct *calla);
73 PANO13_IMPEX int               CorrectFileColourBrightness(fullPath *inPath, fullPath *outPath, magnolia_struct *magnolia, int parm3);
74 PANO13_IMPEX int               FindNextCandidate(int candidates[], calla_struct *calla);
75 
76 PANO13_IMPEX magnolia_struct   *InitializeMagnolia(int numberImages, int size, calla_function parm2);
77 PANO13_IMPEX void              ColourBrightness(  fullPath *fullPathImages, fullPath *outFullPathImages, int counterImages, int indexReferenceImage, int parm3,int createCurvesType);
78 PANO13_IMPEX void              CorrectImageColourBrigthness(Image *image, magnolia_struct *magnolia, int parm3);
79 PANO13_IMPEX void              FreeHistograms(histograms_struct *ptrHistograms, int count);
80 PANO13_IMPEX void              RemapHistogram(int *histogram, double *array, magnolia_struct *magnolia, int channel);
81 PANO13_IMPEX void              ComputeAdjustmentCurve(double *sourceHistogram, double *targetHistogram, double *curve) ;
82 unsigned char Unknown47(unsigned char parm0, unsigned char parm1, unsigned char parm2);
83 unsigned char Unknown48(unsigned char parm0, unsigned char parm1, unsigned char parm2);
84 unsigned char Unknown49(unsigned char parm0, unsigned char parm1, unsigned char parm2);
85 
86 PANO13_IMPEX double            MapFunction(double p[], double x, int n);
87 PANO13_IMPEX int               RemapPoint(int value, double mapTable[]) ;
88 
89 PANO13_IMPEX unsigned char panoColourComputeHue(unsigned char red, unsigned char green, unsigned char blue);
90 PANO13_IMPEX unsigned char panoColourComputeIntensity(unsigned char red, unsigned char green, unsigned char blue);
91 PANO13_IMPEX unsigned char panoColourComputeSaturation (unsigned char red, unsigned char green, unsigned char blue);
92 
93 
94 /* The parameter createCurvesType indicates the type of output format: arbitrary map (.amp) or smooth map (.acv).
95    if zero no map is output
96 */
97 
98 #define CB_OUTPUT_CURVE_ARBITRARY 1
99 #define CB_OUTPUT_CURVE_SMOOTH    2
100 
101 
102 #endif
103 
104 
105