QMap<QRgb,long> histo; // histogram map
QMap<QRgb,long>::iterator j;
QRgb c = 0;
int l, k;
histo.clear();
for(k = 0; k < prev_image.width(); ++k)
for( l = 0; l < prev_image.height(); ++l) {
c = prev_image.pixel(k,l);
if(!histo.contains(c))
histo.insert(c,0);
}
//computation of occurences
for( k = 0; k < prev_image.width(); ++k)
for( l = 0; l < prev_image.height(); ++l) {
c = prev_image.pixel(k,l);
histo[c] = histo[c]+1;
}
//compute average value
long sum_1 = 0;
long sum_2 = 0;
for(j = histo.begin();j!=histo.end();j++)
{
sum_1+=j.value()*j.key();
}
for(j = histo.begin();j!=histo.end();j++)
{
sum_2+=j.value();
}
long av = sum_1/sum_2;
av_r = qRed(av);
av_g = qGreen(av);
av_b = qBlue(av);
//changing contrast of an image by factor getted from horizontal slider ui:
double factor = (double)( (double)ie->horizontalSlider_2->value() )/100 ; // to change also //got to be a value between 0 - 1
if(factor!=0.99)
for (int y = 0; y < prev_image.height(); ++y) {
for (int x = 0; x < prev_image.width(); ++x) {
c = QRgb(prev_image.pixel(x,y));
col.getRgb(&r,&g,&b);
r = (int)(r*(1-factor)+av_r*factor);
g = (int)(g*(1-factor)+av_g*factor);
b = (int)(b*(1-factor)+av_b*factor);
if(r>255)
r=255;
if(g>255)
g=255;
if(b>255)
b=255;
imageToProcess->setPixel(x,y,qRgb(r,g,b));
}
}
if(factor!=0.99)
this
->ie
->label_11
->setPixmap
(QPixmap::fromImage(imageToProcess
->scaled
(this
->ie
->label_11
->size
(),Qt
::KeepAspectRatio,Qt
::SmoothTransformation)));
else
this
->ie
->label_11
->setPixmap
(QPixmap::fromImage(prev_image.
scaled(this
->ie
->label_11
->size
(),Qt
::KeepAspectRatio,Qt
::SmoothTransformation)));
QMap<QRgb,long> histo; // histogram map
QMap<QRgb,long>::iterator j;
QRgb c = 0;
int l, k;
histo.clear();
for(k = 0; k < prev_image.width(); ++k)
for( l = 0; l < prev_image.height(); ++l) {
c = prev_image.pixel(k,l);
if(!histo.contains(c))
histo.insert(c,0);
}
//computation of occurences
for( k = 0; k < prev_image.width(); ++k)
for( l = 0; l < prev_image.height(); ++l) {
c = prev_image.pixel(k,l);
histo[c] = histo[c]+1;
}
//compute average value
long sum_1 = 0;
long sum_2 = 0;
for(j = histo.begin();j!=histo.end();j++)
{
sum_1+=j.value()*j.key();
}
for(j = histo.begin();j!=histo.end();j++)
{
sum_2+=j.value();
}
long av = sum_1/sum_2;
av_r = qRed(av);
av_g = qGreen(av);
av_b = qBlue(av);
//changing contrast of an image by factor getted from horizontal slider ui:
double factor = (double)( (double)ie->horizontalSlider_2->value() )/100 ; // to change also //got to be a value between 0 - 1
if(factor!=0.99)
for (int y = 0; y < prev_image.height(); ++y) {
for (int x = 0; x < prev_image.width(); ++x) {
c = QRgb(prev_image.pixel(x,y));
QColor col(c);
col.getRgb(&r,&g,&b);
r = (int)(r*(1-factor)+av_r*factor);
g = (int)(g*(1-factor)+av_g*factor);
b = (int)(b*(1-factor)+av_b*factor);
if(r>255)
r=255;
if(g>255)
g=255;
if(b>255)
b=255;
imageToProcess->setPixel(x,y,qRgb(r,g,b));
}
}
if(factor!=0.99)
this->ie->label_11->setPixmap(QPixmap::fromImage(imageToProcess->scaled(this->ie->label_11->size(),Qt::KeepAspectRatio,Qt::SmoothTransformation)));
else
this->ie->label_11->setPixmap(QPixmap::fromImage(prev_image.scaled(this->ie->label_11->size(),Qt::KeepAspectRatio,Qt::SmoothTransformation)));
To copy to clipboard, switch view to plain text mode
Bookmarks