[Scilab-users] adjust image
Dear all, please have a look at following code. The aim is to adjust the intensitivity levels of an image to new values...something like imadjust in Matlab. I did not find something like this in IPD or in SIVP, therefore the try. For my purposes it's enough, though not all image types are maybe supported... But the code did work with a bmp and jpg-file. function out=AdjustImage(img, In_low, In_high, Out_low, Out_high) //make sure we work with doubles img = double(img); select ndims(img) case 2 // 2D array (GrayScaleImage) //normalize image MIN = min(img); MAX = max(img); img = (img-MIN)./ (MAX-MIN); //make sure img is in the range [In_low;In_high] img = max(In_low, min(In_high,img)); out = ( (img - In_low) ./ (In_high - In_low) ) ; out = out .* (Out_high - Out_low) + Out_low; case 3 // hypermat (ColorImage) for i = 1:3 //normalize image MIN = min(img(:,:,i)); MAX = max(img(:,:,i)); img(:,:,i) = (img(:,:,i)-MIN)./ (MAX-MIN); //make sure img is in the range [In_low;In_high] img(:,:,i) = max(In_low, min(In_high,img(:,:,i))); out(:,:,i) = ((img(:,:,i) - In_low) ./ (In_high - In_low)) ; out(:,:,i) = out(:,:,i) .* (Out_high - Out_low) + Out_low; end endendfunction; //test case 2D img = rand(240,320); adj_im = AdjustImage(img,0.2,0.8,0,1); //test case hypermat img(:,:,1) = rand(240,320); img(:,:,2) = rand(240,320); img(:,:,3) = rand(240,320); adj_im = AdjustImage(img,0.2,0.8,0,1); For those who have IPD installed, you can use ShowImage() or ShowColorImage() to see the results. For those who don't at least the 2D case should be possible to visualize with Matplot()...the hypermat case...don't know. f = figure(); f.color_map = graycolormap(255); Matplot(img); BR, Philipp -- There we have the salad. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] Plotting as stem function
Thanks, the two answers were usefull for me... -- View this message in context: http://mailinglists.scilab.org/Plotting-as-stem-function-tp4033516p4033542.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
[Scilab-users] usage of libsvm
Dear Scilab Users I would like to lean how to use libsvm Toolbox - (1.4.5). I would like to do multi variable regression by using this tool box. If you have any tutrial material for beginner of this tool box, could you please please send it to me. Thank you for your help. Y. Noguchi ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
[Scilab-users] usage of libsvm Toolbox
Dear Scilab Users I would like to lean how to use libsvm Toolbox - (1.4.5). I would like to do multi variable regression by using this tool box. If you have any tutrial material with sample data for beginner of this tool box, could you please please send it to me. Especially, I would like to know that how I can know the regression equation and their parameters so that I can implement it in the computer to calculate the predicted value on-line. Thank you for your help. Y. Noguchi -- View this message in context: http://mailinglists.scilab.org/usage-of-libsvm-Toolbox-tp4033540.html Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com. ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] new option "@" <= uman : help in the console, with language switch, automatic redirections, related online pages.
Le 22/02/2016 13:13, Samuel Gougeon a écrit : .../... uman denizet>SEP|graphics! @ // Subject with ("SEP" OR "graphics") FROM Denizet uman SEP"Couvert") . OK, i already know that, if any, selection of authors will be kept only as leading field: uman steer|couvert>SEP! @ // Subject with "SEP" FROM ("Steer" OR "Couvert") in order to use the trailing "<###" to specify the number of most recent days within which messages were posted. It will be added to the forthcoming release. SG ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] new option "@" <= uman : help in the console, with language switch, automatic redirections, related online pages.
Hello Rafael, Le 22/11/2015 22:47, Rafael Guerra a écrit : Hello Samuel, Thanks for sharing *uman* and congratulations for the amazing work done. This is a very useful tool to increase Scilab users productivity. The quick access to the appropriate bug webpages is awesome. May we also use uman to query the relevant threads in Scilab users webpages? . Thanks for using and supporting *uman*. The present release for Scilab 6 is out of work due to Scilab 6 running changes, but the next uman's release will come very soon, for both Scilab 5 and Scilab 6. It will propose the new option "*@*" (and other new features) to do what you wish. Here is how "@" is presently implemented (examples from the help page, all already working): // Mailing lists: Search Scilab online archives: The "@" option // // To search only in Subject of messages, end the pattern with "!" // Operators grouping (), | (or), & (and), ~ (not/without) can be used. // If it has spaces or a leading ( , put the pattern between quotes "..." // Author(s) may be also be selected with "author>..." or ".." etc. // uman aliasing @// Search "aliasing" in any part of messages uman aliasing! @ // Search "aliasing" only in Subjects uman grand&setting @ // Messages with "grand" AND "setting" in any part uman grand&~setting @ // Messages with "grand" AND WITHOUT "setting" in any part uman "grand & ~setting" @ // idem. Use quotes when there are blanks. uman cell|struct! @// Subject with "cell" OR "struct" uman "(cell|struct)&~matrix!" @ // Subject with "cell" OR "struct", AND NOT matrix // Quotes are mandatory to protect the leading ( uman struct&~(array|scilab)! @ // Subject with "struct" AND NOT ("array" OR "scilab") uman "(cell|struct)&~(function|array)!" @ // Subject with "cell" OR "struct", // AND NOT "function" OR "array" uman denizet>SEP|graphics! @ // Subject with ("SEP" OR "graphics") FROM Denizet uman SEP"Couvert") I hope this will fulfill your wishes. With it, i already watch at the online archives much more frequently than formerly ;) Best regards Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] ?==?utf-8?q? ?==?utf-8?q? ?= How to replicate what "load" does (aka creating variable in the current workspace from inside a function)
> Not sure if it is related to `who` or to the special use of `resume`. I can confirm that it comes from the bug in who for scilab 6.0. See also my solution that uses 'resume' and not 'who' and work in both 5.5 and 6.0 Cheers, Antoine ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] How to replicate what "load" does (aka creating variable in the current workspace from inside a function)
Le 22/02/2016 12:12, Antoine Monmayrant a écrit : Le Lundi 22 Février 2016 12:04 CET, "Antoine Monmayrant" a écrit: Le Lundi 22 Février 2016 11:51 CET, Serge Steer a écrit: The following function does the job: function myload() txt=["a=1";"b=2"]; ncur= size(who("local"),"*") execstr(txt); vars=who("local"); vars=vars(1:size(vars,'*')-ncur-1) args=strcat(vars,",") execstr("["+args+"]=resume("+args+")") endfunction Thank you Serge! It does work on 5.5.0, but it does not work on 6.6.0-beta1. It might be due to the way variables are ordered when calling "who". OK, it seems that "who" no longer list variables with the most recent at the top, but in alphabetical order. . You can use setdiff() to get the names of the new variables, knowing the former set, whatever is their order. Then, you will need to the same before and after calling the function, to get the unknown names of returned variables. Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] ?==?utf-8?q? ?==?utf-8?q? ?= How to replicate what "load" does (aka creating variable in the current workspace from inside a function)
Hi all, For information, I found a solution that works fine in both 5.5.X and 6.0.X: function myload() txt=["a=1";"b=2"]; execstr(txt);//load local variables defined in txt; //build comma separated list of variables in txt csvar=strsubst(txt,'/=.*/',',','r').'; csvar=part(strcat(csvar),1:$-1); //return local variables to the calling environment execstr("["+csvar+"]=resume("+csvar+")"); endfunction Thank you Serge for your kind help. TIL that scilab has a 'resume' function. Cheers, Antoine ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] ?==?utf-8?q? How to replicate what "load" does (aka creating variable in the current workspace from inside a function)?
Hello Antoine, Serge, Le lundi 22 février 2016 à 12:04 +0100, Antoine Monmayrant a écrit : > > Le Lundi 22 Février 2016 11:51 CET, Serge Steer a > écrit: > > > The following function does the job: > > > > function myload() > > txt=["a=1";"b=2"]; > > ncur= size(who("local"),"*") > > execstr(txt); > > vars=who("local"); > > vars=vars(1:size(vars,'*')-ncur-1) > > args=strcat(vars,",") > > execstr("["+args+"]=resume("+args+")") > > endfunction > > Thank you Serge! > It does work on 5.5.0, but it does not work on 6.6.0-beta1. > It might be due to the way variables are ordered when calling "who". Not sure if it is related to `who` or to the special use of `resume`. The resume will push its arguments to the caller context and thus make some variables visible. This is used inside Scilab to define variables on the caller and mimic the library loading behavior. -- Clément ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] ?==?utf-8?q? ?==?utf-8?q? ?= How to replicate what "load" does (aka creating variable in the current workspace from inside a function)
This bug (who results are always sorted) was already reported here : http://bugzilla.scilab.org/show_bug.cgi?id=14352 ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] ?==?utf-8?q? ?==?utf-8?q? ?= How to replicate what "load" does (aka creating variable in the current workspace from inside a function)
Le Lundi 22 Février 2016 12:04 CET, "Antoine Monmayrant" a écrit: > > Le Lundi 22 Février 2016 11:51 CET, Serge Steer a > écrit: > > > The following function does the job: > > > > function myload() > >txt=["a=1";"b=2"]; > >ncur= size(who("local"),"*") > >execstr(txt); > >vars=who("local"); > >vars=vars(1:size(vars,'*')-ncur-1) > >args=strcat(vars,",") > >execstr("["+args+"]=resume("+args+")") > > endfunction > > Thank you Serge! > It does work on 5.5.0, but it does not work on 6.6.0-beta1. > It might be due to the way variables are ordered when calling "who". OK, it seems that "who" no longer list variables with the most recent at the top, but in alphabetical order. Is this a known change? Should I fill a bug report? Antoine > > Cheers, > > Antoine > > > > > > Serge > > Le 22/02/2016 11:21, Antoine Monmayrant a écrit : > > > Hi all, > > > > > > I need to create variables dynamically depending on what I parse from a > > > text file. > > > For testing, I just made a simple script that parses the file and > > > generates a string array that defines some variables: > > > txt=["a=1";"b=2"]; > > > I then > > > execstr(txt);; > > > to create the variables needed (here "a" and "b"). > > > So far, so good. > > > Now, I need to refactor my code to turn my messy script into a proper set > > > of functions (see example code below). > > > The issue now is that I can't figure out how to define "a" and "b" from > > > within the function. > > > I tried to declare them as "global" inside the function, but it does not > > > work: as I haven't declared them global at the top level before calling > > > my function, it cannot work. > > > Sadly, as I don't know in advance the variables I'll find when I parse > > > the file, I cannot declare the variables global at the top level. > > > > > > Any solution or workaround? > > > > > > Cheers, > > > > > > Antoine > > > > > > /example code > > > > > > //script version: > > > > > > clear a b; > > > exists("a")// nope > > > exists("b")// nope > > > txt=["a=1";"b=2"];//typical result from parsing my txt file > > > execstr(txt); > > > exists("a")// yes > > > exists("b")// yes > > > > > > //now with a function > > > > > > //broken & useless > > > function myload() > > > txt=["a=1";"b=2"]; > > > //string to declare a and b global > > > globaltxt="global "+strsubst(txt, '/=.*/', ';','r'); > > > //does not work > > > execstr(globaltxt); > > > execstr(txt); > > > endfunction > > > > > > > > > //does not work > > > clear a b; > > > exists("a")// nope > > > exists("b")// nope > > > myload()// > > > exists("a")// nope > > > exists("b")// nope > > > > > > > > > //this will work > > > clear a b > > > exists("a")// nope > > > exists("b")// nope > > > global a b // well I can't do that in practice, I don't know a and b in > > > advance > > > myload()// > > > exists("a")// nope > > > exists("b")// nope > > > > > > > > > > > > ___ > > > users mailing list > > > users@lists.scilab.org > > > http://lists.scilab.org/mailman/listinfo/users > > > > > > > ___ > > users mailing list > > users@lists.scilab.org > > http://lists.scilab.org/mailman/listinfo/users > > > > > > > > > ___ > users mailing list > users@lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users > ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] ?==?utf-8?q? How to replicate what "load" does (aka creating variable in the current workspace from inside a function)?
Le Lundi 22 Février 2016 11:51 CET, Serge Steer a écrit: > The following function does the job: > > function myload() >txt=["a=1";"b=2"]; >ncur= size(who("local"),"*") >execstr(txt); >vars=who("local"); >vars=vars(1:size(vars,'*')-ncur-1) >args=strcat(vars,",") >execstr("["+args+"]=resume("+args+")") > endfunction Thank you Serge! It does work on 5.5.0, but it does not work on 6.6.0-beta1. It might be due to the way variables are ordered when calling "who". Cheers, Antoine > > Serge > Le 22/02/2016 11:21, Antoine Monmayrant a écrit : > > Hi all, > > > > I need to create variables dynamically depending on what I parse from a > > text file. > > For testing, I just made a simple script that parses the file and generates > > a string array that defines some variables: > > txt=["a=1";"b=2"]; > > I then > > execstr(txt);; > > to create the variables needed (here "a" and "b"). > > So far, so good. > > Now, I need to refactor my code to turn my messy script into a proper set > > of functions (see example code below). > > The issue now is that I can't figure out how to define "a" and "b" from > > within the function. > > I tried to declare them as "global" inside the function, but it does not > > work: as I haven't declared them global at the top level before calling my > > function, it cannot work. > > Sadly, as I don't know in advance the variables I'll find when I parse the > > file, I cannot declare the variables global at the top level. > > > > Any solution or workaround? > > > > Cheers, > > > > Antoine > > > > /example code > > > > //script version: > > > > clear a b; > > exists("a")// nope > > exists("b")// nope > > txt=["a=1";"b=2"];//typical result from parsing my txt file > > execstr(txt); > > exists("a")// yes > > exists("b")// yes > > > > //now with a function > > > > //broken & useless > > function myload() > > txt=["a=1";"b=2"]; > > //string to declare a and b global > > globaltxt="global "+strsubst(txt, '/=.*/', ';','r'); > > //does not work > > execstr(globaltxt); > > execstr(txt); > > endfunction > > > > > > //does not work > > clear a b; > > exists("a")// nope > > exists("b")// nope > > myload()// > > exists("a")// nope > > exists("b")// nope > > > > > > //this will work > > clear a b > > exists("a")// nope > > exists("b")// nope > > global a b // well I can't do that in practice, I don't know a and b in > > advance > > myload()// > > exists("a")// nope > > exists("b")// nope > > > > > > > > ___ > > users mailing list > > users@lists.scilab.org > > http://lists.scilab.org/mailman/listinfo/users > > > > ___ > users mailing list > users@lists.scilab.org > http://lists.scilab.org/mailman/listinfo/users > ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] How to replicate what "load" does (aka creating variable in the current workspace from inside a function)?
The following function does the job: function myload() txt=["a=1";"b=2"]; ncur= size(who("local"),"*") execstr(txt); vars=who("local"); vars=vars(1:size(vars,'*')-ncur-1) args=strcat(vars,",") execstr("["+args+"]=resume("+args+")") endfunction Serge Le 22/02/2016 11:21, Antoine Monmayrant a écrit : Hi all, I need to create variables dynamically depending on what I parse from a text file. For testing, I just made a simple script that parses the file and generates a string array that defines some variables: txt=["a=1";"b=2"]; I then execstr(txt);; to create the variables needed (here "a" and "b"). So far, so good. Now, I need to refactor my code to turn my messy script into a proper set of functions (see example code below). The issue now is that I can't figure out how to define "a" and "b" from within the function. I tried to declare them as "global" inside the function, but it does not work: as I haven't declared them global at the top level before calling my function, it cannot work. Sadly, as I don't know in advance the variables I'll find when I parse the file, I cannot declare the variables global at the top level. Any solution or workaround? Cheers, Antoine /example code //script version: clear a b; exists("a")// nope exists("b")// nope txt=["a=1";"b=2"];//typical result from parsing my txt file execstr(txt); exists("a")// yes exists("b")// yes //now with a function //broken & useless function myload() txt=["a=1";"b=2"]; //string to declare a and b global globaltxt="global "+strsubst(txt, '/=.*/', ';','r'); //does not work execstr(globaltxt); execstr(txt); endfunction //does not work clear a b; exists("a")// nope exists("b")// nope myload()// exists("a")// nope exists("b")// nope //this will work clear a b exists("a")// nope exists("b")// nope global a b // well I can't do that in practice, I don't know a and b in advance myload()// exists("a")// nope exists("b")// nope ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
[Scilab-users] How to replicate what "load" does (aka creating variable in the current workspace from inside a function)?
Hi all, I need to create variables dynamically depending on what I parse from a text file. For testing, I just made a simple script that parses the file and generates a string array that defines some variables: txt=["a=1";"b=2"]; I then execstr(txt);; to create the variables needed (here "a" and "b"). So far, so good. Now, I need to refactor my code to turn my messy script into a proper set of functions (see example code below). The issue now is that I can't figure out how to define "a" and "b" from within the function. I tried to declare them as "global" inside the function, but it does not work: as I haven't declared them global at the top level before calling my function, it cannot work. Sadly, as I don't know in advance the variables I'll find when I parse the file, I cannot declare the variables global at the top level. Any solution or workaround? Cheers, Antoine /example code //script version: clear a b; exists("a")// nope exists("b")// nope txt=["a=1";"b=2"];//typical result from parsing my txt file execstr(txt); exists("a")// yes exists("b")// yes //now with a function //broken & useless function myload() txt=["a=1";"b=2"]; //string to declare a and b global globaltxt="global "+strsubst(txt, '/=.*/', ';','r'); //does not work execstr(globaltxt); execstr(txt); endfunction //does not work clear a b; exists("a")// nope exists("b")// nope myload()// exists("a")// nope exists("b")// nope //this will work clear a b exists("a")// nope exists("b")// nope global a b // well I can't do that in practice, I don't know a and b in advance myload()// exists("a")// nope exists("b")// nope ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users