Idea: converting GREY images to GREYALPHA images

Hello everyone,
currently I am working with grey-scale images, and I thought it would be a nice idea to have an opportunity to convert Grayscale images into Grayscale+Alpha images.
I had a look here: OpenCV: Color Space Conversions
but I could only find GRAY2RGB , GRAY2BGRA and RGB2RGBA. So I think a conversion GRAY2GRAYA is missing in this place. To show that this is something useful: The png format has support for these Grayscale+Alpha images: PNG Basics (PNG: The Definitive Guide)

And here is an example python script, where reducing these 4 channels to only 2 channels would make a benefit:

from matplotlib import pyplot as plt
import numpy as np

from skimage import data
import cv2

camera =
camera = cv2.cvtColor(camera, cv2.COLOR_RGB2RGBA)
plt.imshow(camera, interpolation='nearest', cmap='gray');
(512, 512)
(512, 512, 4)
pad= np.full((int(camera.shape[0]/4), camera.shape[1]) ,0)
new_pad = cv2.cvtColor(np.uint8(pad), cv2.COLOR_GRAY2BGRA)
new_pad[:,:,3]=0 # setting alpha channle to zero
camera_new=np.concatenate((new_pad, camera ,new_pad) ,axis=0)
plt.imshow(camera_new, interpolation='nearest', cmap='gray');


you’re proposing a GRAYA “type” and conversion codes?

that’s interesting. I think you could implement that for imread/imwrite/imshow. maybe open an issue on github to discuss approaches, or even just to get the idea out there. there are always people looking for “easy” issues to work on. this one seems like a tidy work package with limited theoretical challenges.

by the way: for OpenCV v5 there is talk of giving cv::Mat a colorspace attribute