Swap Channels
Swap color channels
Process different color channels.
Swap RGB channels
(ns lv.demo)
(use 'lv.core)
(layout "grid" [img0 img1]
[img2 ras3])
; assume there are 4 PNG images in the media folder.
(image "flower-sampler/*.png")
(render)
; Do not modify the image.
; Copies red green and blue without modification from image c0.
(rgb :img0 [c0 c1 c2 c3]
(rgb c0.rgb)
)
; Invert the blue channel.
(rgb :img1 [c0 c1 c2 c3]
(r c0.r)
(g c0.g)
(b (- 1 c0.b))
)
; Mix two images,
; but use different blending calculations for each channel.
(rgb :img2 [c0 c1 c2 c3]
(r (+ c2.r c0.r))
(g (* c2.g c0.g))
(b (- c2.b c0.b))
)
; Mix the output of node img0 and img1.
; Blending is controlled by the green channel of img0
; (img0 = the original unmodified image).
(rgb :ras3 [img0 img1]
(rgb (mix img0.rgb
img1.rgb
img0.g))
)
Swap HSV channels
(ns lv.demo)
(use 'lv.core)
(layout "grid" [img0 img1]
[img2 ras3])
; assume there are 4 PNG images in the media folder.
(image "flower-sampler/*.png")
(render)
; Do not modify the image.
; Copies hue, saturation and brightness
; without modification from image c0.
(hsv :img0 [c0 c1 c2 c3]
(hsv c0.hsv)
)
; Invert the hue channel.
(hsv :img1 [c0 c1 c2 c3]
(h (+ 0.5 c0.h))
(s c0.s)
(v c0.v)
)
; Exchange brightness and saturation channel.
(hsv :img2 [c0 c1 c2 c3]
(h c2.h)
(s c2.v)
(v c2.s)
)
; Mix the output of node img0, img1 and img2.
; Playing with the equations.
(hsv :ras3 [img0 img1 img2]
(h (* img0.h img1.h img2.h))
(s (- 1 img1.s))
(v img1.v)
)
Assign RGB channels to HSV channels
(ns lv.demo)
(use 'lv.core)
(layout "grid" [img0 img1]
[img2 ras3])
; assume there are 4 PNG images in the media folder.
(image "flower-sampler/*.png")
(render)
; Red, green and blue channels are assigned to hue, saturation and value.
(hsv :img0 [c0 c1 c2 c3]
(hsv c0.rgb)
)
; Playing with the equations for HSV output.
; Inputs from two different images and different color models.
(hsv :img1 [c0 c1 c2 c3]
(h (+ 0.13 c1.r c1.b))
(s (* 0.64 c1.s))
(v c1.g)
)
; Keep the hue channel.
; But patch saturation and value.
(hsv :img2 [c0 c1 c2 c3]
(h c2.h)
(s c2.b)
(v c2.r)
)
; Mix the output of node img2 with itself.
; But use different color models.
(hsv :ras3 [img2]
(hsv (mix img2.hsv img2.rgb 0.78))
)