<div dir="ltr"><div dir="ltr"><div>Thanks for the reply.</div><div><br></div><div>- no , I did not test xs2gif() yet.<br></div><div><br></div><div>I just installed scicv.</div><div><br></div><div>First Off:</div><div>- it does read images (png's) with alpha channel.</div><div><br></div><div>But it seems that it converts it to a 3-channel image:</div><div><br></div><div>Example:</div><div><br></div><div>Beeing RGBA_test.png a 4 channel image</div><div><br></div><div><br></div><div><br></div><div><pre style="font-family:Monospaced;font-style:normal"><span style="color:rgb(0,0,0)">scicv_Init</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>

<span style="color:rgb(0,0,0)">img</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(0,0,0)">imread</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(188,143,143)">RGBA_test.png</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">CV_LOAD_IMAGE_ANYDEPTH</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(0,0,0)">matplot</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">img</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(50,185,185)">disp</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">getImageType</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">img</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span></pre></div><div>// this will translate into a image of type:    CV_8UC1   = 8 bit, 1 channel...hence a grayscale image with 256 pixel values</div><div><br></div><div><br></div><div>//use:</div><div>
<pre style="font-family:Monospaced;font-style:normal"><span style="color:rgb(0,0,0)">img</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(0,0,0)">imread</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(188,143,143)">RGBA_test.png</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">CV_LOAD_IMAGE_COLOR</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span></pre>

</div><div>
// this will translate into a image of type:    CV_8UC3   = 8 bit, 3 channel...hence a color image with 256 pixel values for each channel
</div><div><br></div><div>So I am not sure if imwrite() will use transparency.</div><div>The help is quite short on that.</div><div>It states:</div><div></div><div>
  
    <div class="gmail-refsynopsisdiv">
      <div class="gmail-synopsis">
        <pre><span class="gmail-functionid">imwrite</span><span class="gmail-default">(filename, img[, params])</span></pre>
      </div>
    </div>
    <div class="gmail-refsection">But it does not explain what "params" is.<br></div>
  

</div><div><br></div><div>The openCV help on imwrite however brings hope, since the scicv toolbox is based on openCV:</div><div><br></div><div>...from the openCV help:<br></div><div><br>
</div><div>It is possible to store PNG images with an alpha channel using this 
function.</div><div>To do this, create 8-bit (or 16-bit) 4-channel image BGRA, 
where the alpha channel goes last.</div><div>Fully transparent pixels should have 
alpha set to 0, fully opaque pixels should have alpha set to 255 (65535).<br></div><div><br></div><div>Best regards,</div><div>Philipp<br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Am Mo., 4. März 2019 um 19:05 Uhr schrieb Samuel Gougeon <<a href="mailto:sgougeon@free.fr">sgougeon@free.fr</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello Philipp,<br>
<br>
Le 04/03/2019 à 14:15, P M a écrit :<br>
> Dear all,<br>
><br>
> I build some masks with scilab, that I want to apply later on a set of <br>
> images.<br>
> I can build these masks a batch process, because I have pixel <br>
> coordinates that define the mask coordinates.<br>
> Each mask itself will be an image....<br>
> For now I use xs2svg and/or xs2png<br>
><br>
> Now: Is there a way to export images from scilab applying alpha channel?<br>
><br>
> I ask, because several masks will be layered on top of each <br>
> other...together with a mask that is build manually by a user.<br>
> To get the final result I - for now - have to make each (mask-) image <br>
> a bit transparent, to still see the underlaying image.<br>
> Thus I loose the original color of the mask image.<br>
><br>
> I could probably build an R-G-B-alpha image such as:<br>
><br>
> img = zeros[imgHeight, imgWidht ,4];<br>
><br>
> R = img[ : , : ,1];<br>
> G = img[ : , : ,2];<br>
> B = img[ : , : ,3];<br>
> A = img[ : , : ,4];<br>
><br>
> and than set the right pixel values at the right positions.<br>
><br>
> However: It seems, that it is not possible to add the alpha channel to <br>
> an image when exporting it to a native image file..such as png.<br>
<br>
Interesting piece of information. It would deserve being documented in <br>
the xs*() pages for formats theoretically supporting the transparency.<br>
Have you tried with xs2gif() as well?<br>
<br>
At least, since Scilab 5.5.0, images with an alpha channel can be <br>
handled and display with Matlpot().<br>
<br>
><br>
> imwrite (IPCV-toolbox) seems to support only 8bit (one-channel) or <br>
> 24bit (3-channel) image.<br>
<br>
Have you tried with <a href="https://atoms.scilab.org/toolboxes/scicv" rel="noreferrer" target="_blank">https://atoms.scilab.org/toolboxes/scicv</a> ? It is <br>
likely the most huge external image processing library available for Scilab.<br>
<br>
Regards<br>
Samuel<br>
<br>
_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a><br>
<a href="http://lists.scilab.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a><br>
</blockquote></div>