anchor.diff:  ;; Do some basic processing on the image (adjust colour values)
   (defun write-image (img name)
      (write-png-file name img))
  +
  +(defun 4-neighbors (img i j)
  +  (declare (type fixnum i j))
  +  (with-image-bounds (height width)
  +      img
  +    (values (when (> i 0) (list (1- i) j))             ; top
  +            (when (> j 0) (list i (1- j)))             ; left
  +            (when (< i (1- height)) (list (1+ i) j))   ; bottom
  +            (when (< j (1- width)) (list i (1+ j)))     ; right
  +            )))
  +
  +(defun 8-neighbors (img i j)
  +  (declare (type fixnum i j))
  +  (with-image-bounds (height width)
  +      img
  +    (values (when (and (> i 0) (> j 0)) (list (1- i) (1- j))) ; top-left
  +            (when (> j 0) (list i (1- j)))                    ; left
  +            (when (and (< i (1- height)) (> j 0)) (list (1+ i) (1- j))) ; bottom-left
  +            (when (< i (1- height)) (list (1+ i) j)) ; bottom
  +            (when (and (< i (1- height)) (< j (1- width))) (list (1+ i) (1+ j))) ; bottom-right
  +            (when (< j (1- width)) (list i (1+ j))) ; right
  +            (when (and (> i 0) (< j (1- width))) (list (1- i) (1+ j))) ; top-right
  +            (when (> i 0) (list (1- i) j)) ; top
  +            )))
  +
  +(defmacro multiple-value-list-remove-nulls (values)
  +  `(remove-if #'null (multiple-value-list ,values)))
  +
  +(defun label-components (img &key (neighbor-function #'4-neighbors))
  +  (with-image-bounds (height width)
  +      img
  +    (let ((label-array (make-array (list height width)
  +                                   :element-type 'fixnum
  +                                   :initial-element 0))
  +          (stack)
  +          (label-value 0))
  +      (dotimes (i height)
  +        (dotimes (j width)
  +          (when (= 0 (aref label-array i j))
  +            (let ((current-label-value (multiple-value-list (pixel img i j))))
  +              (incf label-value)
  +              (setf (aref label-array i j) label-value)
  +              (mapcar (lambda (p)
  +                        (destructuring-bind (ni nj) p
  +                          (when (equalp current-label-value
  +                                        (multiple-value-list
  +                                         (pixel img ni nj)))
  +                            (push p stack)
  +                            (setf (aref label-array ni nj) label-value))))
  +                      (multiple-value-list-remove-nulls
  +                       (funcall neighbor-function img i j)))
  +              ;; now we walk through the list....
  +              (do ((k (pop stack) (pop stack)))
  +                  ((null k))
  +                (mapcar (lambda (p)
  +                          (destructuring-bind (ni nj) p
  +                            (when (and (equalp current-label-value
  +                                               (multiple-value-list
  +                                                (pixel img ni nj)))
  +                                       (= 0 (aref label-array ni nj)))
  +                              (push p stack)
  +                              (setf (aref label-array ni nj) label-value))))
  +                        (multiple-value-list-remove-nulls
  +                         (funcall neighbor-function img (car k) (cadr k)))))))))
  +      (map-array #'1- label-array))))
   
   ;; Perform a very simple modification to the pixels in an image to greyscale it
   (defun greyscale-image (img)
  
positive.code: ;; Define packages to use
  (use-package 'opticl)
  
  ;; Convert an image into RGB pixels
  (defun load-painting (name)
     (let ((img (read-png-file name))) img))
  
negative.code:                         (setf (pixel img i j)
                             (values grey grey grey))))))))))
  
  ;; Perform an edge thinning algorithm
  (defun edge-thin (img)
     (typecase img
        (8-bit-rgb-image
           (locally (declare (type 8-bit-rgb-image img))
              (with-image-bounds (height width) img
                 (loop for i below height do
                    (loop for j below width do
                       (setf empty nil)
                       (setf c 0)
                       (dolist (f (multiple-value-list-remove-nulls (8-neighbors img i j)))
                          (if (not (null f))
                             (multiple-value-bind (_r _g _b)
                                (pixel img i j)
                                (declare (type (unsigned-byte 8) _r _g _b)))
                             (multiple-value-bind (r1 g1 b1)
                                (pixel img (first f) (second f))
                                (declare (type (unsigned-byte 8) r1 g1 b1))
                                   ;((and (eq _r 0) (eq r1 255)) (setf empty nil))
                                   ;((and (eq _r 255) (eq r1 255)) (setf empty nil))
                                   (setf c 6)
                                   (if (and (eq _r 255) (eq r1 0)) (setf c (+ c 1))))))
                       (multiple-value-bind (r g b)
                          (pixel img i j)
                          (declare (type (unsigned-byte 8) r g b))
                             (setf v r)
                             (format t "~S~%" c)
                             (if (eq c 8) (setf v 0))
                             (setf (pixel img i j)
                             (values v v v))))))))))
  
  
  (defun threashold-image (img amount)
     (typecase img
        (8-bit-rgb-image
           (locally (declare (type 8-bit-rgb-image img))
              (with-image-bounds (height width) img
                 (loop for i below height do
                    (loop for j below width do
                       (multiple-value-bind (r g b)
                          (pixel img i j)
                          (declare (type (unsigned-byte 8) r g b))
                          (if (> r amount) (setf v 255) (setf v 0))
                          (setf (pixel img i j)
                             (values v v v))))))))))
  ;; Sums an array
  ; https://faculty.washington.edu/ikalet/courses/lisp/code/arrays.cl
  (defun add-all-elements (arr)
  