Closed statcom closed 3 years ago
Hi @statcom,
The code is not really implemented to detect other checkers than the X-Rite ColorChecker Classic and Passport, however, it is parameterizable and could be generalised, e.g. https://github.com/colour-science/colour-checker-detection/blob/develop/colour_checker_detection/detection/segmentation.py#L60.
Upon having the swatches sampled, and assuming you have reference values, you can then compute the fitting matrix. There is a full example here: https://nbviewer.jupyter.org/github/colour-science/colour-checker-detection/blob/master/colour_checker_detection/examples/examples_detection.ipynb
Thanks for your prompt reply!
That code is exactly what I need. I will look into it. In my experience with Matlab, the generalization/parameterization was not too difficult. The color targets are rectangular grids with different number of swatches where some cells are missing (not applicable).
BTW, great project and thanks for sharing!
You are welcome! If you have something nice that you want to be integrated into the project, feel free to open a PR! I think the builds are breaking currently though, haven't had time to check now.
Considering Datacolor's SpyderCheckr24 has the same layout and reference values are available on their website, would it be sufficient to leave segmentation.py as it is and only update chromaticity_coordinates.py with the values? Like this? Although I'm not sure about the illuminant, it is not mentioned in the Datacolor's document. There are also values available at Chromaxion, but those are from one sample only.
Hi @kvok,
You would indeed not need to change colour-checker-detection
code here I think. Given how similar the charts are you could simply get the values from the segmentation and colour correct against the SpyderCheckr24
data.
I want to apply the example of colour checker detection for one image so how I can convert this code for one image for swatches, colour_checker, masks in detect_colour_checkers_segmentation( image, additional_data=True):
Hello @farhanalfin,
Sorry, I'm not quite sure to understand, the colour_checker_detaction.detect_colour_checkers_segmentation
definition works with a single image as input. Would you mind clarifying what you are trying to achieve please.
Cheers,
Thomas
Hello Thomas in the colour checker example
for swatches, colour_checker, masks in detect_colour_checkers_segmentation( image, additional_data=True):
is this code for one image which have one colour checker in it.
Correct!
When I tried to use a color detection library of color project for an image opened by OpenCV, I thought I would have to convert it to RGB. But when I did that, I received an incorrect result of color checker segmentation. In the original example of color checker segmentation example, the image opened using: COLOUR_CHECKER_IMAGES = [ colour.cctf_decoding(colour.io.read_image("IMG_1967.png")) ] for image in COLOUR_CHECKER_IMAGES: plot_image(colour.cctf_encoding(image))
SWATCHES = []
for image in COLOUR_CHECKER_IMAGES:
for swatches, colour_checker, masks in detect_colour_checkers_segmentation(
image, additional_data=True):
SWATCHES.append(swatches)
# Using the additional data to plot the colour checker and masks.
masks_i = np.zeros(colour_checker.shape)
for i, mask in enumerate(masks):
masks_i[mask[0]:mask[1], mask[2]:mask[3], ...] = 1
plot_image(
colour.cctf_encoding(
np.clip(colour_checker + masks_i * 0.25, 0, 1)))
The images decoded during opening and then encoded to use it for detect_colour_checkers_segmentation and to display the result had to encoding the resulted image. These were taking a long time and the calculating results make the result not accurate.
I found that it is better to open image by OpenCV as BGR and use it in detect_colour_checkers_segmentation and encoding the resulted image. this take less time what do say about this
Hi,
Would you have an image to share? It is really hard ATM to understand the issue you are having.
Cheers,
Thomas
In more simple words, can I use image by OpenCv (BGR uint8) in colorchecker detection functions
for swatches, colour_checker, masks in detect_colour_checkers_segmentation(
image, additional_data=True):
if not how ı can convert the image to be suitable
Sorry, I'm on a trip with a limited internet connection. The expectation is for the image to be linear floating-point RGB. If you were to use .png files, for example, you might decode them as follows:
colour.cctf_decoding(colour.io.read_image(path))
This is a question than an issue.
I am designing software with GUI allowing users to extract color values of patches in different color targets (e.g., X-rite color checker SG, IT8.7/2, and HCT). I think that color target detection in the software does not have to be automatic as it can ask users to select 4 corner points. I wonder how your code can be extended for the other color targets. Thanks.