slyrus / opticl

An image processing library for Common Lisp
Other
182 stars 35 forks source link

JPEG reading has a bug #44

Open stewart123579 opened 2 years ago

stewart123579 commented 2 years ago

Quicklisp: opticl-20211230-git

(Thanks to #14 for the hint of what I'm seeing)

There appears to be a bug in the read-jpeg code

(opticl:write-jpeg-file "/tmp/cat2.jpg" (opticl:read-jpeg-file "/tmp/cat.jpg"))

produces an output image which is different from the input image.


Looking at the RBG values in lisp (SBCL) and python I get different values.

(let ((img (read-jpeg-file "/tmp/cat.jpg")))
    (loop for x below (array-dimension img 1)
        minimize (aref img 100 x 1) into low
        maximize (aref img 100 x 1) into high
        finally (return (list low high))))

gives (132 255)

import numpy as np
from PIL import Image
image = np.array(Image.open("/tmp/cat.jpg"))
arr = image[100,:,1]
print(np.min(arr), np.max(arr))

gives (133 255)

i.e. minimum value is 132 or 133.


An example JPEG: Obligatory cat image