# Image transparency is possible in Scilab

**URL:** <https://scilab.discourse.group/t/image-transparency-is-possible-in-scilab/829>\
**Category:** Signal and image processing\
**Created:** [February 20, 2025, 3:44pm UTC](https://scilab.discourse.group/t/image-transparency-is-possible-in-scilab/829 "2025-02-20T15:44:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![philipp](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/philipp/32/53_2.png) [@philipp](https://scilab.discourse.group/u/philipp)\
**Post date:** [February 20, 2025, 3:44pm UTC](https://scilab.discourse.group/t/image-transparency-is-possible-in-scilab/829/1 "2025-02-20T15:44:22Z")

</div>

Dear,

image transparency and Scilab seem to popup as a topic once in a while.

Transparency is said to not be supported in Scilab, e.g.: see

> [@Transparent SciLab graph](https://scilab.discourse.group/t/transparent-scilab-graph/822):
>
> How can I generate a transparent SciLab graph that I can superimpose over another image?

However `Matplot()` (native Scilab) and `matplot()` (scicv) do support RGBA images.

The point is, that `imread()` from the various image processing toolboxes clip the alpha channel from the input image.

E.g.:

A 100x100x4 RGBA image (PNG) will be loaded as 100x100x3 data structure by `imread()` of IPCV.

However, there is a workaround:

You can extract the alpha channel of the input image and save it as a separate image. This can be done rather easy with e.g.: IrfanView by displaying just the alpha channel and saving this as a new file.

Once there is a separate alpha-channel image, one can load both images (orig as RGB & alpha) into Scilab.

The alpha-channel will be saved as an gray scale image.

Done this, one can reunite both parts (RGB + ALPHA) by loading the separatly with `imread()`.

`img_RGB = imread(PATH_TO_IMAGE);`  
`img_ALPHA = imread(PATH_TO_ALPHA_CHANNEL_IMAGE); `

In Scilab one can than build a structure that holds 4 channels, e.g.:

`img = uint8(zeros(imgHeight, imgWidth, 4));`

Next, one can reunite the separate images together into one.

`img(:,:,1:3) = uint8(img_RGB);`  
`img(:,:,4) = uint8(img_ALPHA);`

If we also load a background image:

`img_background = imread(PATH_IMG_BACK);`

we can display the result

`subplot(1,3,1);`  
`Matplot(img_background);`

`subplot(1,3,2);`  
`Matplot(img_RGB);`

`subplot(1,3,3);`  
`Matplot(img_background);`  
`Matplot(img); `

 ![testOutput](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/2af2b60755eec8f28b1a467e18ac90518de3d2b6.png)

Note:  
The ALPHA channel in this example contained only 0 and 255 as values.  
You may use values in the range [0 255] to get other transparency effects.

In the hope, that this will help here and there…

Best Regards,  
Philipp
