Changeset 69365


Ignore:
Timestamp:
Sep 4, 2016, 9:54:56 AM (8 years ago)
Author:
Nikos Alexandris
Message:

i.rgb.his (sandbox): set hue to NULL if achromatic case is true

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/alexandris/i.rgb.his/rgb2his.c

    r69364 r69365  
    2020#include <math.h>
    2121
     22/*
     23 * (input/output) rowbuffer
     24 * columns
     25 * maximum level of range 2^bit_depth
     26 */
    2227
    2328void rgb2his(DCELL *rowbuffer[3], int columns, double max_level)
     29
    2430{
    2531    int column;         /* column indicator               */
     
    3642for (column = 0; column < columns; column++) {
    3743
    38         if (Rast_is_d_null_value(&rowbuffer[0][column]) ||
    39             Rast_is_d_null_value(&rowbuffer[1][column]) ||
    40             Rast_is_d_null_value(&rowbuffer[2][column])) {
     44    if (Rast_is_d_null_value(&rowbuffer[0][column]) ||
     45        Rast_is_d_null_value(&rowbuffer[1][column]) ||
     46        Rast_is_d_null_value(&rowbuffer[2][column])) {
    4147            Rast_set_d_null_value(&rowbuffer[0][column], 1);
    4248            Rast_set_d_null_value(&rowbuffer[1][column], 1);
     
    8490
    8591        /* undefined -- (how to) set to NULL? */
    86         hue = 0.0;
     92        hue = -1;
    8793
    88         rowbuffer[0][column] = (FCELL)hue;
    89         rowbuffer[1][column] = (FCELL)saturation;
    90         rowbuffer[2][column] = (FCELL)lightness;
    9194    }
    9295
     
    113116            hue += 360.0;
    114117
    115         /* HSL output values */
     118    }
     119
     120    /* HSL output values */
     121    if (hue == -1.0) {
     122            Rast_set_d_null_value(&rowbuffer[0][column], 1);
     123    }
     124    else
     125    {
    116126        rowbuffer[0][column] = (FCELL)hue;
    117         rowbuffer[1][column] = (FCELL)saturation;
    118         rowbuffer[2][column] = (FCELL)lightness;
    119127    }
     128
     129    rowbuffer[1][column] = (FCELL)saturation;
     130    rowbuffer[2][column] = (FCELL)lightness;
    120131
    121132    G_debug(2, "Output rowbuffers 0, 1, 2: %f, %f, %f\n",
Note: See TracChangeset for help on using the changeset viewer.