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

[FEATURE]: Adaptive samples count #65

Open roshameow opened 2 years ago

roshameow commented 2 years ago

Description

I noticed that in segmentation.py/detect_colour_checkers_segmentation the samples is a passed in parameter. Would it be more natural if we instead pass in the ratio of samples/colorchecker to adapt different checkerboard size?

This line can be modified as following: https://github.com/colour-science/colour-checker-detection/blob/develop/colour_checker_detection/detection/segmentation.py#L1097

samples_ratio=4
samples = int(np.sqrt(height*width/(swatches_h*swatches_v))/samples_ratio)
masks = swatch_masks(width, height, swatches_h, swatches_v, samples)
KelSolaar commented 2 years ago

Hi @roshameow,

Sorry for the late reply, this slipped through the many cracks!

We tend to like knowing how much samples are being processed in my field, that said we could have a utility function to compute them so that they could be passed a bit more easily this way.

Cheers,

Thomas

roshameow commented 2 years ago

Hi Thomas,

I see your concern here. Are you talking about a utility function like

def get_sample_by_ratio(height, width, swatches_h, swatches_v, samples_ratio=0.25):
    return int(np.sqrt(height*width/(swatches_h*swatches_v))*samples_ratio)

and add flag like "use_sample_ratio" in the parameter dict? I totally agree.

Also much thanks for your work. It did speed up a lot when I was doing a color correction process.