How to convert a numpy array of RGB values to LAB values with colormath.color_conversions without using loops?

浪尽此生 提交于 2021-02-08 11:23:22

问题


I'm converting RGB triplets to LAB in this way.

from colormath.color_objects import sRGBColor, LabColor
from colormath.color_conversions import convert_color

for p in range(0,h):
    for q in range(0,w):
        rgb_color = sRGBColor(img_arr[p][q][0],img_arr[p][q][1],img_arr[p][q][2])
        lab_color = convert_color(rgb_color, LabColor)

But this method is slow. Is there a way I can convert img_arr from RGB to LAB without loops? I want to use colormath only.

来源:https://stackoverflow.com/questions/37608210/how-to-convert-a-numpy-array-of-rgb-values-to-lab-values-with-colormath-color-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!