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: ;; Edge detect
  ; http://academypublisher.com/ijrte/vol01/no02/ijrte0102250254.pdf
  (defun edge-detect (img output)
     (greyscale-image img)
     (setf m (make-array '(3 3)
        :initial-contents
           '(( 1  0  0)
             ( 0  0  0)
             ( 0  0 -1))))
     (setf img (discrete-convolve img m))
     (write-image img output)) ; output the image for now
  
  ;; Shorthand function to run the noise estimation
  (defun noise (input output)
     (estimate-noise (load-painting input) output))
  
  ;; Shorthand function to run the noise estimation
  (defun edge (input output)
     (edge-detect (load-painting input) output))
  
negative.code: ;; Define packages to use
  (use-package 'opticl)
  
  (defparameter *edge-kernel* #2A((0 1 0) (1 -4 1) (0 1 0)))
  ;; Convert an image into RGB pixels
  (defun load-painting (name)
     (let ((img (read-png-file name))) img))
  