Reputation: 94
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))
# Detection
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.
Can someone explain to me why this is?
Upvotes: 0
Views: 355
Reputation: 4090
The expectation for the colour_checker_detection. detect_colour_checkers_segmentation
definition is for the image data to be linear floating-point RGB in range [0, 1].
Upvotes: 1