Corrections des commandes couleurs

* Luminosité & Saturation : multiplication au lieu d'addition
* Le zéro de saturation était mal géré
This commit is contained in:
Geoffrey Frogeye 2014-05-22 21:26:51 +02:00
parent 82a60fccf9
commit 68694e3d73
3 changed files with 8 additions and 9 deletions

View file

@ -12,7 +12,7 @@ Nos noms complets et le nom du lycée sont masqués pour des raisons d'intimité
###Le programme
Ce programme est un éditeur basique d'images [PBM/PGM/PPM](http://fr.wikipedia.org/wiki/Portable_pixmap) sexécutant en ligne de commande.
*Version :* v1.0.0
*Version :* v1.0.1
*Status :* [![Build Status](https://travis-ci.org/GeoffreyFrogeye/PILG.svg?branch=master)](https://travis-ci.org/GeoffreyFrogeye/PILG)

View file

@ -398,7 +398,7 @@ int saturation(Image entree, Image &sortie,
for (int y = 0; y < sortie.g_dimensionY(); y++) {
entree.g_pixel(x, y, pixel);
rvb2tsl(pixel, tsl);
tsl.s += saturation;
tsl.s *= saturation;
tsl.s = tsl.s > 1 ? 1 : (tsl.s < 0 ? 0 : tsl.s);
tsl2rvb(tsl, pixel);
sortie.s_pixel(x, y, pixel);
@ -418,7 +418,7 @@ int luminosite(Image entree, Image &sortie,
for (int y = 0; y < sortie.g_dimensionY(); y++) {
entree.g_pixel(x, y, pixel);
rvb2tsl(pixel, tsl);
tsl.l += luminosite;
tsl.l *= luminosite;
tsl.l = tsl.l > 1 ? 1 : (tsl.l < 0 ? 0 : tsl.l);
tsl2rvb(tsl, pixel);
sortie.s_pixel(x, y, pixel);

View file

@ -66,14 +66,14 @@ int tsl2rvb(TSL entree, Pixel &sortie) {
}
if (entree.s == 0) {
fill_n(c, 3, entree.l * 255);
fill_n(c, 3, entree.l);
} else {
fill_n(t3, 3, 0);
fill_n(c, 3, 0);
t2 = entree.l < 0.5 ? entree.l * (1 + entree.s) : entree.l + entree.s - entree.l
* entree.s;
t1 = 2 * entree.l - t2;
entree.t /= 360;
entree.t /= 360.0;
t3[0] = entree.t + 1 / 3.0;
t3[1] = entree.t;
t3[2] = entree.t - 1 / 3.0;
@ -97,12 +97,11 @@ int tsl2rvb(TSL entree, Pixel &sortie) {
c[i] = t1;
}
}
sortie.r = c[0] * sortie.maxComposante;
sortie.v = c[1] * sortie.maxComposante;
sortie.b = c[2] * sortie.maxComposante;
}
sortie.r = c[0] * sortie.maxComposante;
sortie.v = c[1] * sortie.maxComposante;
sortie.b = c[2] * sortie.maxComposante;
return 0;
}