Bonjour,

J'ai un problème: j'essaye de récupérer 3 images représentant respectivement les composants HSL (Hue/Saturation/Lightness) d'une image. Je pensais que cela serait facile car tout est déjà dans Qt pour le faire.
La vitesse n'est pas un point crucial donc j'utilise avec excès setpixel et getpixel (attendons déjà que ça fonctionne LOL ).
Voici mon bout de code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
    static void ComputeImagesHSL(QImage& oimg, QImage& H, QImage& S, QImage& L)
    {
        QColor colorRGB;
        QColor colorH, colorS, colorL;
        H = S = L = oimg; //modify!
 
 
        qreal hf, sf, lf, af;
 
        //int32_t * pRGBA = image.bits();
 
        for (int y = 0; y <oimg.height(); y++)
        {
            for (int x = 0; x <oimg.width(); x++)
            {
                colorRGB = oimg.pixel(x, y);
                colorRGB.getHslF(&hf, &sf ,&lf, &af);
 
                int t;
                if(!colorRGB.isValid())
                    t=0;
                //qDebug("%5.3f %5.3f %5.3f %5.3f", hf,sf,lf,af);
               // hf = hf/360.0f;
                //hf = qMin(hf, (qreal)1.0f);
                //hf = qMax(hf, (qreal)0.0f);
                if(hf<0)
                    hf = 0;
 
                if(hf>1)
                    hf=1;
 
                colorH = QColor::fromRgbF(hf,hf,hf,af);
                colorS = QColor::fromRgbF(sf,sf,sf,af);
                colorL = QColor::fromRgbF(lf,lf,lf,af);
 
                if(!colorH.isValid())
                    t=0;
 
                H.setPixel(x, y, colorH.rgb());
                S.setPixel(x, y, colorS.rgb());
                L.setPixel(x, y, colorL.rgb());
            }
        }
J'ai placé des breakpoints sur les différents if: aucun ne déclenche!

Mon image H lorsque je l'affiche présente de grosse zone saturée blanche. Cela ne correspond pas du tout à la couche Hue que je suis censé récupérer...

Si quelqu'un à une idée!!!