Raw File
libmlhe.h
/*----------------------------------------------------------------------------

Copyright (c) 2018 J.L. Lisani (joseluis.lisani@uib.es)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

----------------------------------------------------------------------------*/

#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

class mlhe {
    public:
        mlhe(unsigned char *Iinput, int w, int h);
        ~mlhe();
        void apply_algorithm(int L, int A, float rrmax, float rrmin, int option,
                             int PAE_N, float PAE_smin, float PAE_smax,
                             float CLAHE_clip);
        unsigned char *get_result();

    private:
        void clahe(int *selected, int nselected,
                   int min, int max); //implements Algorithm 7
        void piecewise_affine_histogram_equalization(int *selected, 
                                                     int nselected,
                                                     int min, 
                                                     int max); //implements 
                                                               //Algorithm 8
        void histogram_equalization(int *selected, int nselected,
                                    int min, int max); //implements Algorithm 5
        void fill_cc(vector<int> &cc, int p); //implements Algorithm 4
        void process_bilevelset(int *selected, int nselected, 
                                int min, int max); //implements Algorithm 3
        void recursive_histo(int *selected, int nselected, 
                             int min, int max); //implements Algorithm 2
                 
        //auxiliary variables            
        int w, h;
        bool *marked;
        unsigned char *I;
    
        //Parameters
        int Lmax;
        int Amin;
        float rmax, rmin;
        int optionHE; //1: HE, 2: PAE, 3: CLAHE
        int N;
        float smin, smax;
        float clip;
};


back to top