# Idea: converting GREY images to GREYALPHA images

**URL:** <https://forum.opencv.org/t/idea-converting-grey-images-to-greyalpha-images/444>\
**Category:** Python\
**Created:** [December 21, 2020, 2:23pm UTC](https://forum.opencv.org/t/idea-converting-grey-images-to-greyalpha-images/444 "2020-12-21T14:23:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kolibril13](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@kolibril13](https://forum.opencv.org/u/kolibril13)\
**Post date:** [December 21, 2020, 2:23pm UTC](https://forum.opencv.org/t/idea-converting-grey-images-to-greyalpha-images/444/1 "2020-12-21T14:23:18Z")

</div>

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](https://docs.opencv.org/3.4/d8/d01/group __imgproc__ color__conversions.html)  
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)](http://www.libpng.org/pub/png/book/chapter08.html#png.ch08.div.5.5)

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

```python
from matplotlib import pyplot as plt
import numpy as np

from skimage import data
import cv2

camera = data.camera()
print(camera.shape)
camera = cv2.cvtColor(camera, cv2.COLOR_RGB2RGBA)
plt.imshow(camera, interpolation='nearest', cmap='gray');

```

```
(512, 512)

```

```python
camera.shape

```

```
(512, 512, 4)

```

```python
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');

```

![output_2_0](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/1X/b9ce455cf8996384d9c09105114958a94a3f1819.png)

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [December 21, 2020, 8:12pm UTC](https://forum.opencv.org/t/idea-converting-grey-images-to-greyalpha-images/444/2 "2020-12-21T20:12:29Z")

</div>

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](https://github.com/opencv/opencv/wiki/OE-5.-OpenCV-5)
