25 lines
935 B
Common Lisp
25 lines
935 B
Common Lisp
;; Outline effect - shows only edges
|
|
(require-primitives "image")
|
|
|
|
(define-effect outline
|
|
:params (
|
|
(thickness :type int :default 2 :range [1 10])
|
|
(threshold :type int :default 100 :range [20 300])
|
|
(color :type list :default (list 0 0 0)
|
|
)
|
|
(fill_mode "original"))
|
|
(let* ((edge-img (image:edge-detect frame (/ threshold 2) threshold))
|
|
(dilated (if (> thickness 1)
|
|
(dilate edge-img thickness)
|
|
edge-img))
|
|
(base (cond
|
|
((= fill_mode "original") (copy frame))
|
|
((= fill_mode "white") (make-image (image:width frame) (image:height frame) (list 255 255 255)))
|
|
(else (make-image (image:width frame) (image:height frame) (list 0 0 0))))))
|
|
(map-pixels base
|
|
(lambda (x y c)
|
|
(let ((edge-val (luminance (pixel dilated x y))))
|
|
(if (> edge-val 128)
|
|
color
|
|
c))))))
|