Exemplo n.º 1
0
def melonize(img, n_frames):
    hsl = nphusl.to_husl(img)
    hue, sat, lit = (hsl[..., n] for n in range(3))
    #sat[:] = 99
    pink = 360  # very end of the H spectrum
    green = 130

    def gen_chunksizes():
        yield from range(1, 100)
        yield from range(100, 1, -1)

    for chunksize in gen_chunksizes():
        hsl_out = hsl.copy()
        hue_out, sat_out, lit_out = (hsl_out[..., i] for i in range(3))
        for low, high in nphusl.chunk(100, chunksize):  # chunks of the hue range
            select = np.logical_and(lit > low, lit < high)
            is_odd = low % (chunksize * 2)
            color = pink if is_odd else green
            hue_out[select] = color
            select = np.logical_and(lit > (low - 1), lit < low)
            select = np.logical_and(select, lit > 60)
            ave = (low + high) / 2
            select = np.logical_and(lit > (ave - 2), lit < (ave + 2))
            sat_out[select] = 100
        yield nphusl.to_rgb(hsl_out)
Exemplo n.º 2
0
def melonize(img, n_frames):
    hsl = nphusl.to_husl(img)
    hue, sat, lit = (hsl[..., n] for n in range(3))
    #sat[:] = 99
    pink = 360  # very end of the H spectrum
    green = 130

    def gen_chunksizes():
        yield from range(1, 100)
        yield from range(100, 1, -1)

    for chunksize in gen_chunksizes():
        hsl_out = hsl.copy()
        hue_out, sat_out, lit_out = (hsl_out[..., i] for i in range(3))
        for low, high in nphusl.chunk(100,
                                      chunksize):  # chunks of the hue range
            select = np.logical_and(lit > low, lit < high)
            is_odd = low % (chunksize * 2)
            color = pink if is_odd else green
            hue_out[select] = color
            select = np.logical_and(lit > (low - 1), lit < low)
            select = np.logical_and(select, lit > 60)
            ave = (low + high) / 2
            select = np.logical_and(lit > (ave - 2), lit < (ave + 2))
            sat_out[select] = 100
        yield nphusl.to_rgb(hsl_out)
Exemplo n.º 3
0
def hue_watermelon(img):
    hsl = nphusl.to_husl(img)
    hue, saturation, lightness = (hsl[..., n] for n in range(3))
    hue_out = hue.copy()
    pink = 360  # very end of the H spectrum
    green = 130
    chunksize = 45
    for low, high in nphusl.chunk(360, chunksize):  # chunks of the hue range
        select = np.logical_and(hue > low, hue < high)
        is_odd = low % (chunksize * 2)
        color = pink if is_odd else green
        hue_out[select] = color
    hue[:] = hue_out
    return nphusl.to_rgb(hsl), "watermelon"
Exemplo n.º 4
0
def hue_watermelon(img):
    hsl = nphusl.to_husl(img)
    hue, saturation, lightness = (hsl[..., n] for n in range(3))
    hue_out = hue.copy()
    pink = 360  # very end of the H spectrum
    green = 130
    chunksize = 45
    for low, high in nphusl.chunk(360, chunksize):  # chunks of the hue range
        select = np.logical_and(hue > low, hue < high)
        is_odd = low % (chunksize * 2)
        color = pink if is_odd else green
        hue_out[select] = color
    hue[:] = hue_out
    return nphusl.to_rgb(hsl), "watermelon"