The code for hue is: hmix = CLIP(in[0] * data->red[CHANNEL_HUE]) + (in[1] * data->green[CHANNEL_HUE]) + (in[2] * data->blue[CHANNEL_HUE]);
'in' is the input pixel array. The code basically just multiply the red, green and blue channels by the weights in 'data' and sum them up. As you can see, the CLIP is applied only to the red transformation. If the green or blue calculations results are out of range (< 0 or > 1), the final result will be out of range. It is the same for the saturation (smix) and lightness (lmix). Further in the code we have this line: rmix = CLIP((out[0] * data->red[CHANNEL_RED]) + (out[1] * data->green[CHANNEL_RED]) + (out[2] * data->blue[CHANNEL_RED])); Here a similar calculation is done, but this time the CLIP macro is applied to the final result, not only to the red piece. It is the same for the gray (graymix), green(gmix) and blue (bmix). So was it on purpose to clip only part of the calculation? Cheers -- Caio S. Souza Laboratório de Biologia Teórica e Computacional Universidade de Brasília www.lbtc.unb.br 2015-11-27 8:30 GMT-02:00 Tobias Ellinghaus <m...@houz.org>: > Am Donnerstag, 26. November 2015, 22:48:26 schrieb Caio S. Souza: >> Hello! > > Hi. > >> I'm almost done implementing this feature, but I have two questions. >> 1) I had to add one entry to the struct dt_iop_channelmixer_params_t >> to store where the correction must be applied. Should I increment the >> version in the DT_MODULE_INTROSPECTION macro? > > Yes. > >> 2) The final outputs of red, green, blue and gray channels are clipped >> to avoid out of range values. But the clip is applied only partially >> for the hue, lightness and saturation (on both CPU and opencl >> versions). Was it on purpose or is it a bug? > > I haven't looked at the code, but in general we should try to avoid clipping > wherever possible. > >> Cheers > > Tobias > > [...] ___________________________________________________________________________ darktable developer mailing list to unsubscribe send a mail to darktable-dev+unsubscr...@lists.darktable.org