<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;"><div>Hi Mat, <br></div><div><br></div><div>First of all, thanks Philipp for the example. <br></div><div><br></div><div>Infact you might be able to get the similar result with Image Arithmetic function - imadd, which will perform the proper int clipping. I attached the file with added lines to compare the results which should be identical.<br></div><div><br></div><div>On the other hand, to adjust the color level or RGB image, you could use "imadjust". <br></div><div><br></div><div>S2 = imadjust(S) will adjust the image automatically, or define your own source and destination histogram range. <br></div><div><br></div><div>you could also explore imhistequal for histogram equalisation, however, bear in mind applying these in RGB will caused color distortion. <br></div><div><br></div><div>On of the way in Color Image processing if you were to adjust to RGB image intensity w/o affecting the color proportion for viewing effect :<br></div><div><br></div><div>1. convert RGB to LAB (rgb2hsv)<br></div><div>2. perform adjustment on the first layer (correspond to "v", in transformed image, the hsv layers are arrange in "v", "s","h")<br></div><div>3. fuse the layers 2 and 3 to the adjusted layer 1<br></div><div>4. convert LAB to RGB<br></div><div><br></div><div>you should get a nicely adjusted color image.<br></div><div><br></div><div>/// sample<br></div><div>S = imread('darkroom.jpg'); <br></div><div><br></div><div>S2 = rgb2hsv(S);<br></div><div><br></div><div>S3 = imhistequal(S2(:,:,1));<br></div><div><br></div><div>S3(:,:,2:3) = S2(:,:,2:3)<br></div><div><br></div><div>S4=hsv2rgb2(S3); //hsv2rgb name has been taken by Scilab, so IPCV use hsv2rgb2<br></div><div><br></div><div>imshow(S4);<br></div><div>//</div><div><br></div><div><br></div><div>hope this helps.<br></div><div><br></div><div>rgds,<br></div><div>Chin Luh</div><div><br></div><div><br></div><div data-zbluepencil-ignore="true" style="" class="zmail_extra"><div><br></div><div id="Zm-_Id_-Sgn1">---- On Wed, 10 Jun 2020 15:40:20 +0800 <b>P M <p.muehlmann@gmail.com></b> wrote ----<br></div><div><br></div><blockquote style="border-left: 1px solid rgb(204, 204, 204); padding-left: 6px; margin: 0px 0px 0px 5px;"><div><div dir="ltr"><div>Dear Mat,<br></div><div><br></div><div>not sure if this helps,<br></div><div>but here is a way, how to set brightness using a constant value.<br></div><div><br></div><div>I guess for automatization one can figure out a way using mean pixel value.<br></div><div><br></div><div>Best Regards,<br></div><div>Philipp<br></div><div><br></div><div><pre style="font-family: Monospaced;font-style: normal;"><span class="colour" style="color:rgb(0, 0, 0)">img</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(174, 92, 176)"><u>imread</u></span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(50, 185, 185)">fullpath</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(174, 92, 176)"><u>getIPCVpath</u></span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(74, 85, 219)">)</span> <span class="colour" style="color:rgb(92, 92, 92)">+</span> <span class="colour" style="color:rgb(188, 143, 143)">"</span><span class="colour" style="color:rgb(188, 143, 143)">/images/</span><span class="colour" style="color:rgb(188, 143, 143)">"</span> <span class="colour" style="color:rgb(92, 92, 92)">+</span> <span class="colour" style="color:rgb(188, 143, 143)">'</span><span class="colour" style="color:rgb(188, 143, 143)">baboon.png</span><span class="colour" style="color:rgb(188, 143, 143)">'</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(100, 174, 100)"><i>// image size = 512 x 512</i></span>
<span class="colour" style="color:rgb(100, 174, 100)"><i>// result of </i></span><span class="colour" style="color:rgb(100, 174, 100)"><i>"</i></span><span class="colour" style="color:rgb(100, 174, 100)"><i>imread</i></span><span class="colour" style="color:rgb(100, 174, 100)"><i>"</i></span><span class="colour" style="color:rgb(100, 174, 100)"><i> is of type 10 --</i></span><span class="colour" style="color:rgb(100, 174, 100)"><i>></i></span><span class="colour" style="color:rgb(100, 174, 100)"><i> text object</i></span>
<span class="colour" style="color:rgb(100, 174, 100)"><i>// (???)..guess: type = unsigned char, which is 8 bit</i></span>
<span class="colour" style="color:rgb(100, 174, 100)"><i>//</i></span>
<span class="colour" style="color:rgb(100, 174, 100)"><i>// However this limits the pixel values between 0 and 255</i></span>
<span class="colour" style="color:rgb(100, 174, 100)"><i>// e.g.: 255 + 1 will be set to </i></span><span class="colour" style="color:rgb(100, 174, 100)"><i>"</i></span><span class="colour" style="color:rgb(100, 174, 100)"><i>0</i></span><span class="colour" style="color:rgb(100, 174, 100)"><i>"</i></span>
<span class="colour" style="color:rgb(100, 174, 100)"><i>//</i></span>
<span class="colour" style="color:rgb(100, 174, 100)"><i>// for brightness control we must be able to exceed 255.</i></span>
<span class="colour" style="color:rgb(100, 174, 100)"><i>// ..we also want to go into negative pixel values</i></span>
<span class="colour" style="color:rgb(100, 174, 100)"><i>// so we need to change integer type...use int16</i></span>
<span class="colour" style="color:rgb(100, 174, 100)"><i>// positive pixel values above 255 will be set to 255 afterwards</i></span>
<span class="colour" style="color:rgb(100, 174, 100)"><i>// negative pixel values will be set to 0 afterwards</i></span>
<span class="colour" style="color:rgb(0, 0, 0)">nPx</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(188, 143, 143)">512</span><span class="colour" style="color:rgb(92, 92, 92)">*</span><span class="colour" style="color:rgb(188, 143, 143)">512</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">brighnessLv_1</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(188, 143, 143)">128</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">brighnessLv_2</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(92, 92, 92)">-</span><span class="colour" style="color:rgb(188, 143, 143)">128</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">img_1</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(50, 185, 185)">int16</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">img</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">img_1</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(0, 0, 0)">img_1</span> <span class="colour" style="color:rgb(92, 92, 92)">+</span> <span class="colour" style="color:rgb(0, 0, 0)">brighnessLv_1</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">img_2</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(50, 185, 185)">int16</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">img</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">img_2</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(0, 0, 0)">img_2</span> <span class="colour" style="color:rgb(92, 92, 92)">+</span> <span class="colour" style="color:rgb(0, 0, 0)">brighnessLv_2</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">pos</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(50, 185, 185)">find</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">img_1</span> <span class="colour" style="color:rgb(92, 92, 92)">></span> <span class="colour" style="color:rgb(188, 143, 143)">255</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">img_1</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">pos</span><span class="colour" style="color:rgb(74, 85, 219)">)</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(188, 143, 143)">255</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">pos</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(50, 185, 185)">find</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">img_1</span> <span class="colour" style="color:rgb(92, 92, 92)"><</span> <span class="colour" style="color:rgb(188, 143, 143)">0</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">img_1</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">pos</span><span class="colour" style="color:rgb(74, 85, 219)">)</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(188, 143, 143)">0</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">pos</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(50, 185, 185)">find</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">img_2</span> <span class="colour" style="color:rgb(92, 92, 92)">></span> <span class="colour" style="color:rgb(188, 143, 143)">255</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">img_2</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">pos</span><span class="colour" style="color:rgb(74, 85, 219)">)</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(188, 143, 143)">255</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">pos</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(50, 185, 185)">find</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">img_2</span> <span class="colour" style="color:rgb(92, 92, 92)"><</span> <span class="colour" style="color:rgb(188, 143, 143)">0</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">img_2</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">pos</span><span class="colour" style="color:rgb(74, 85, 219)">)</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(188, 143, 143)">0</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">img_1</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(50, 185, 185)">uint8</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">img_1</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">img_2</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(50, 185, 185)">uint8</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">img_2</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">f</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(50, 185, 185)">figure</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">f</span><span class="colour" style="color:rgb(92, 92, 92)">.</span><span class="colour" style="color:rgb(170, 170, 170)">figure_size</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(74, 85, 219)">[</span><span class="colour" style="color:rgb(188, 143, 143)">1591</span><span class="colour" style="color:rgb(0, 0, 0)">,</span><span class="colour" style="color:rgb(188, 143, 143)">610</span><span class="colour" style="color:rgb(74, 85, 219)">]</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(0, 0, 0)">f</span><span class="colour" style="color:rgb(92, 92, 92)">.</span><span class="colour" style="color:rgb(170, 170, 170)">background</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(188, 143, 143)">8</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(174, 92, 176)"><u>subplot</u></span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(188, 143, 143)">1</span><span class="colour" style="color:rgb(0, 0, 0)">,</span><span class="colour" style="color:rgb(188, 143, 143)">3</span><span class="colour" style="color:rgb(0, 0, 0)">,</span><span class="colour" style="color:rgb(188, 143, 143)">1</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(174, 92, 176)"><u>imshow</u></span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">img</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(174, 92, 176)"><u>subplot</u></span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(188, 143, 143)">1</span><span class="colour" style="color:rgb(0, 0, 0)">,</span><span class="colour" style="color:rgb(188, 143, 143)">3</span><span class="colour" style="color:rgb(0, 0, 0)">,</span><span class="colour" style="color:rgb(188, 143, 143)">2</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(174, 92, 176)"><u>imshow</u></span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">img_1</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(174, 92, 176)"><u>subplot</u></span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(188, 143, 143)">1</span><span class="colour" style="color:rgb(0, 0, 0)">,</span><span class="colour" style="color:rgb(188, 143, 143)">3</span><span class="colour" style="color:rgb(0, 0, 0)">,</span><span class="colour" style="color:rgb(188, 143, 143)">3</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span>
<span class="colour" style="color:rgb(174, 92, 176)"><u>imshow</u></span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">img_2</span><span class="colour" style="color:rgb(74, 85, 219)">)</span><span class="colour" style="color:rgb(0, 0, 0)">;</span><br></pre></div><div><br></div><div><br></div></div><div><br></div><div class="x_719436699gmail_quote"><div class="x_719436699gmail_attr" dir="ltr">Am Di., 9. Juni 2020 um 22:05 Uhr schrieb mat368 <<a target="_blank" href="mailto:matthieu.gazon@orange.fr">matthieu.gazon@orange.fr</a>>:<br></div><div><br></div></div><div>_______________________________________________<br></div><div>users mailing list <br></div><div><a target="_blank" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a> <br></div><div><a target="_blank" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a> <br></div></div><blockquote style="margin: 0.0px 0.0px 0.0px 0.8ex;border-left: 1.0px solid rgb(204,204,204);padding-left: 1.0ex;" class="x_719436699gmail_quote">Hello<br> I am looking for a function or a code to auto adjust level of color image ?<br> I dont see that in thé ipcv package.<br> <br> Thanks for tour trop.<br> Mat<br> <br> <br> <br> --<br> Sent from: <a target="_blank" href="http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html">http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html</a><br> _______________________________________________<br> users mailing list<br> <a target="_blank" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a><br> <a target="_blank" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a><br></blockquote></blockquote></div><div><br></div></div><br></body></html>