Python OpenCV 中 ARGB、RGBA 颜色 Space 的区别
Difference between ARGB, RGBA Color Space in Python OpenCV
我有很多关于 RGBA 和 ARGB 颜色模型的问题。
RGBA和ARGB颜色有什么区别space。都是Alpha、红绿蓝通道的排列方式吗?
在我的例子中,我想读取一个带有 jpg 扩展名的图像。我可以从图像中提取 alpha 通道吗?
使用带有 jpg 扩展名的图像。如何将图像转换为 python 中的 RGBA 颜色 space?下面是我的初始代码:
frame = cv2.imread("image.jpg", -1)
print( frame[0,0])
上面的打印语句只显示RGB值。我将如何包含 Alpha 通道?
What is the difference between RGBA and ARGB color space. Is it all about the arrangement of Alpha, Red, Green and Blue Channels?
是的,it's all about the arrangement。
In my case, I want to read an image with jpg extension. Can I extract alpha channel from the image?
没有。 JPG doesn't support transparency。您需要 PNG 等其他格式来存储 alpha 通道。
Using an image with jpg extension. How will I convert the image into RGBA color space in python?
您正在使用 IMREAD_UNCHANGED
(-1
) 加载图像,"If set, return the loaded image as is (with alpha channel, otherwise it gets cropped)."
如果您的图像有 Alpha 通道(例如 PNG),您就完成了。否则,就像您的情况一样,将图像读取为 BGR(默认值,IMREAD_COLOR
),然后转换为 BGRA:
frame = cv2.imread("image.jpg")
bgra = cv.cvtColor(frame, cv.COLOR_BGR2BGRA)
您可以检查 您的图片:
height, width, channels = img.shape
channels
对于 BGRA 必须是 4。
我有很多关于 RGBA 和 ARGB 颜色模型的问题。
RGBA和ARGB颜色有什么区别space。都是Alpha、红绿蓝通道的排列方式吗?
在我的例子中,我想读取一个带有 jpg 扩展名的图像。我可以从图像中提取 alpha 通道吗?
使用带有 jpg 扩展名的图像。如何将图像转换为 python 中的 RGBA 颜色 space?下面是我的初始代码:
frame = cv2.imread("image.jpg", -1) print( frame[0,0])
上面的打印语句只显示RGB值。我将如何包含 Alpha 通道?
What is the difference between RGBA and ARGB color space. Is it all about the arrangement of Alpha, Red, Green and Blue Channels?
是的,it's all about the arrangement。
In my case, I want to read an image with jpg extension. Can I extract alpha channel from the image?
没有。 JPG doesn't support transparency。您需要 PNG 等其他格式来存储 alpha 通道。
Using an image with jpg extension. How will I convert the image into RGBA color space in python?
您正在使用 IMREAD_UNCHANGED
(-1
) 加载图像,"If set, return the loaded image as is (with alpha channel, otherwise it gets cropped)."
如果您的图像有 Alpha 通道(例如 PNG),您就完成了。否则,就像您的情况一样,将图像读取为 BGR(默认值,IMREAD_COLOR
),然后转换为 BGRA:
frame = cv2.imread("image.jpg")
bgra = cv.cvtColor(frame, cv.COLOR_BGR2BGRA)
您可以检查
height, width, channels = img.shape
channels
对于 BGRA 必须是 4。