colour-science / colour-checker-detection

Colour checker detection with Python
https://www.colour-science.org/
BSD 3-Clause "New" or "Revised" License
221 stars 31 forks source link

On colour checker detection robustness? #23

Closed ddonohoe closed 3 years ago

ddonohoe commented 3 years ago

Colour checker detection fails with the following image:

colourchecker.bmp.gz

The following is my minimal test case:

import colour
from colour_checker_detection import detect_colour_checkers_segmentation

image = colour.cctf_decoding(colour.io.read_image('colourchecker_crop.bmp'))

swatches = detect_colour_checkers_segmentation(image)

if len(swatches) == 0:
    print("Detection failed")

I found that I can make the detection work if I replace INTER_CUBIC with INTER_LINEAR in adjust_image(). With Cubic interpolation, only 15 swatches are detected ("counts" in colour_checkers_coordinates_segmentation()), whereas with Linear interpolation, 19 swatches are detected.

A strange thing I observed is that if I convert the image to .png first, everything changes, even though the images should be identical. In this case Linear interpolation detects 18 swatches, whereas Cubic interpolation detects 19.

KelSolaar commented 3 years ago

HI @ddonohoe,

Sorry for the late reply, it seems like we could expose a few more arguments to control the behaviour.

That being said, looking at your image, the colour checker is really highly distorted and noisy, I'm actually surprised it works at all! It might be a good idea to undistort the image before.

image

Cheers,

Thomas

ddonohoe commented 3 years ago

Hi Thomas,

Thank you very much for the suggestions, this is really helpful! I can certainly undistort the image and reduce the noise.

Best Regards, Dave