18 #ifndef PIC_ALGORITHMS_HISTOGRAM_MATCHING_HPP 19 #define PIC_ALGORITHMS_HISTOGRAM_MATCHING_HPP 21 #include "../base.hpp" 23 #include "../image.hpp" 24 #include "../image_vec.hpp" 25 #include "../histogram.hpp" 27 #include "../util/std_util.hpp" 56 for(
int i = 0; i < channels; i++) {
64 hist_t[i].
uniform(hist_s[i].getfMin(),
69 hist_s[i].
clip(clip_value_ui);
70 hist_t[i].
clip(clip_value_ui);
84 for(
int i = 0 ; i < channels; i++) {
91 int *tmp_lut =
new int[
nBin];
93 for(
int j = 0; j <
nBin; j++) {
95 float *ptr = std::upper_bound(c_t, c_t +
nBin, x);
96 tmp_lut[j] =
MAX((
int)(ptr - c_t), 0);
99 lut.push_back(tmp_lut);
133 Image *img_source = NULL;
134 Image *img_target = NULL;
138 img_source = imgIn[0];
143 img_target = imgIn[1];
145 if(imgIn[0]->channels != imgIn[1]->channels) {
158 imgOut = imgIn[count]->
clone();
160 if(!imgOut->isSimilarType(imgIn[count])) {
165 int channels = img_source->
channels;
172 std::vector<int *> lut;
173 computeLUT(h_source, h_target, channels, lut);
175 for(
int i = 0; i < imgOut->size(); i += channels) {
177 for(
int j = 0; j < channels; j++) {
180 int ind_source = h_source[j].
project(img_source->
data[k]);
182 int ind_target = lut[j][ind_source];
184 imgOut->data[k] = h_target[j].
unproject(ind_target);
PIC_INLINE bool ImageVecCheck(ImageVec &imgIn, int minInputImages)
ImageVecCheck.
Definition: image_vec.hpp:147
unsigned int uint
Definition: base.hpp:23
float * cumulativef(bool bNormalized)
cumulativef computes the cumulative Histogram.
Definition: histogram.hpp:440
void update(int nBin, float clip_value=1.0f)
update
Definition: histogram_matching.hpp:118
void calculate(Image *imgIn, VALUE_SPACE type=VS_LIN, int nBin=256, BBox *box=NULL, int channel=0)
calculate computes the histogram of an input image. In the case of LDR images, they are ssumed to be ...
Definition: histogram.hpp:213
float * data
data is the main buffer where pixel values are stored.
Definition: image.hpp:91
int channels
Definition: image.hpp:80
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
The Histogram class is a class for creating, managing, loading, and saving histogram for an Image...
Definition: histogram.hpp:37
Image * Process(ImageVec imgIn, Image *imgOut=NULL)
Process.
Definition: histogram_matching.hpp:131
static Image * execute(Image *img_source, Image *img_target, Image *imgOut=NULL)
execute
Definition: histogram_matching.hpp:203
static Image * executeEqualization(Image *img, Image *imgOut=NULL, float clip_value=0.9f)
executeEqualization
Definition: histogram_matching.hpp:217
Definition: histogram_matching.hpp:31
float clip_value
Definition: histogram_matching.hpp:36
void stdVectorArrayClear(std::vector< T *> &vec)
stdVectorArrayClear
Definition: std_util.hpp:71
void clip(uint value)
clip clips the histogram to value.
Definition: histogram.hpp:409
float * getCumulativef()
getCumulativef this function returns the cumulative Histogram. Note that cumulativef needs to be comp...
Definition: histogram.hpp:459
bool bClipping
Definition: histogram_matching.hpp:35
int nPixels() const
nPixels computes the number of pixels.
Definition: image.hpp:499
int project(float x)
project converts an input value in the histogram domain.
Definition: histogram.hpp:337
PIC_INLINE ImageVec Double(Image *img1, Image *img2)
Double creates an std::vector which contains img1 and img2; this is for filters input.
Definition: image_vec.hpp:49
Definition: histogram.hpp:31
float unproject(int ind)
unproject converts a histogram value back to its original domain.
Definition: histogram.hpp:352
void computeLUT(Histogram *hist_s, Histogram *hist_t, int channels, std::vector< int *> &lut)
computeLUT
Definition: histogram_matching.hpp:82
The Image class stores an image as buffer of float.
Definition: image.hpp:60
void computeHistograms(Image *img_s, Image *img_t, Histogram *hist_s, Histogram *hist_t)
computeHistograms
Definition: histogram_matching.hpp:45
Image * clone() const
Clone creates a deep copy of the calling instance.
Image * allocateSimilarOne()
allocateSimilarOne creates an Image with similar size of the calling instance.
Definition: bilateral_separation.hpp:25
#define MAX(a, b)
Definition: math.hpp:73
HistogramMatching()
HistogramMatching.
Definition: histogram_matching.hpp:108
void uniform(float fMin, float fMax, uint value, VALUE_SPACE type, int nBin)
uniform
Definition: histogram.hpp:298
int nBin
Definition: histogram_matching.hpp:34