Skip to content
Snippets Groups Projects
Commit ce4b39cc authored by Provot Bertrand's avatar Provot Bertrand
Browse files

Merge remote-tracking branch 'origin/dev2018' into dev2018

parents a77b1411 189d5326
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@
#include <QDoubleSpinBox>
#include <QDialogButtonBox>
#include <QApplication>
#include <Histogram.h>
using namespace std;
using namespace imagein;
......@@ -73,22 +74,16 @@ Image* HistogramOp::equalize( const Image *img ) {
Image* resImg = new Image(img->getWidth(), img->getHeight(), img->getNbChannels());
for(unsigned int c = 0; c < img->getNbChannels(); ++c) {
Histogram hist_data = img->getHistogram(c);
double hist_sum[256];
long sum = 0;
for(int counter=0; counter< 256; counter++ ) {
sum = sum + hist_data[counter];
hist_sum[counter] = sum;
}
double area = img->getWidth() * img->getHeight();
double Dm = 256; // number of levels in output image
CumulatedHistogram hist_sum = CumulatedHistogram(*img, c);
double Dm = 255; // number of levels in output image
for(unsigned int j = 0; j < img->getHeight(); ++j) {
for(unsigned int i = 0; i < img->getWidth(); ++i) {
double K = img->getPixel(i, j, c);
K = Dm / area * hist_sum[(int)K];
K = Dm * hist_sum[(int)K];
if( K < 0 ) K = 0;
if( K > 255 ) K = 255;
resImg->setPixel(i, j, c, K);
resImg->setPixel(i, j, c, K);
}
}
}
......@@ -100,17 +95,10 @@ Image* HistogramOp::equalize( const Image *img ) {
Image *HistogramOp::normalize( const Image *img ) {
Image* resImg = new Image(img->getWidth(), img->getHeight(), img->getNbChannels());
Image* resImg = new Image(*img);
for(unsigned int c = 0; c < img->getNbChannels(); ++c) {
Histogram hist_data = img->getHistogram(c);
int min=255,max=0;
for(int counter=0; counter< 256; counter++ ) {
if(hist_data[255-counter]!=0)
min=255-counter;
if(hist_data[counter]!=0)
max=counter;
}
int min = img->min(c);
int max = img->max(c);
for(unsigned int j = 0; j < img->getHeight(); ++j) {
for(unsigned int i = 0; i < img->getWidth(); ++i) {
double K = img->getPixel(i, j, c);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment