Octave is a free software clone of Matlab with a lively community of users and developers.
Octave-forge is a repository of extensions that haven't made their way to Octave yet or are too specialized to do so, including free substitutes of Matlab toolboxes.
The Octave Wiki is just that, a wiki to which Octave users are invited to contribute.
I work a lot with Octave and, in return, contribute to its development. Code that is clean enough and is of general utility I add to Octave-forge. I've put below code that is too specialized to fit in Octave-forge.
During my studies, I wrote some Octave functions to visualize 3D data using VRML. These functions went to the Octave-forge VRML package. I've used them again at my latest job, and my manager at Magic Leap is glad to let me open-source the fixes and improvements I bring.
I don't have the time or will to do a full maintenance job on Octave-Forge, so I just leave the latest files here:
This collection of m-files, developed for my work at Tyzx, implements a raw octave-gnuplot interface: allows to create temp dirs, save data, and run arbitrary gnuplot commands. This interfaces is mostly for people who know how to use both gnuplot and octave but also has a shortcut function g_ez(...) that allows to do plots with a single command.
For installation, just run from the octave prompt "pkg install gnuplot-1.0.0.tar.gz", then "pkg load gnuplot", as indicated in this page.
For a fast start, type "demo g_ez" in the octave prompt, or try the g_demo() function, as it shows how to use the pm3d (and image) feature. You may also be interested by the 'myimage' function (uses the image viewer display, some functionality requires imagemagick) to manipulate/display images.
octave> help g_new g = g_new ( ...) - Create a new gnuplot_object and its directory The g_XYZ() functions allow Octave to create plots with Gnuplot. They are little more than an Octave front-end to Gnuplot, but allow to do anything Gnuplot can do directly from Octave. In addition, there are some commodity functions (g_cmd() with struct arg, g_locate()) that allow to nest one figure in another. g_new() creates a temporary directory in which data and commands will be stored in a gnuplot-readable format. g_new accepts key, value pairs of arguments, which will be passed to g_set. Typical usage: g = g_new (Snapshots from the output of g_demo():) g = g_data (g, "myChosenDataFileName", data, ...) g = g_cmd (g, ,\ "plot 'myChosenDataFileName' with lines",...); g_plot (g, ); DEMO: Run g_demo(), or see http://gnuplot.sourceforge.net/demo_4.1 on how to do nice plots. SEE ALSO: g_ez, g_delete, g_data, g_cmd, g_plot, g_set, g_locate. TODO: an OO style of function call (see failed attempt at end of g_new code)
A simple plot | Four of the same, w/ different colors |
Octave's sombrero mascot | The same, in color |
A graded checkerboard image | The same, seen in 3D |
octave> help myimage im2 = myimage (im,...) - Make im viewable by normalizing greylevels and more Scales the values of im so that they range in [0,255]. The smallest element of im (or range(1), if the "range" option is used) is mapped to zero, and the largest (or range(2)) is mapped to 255. If both dimensions are less than 180, If the save option is not used, and nargout is 0, then im2 will be displayed, rather than returned. NaN and Inf pixels become black or, if the image is saved as a .png or .gif, transparent. OPTIONS: -------- "range", [min,max] : Graylevel range to be mapped to 0:255. Default:[min(im(:)),max(im(:))] "qrange", [minq,maxq]: Map quantiles between minq and maxq to 0 and 255. "minsz", [Rows,Cols] : Minimum dims of im2. im will be scale by an integral factor so that at least one of its dimensions matches minsz. Default: [180 180] "scl", scl : Scale image size up (scl>1) or down (scl<1) "invert" : Invert image (black becomes white and vice versa). "is_col" : Color image, consecutive rows being R, G and B. "colormap", : Convert greylevel image to a 'rainbow' colormap "show_range" : Place a graylevel scale below image. "scale_sz",sz : Width of graylevel scale. Implies show_range. "text", [x,y], str : Annotate image with str, at position x,y, with size sz "text", [x,y,sz],str "line", [x,y,x,y,R,G,B,W] or "line", [x,y,x,y,R,G,B] or "line", [x,y,x,y,C,W] or "line", [x,y,x,y,C] or "line", [x,y,x,y] "save", filename : Save im2 in filename. "display", yesno : Display im2 or not. Default: False iff save requested or nargout!=0. EXAMPLES: type "demo myimage" to run the examples below --------- myimage (randn(3,3), "show_range") myimage (rand(9,3), "is_col") myimage (randn(32,32), "minsz",[32,50]) myimage (ones(64,1)*linspace(0,1,256), "colormap") myimage (linspace(0,3,256)'*ones(1,64), "range",[3 1]) myimage (zeros(200,200), "text",[10,20],">> 1 + pi\nans = 4.1416\n>>") im = kron (ones(4), kron (eye(2),ones(10))); im += ones (80,1)*linspace(0,1/2,80); myimage (im,"text",[11,5],"Hello","text", [10,30,30],"world") FIXME: scl < 1 seems to be buggySnapshots from the output of myimage():
myimage (randn(3,3), "show_range"); | myimage (rand(4,5,3)); |
myimage (zeros(200,200), "text",[10,20],">> 1 + pi\nans = 4.1416\n>>") | im = kron (ones(4), kron (eye(2),ones(10))); im += ones (80,1)*linspace(0,1/2,80); myimage (im, "text",[100,200,200],"Hello","text", [20,400,200],"world") |
This patch for Version 4 of David Lowe's SIFT software could be of interest to Octave users who do image processing. It allows Version 4 of David Lowe's SIFT software to work under both Matlab and Octave. This patch is temporary: it should make it into the next release of the SIFT software.
The SIFT image detector identifies interest points, somewhat like a corner detector does, and gives them a local descriptor. The descriptor can then be used for matching purposes (another way to perform matching could be correlation of a small window around the feature). Wrt to corners + local window correlation, SIFT features are more robust to changes in illumination and viewpoint and they are increasingly used in computer vision. The siftDemo has functions to find sift features and to perform matching. I've tested the patch under octave+linux, matlab+linux (it works) and octave+win (it fails, probs w/ imagemagick + double). You can apply it to the matlab code in siftDemoV4 to allow Octave to extract SIFT image features with David Lowe's package.unzip siftDemoV4.zip; cd siftDemoV4; patch -p1 < mySift.patchIn Octave, make sure sift.m is in your path; then the following commands should find and display the features.
[image, descriptors, locs] = sift("YOUR-PATH-HERE/siftDemoV4/book.pgm"); showkeys(image, locs) See also 'help match'
Snapshots:
Output of showkeys() | Output of match() |
here is a sudoku solver which I tried on 3 problems from The Providence Journal. It worked.
[output,feasible] = sudoku (input) - Try to solve a sudoku problem This function applies brutish force and may or may not work properly. The method (1) excludes impossible values of cells within each group (row, column and 3x3 block), (2) deduces the value of a cell that is the only one to be able to assume that value within a group and (3) makes guesses and sees where they lead (depth-first search). Does not check for unicity. May or may not detect unsolvalble cases properly. Please report success/failure to me. input : 9 x 9 : initial grid w/ unknown values set to 0. output : 9 x 9 : final grid. feasible: true if a solution was found, 0 otherwise.Example (from The Providence Journal):
>> dummy4 = [0 0 0 6 0 0 0 0 7; > 0 6 0 2 7 0 5 0 3; > 0 0 4 3 0 1 0 9 0; > 8 9 0 0 0 0 0 0 0; > 0 4 0 0 0 0 0 7 0; > 0 0 0 0 0 0 0 5 2; > 0 2 0 5 0 6 7 0 0; > 5 0 6 0 3 9 0 2 0; > 7 0 0 0 0 2 0 0 0]; >> sudoku (dummy4) ans = 1 5 3 6 9 8 2 4 7 9 6 8 2 7 4 5 1 3 2 7 4 3 5 1 8 9 6 8 9 5 1 2 7 3 6 4 3 4 2 9 6 5 1 7 8 6 1 7 8 4 3 9 5 2 4 2 1 5 8 6 7 3 9 5 8 6 7 3 9 4 2 1 7 3 9 4 1 2 6 8 5
I enjoy programming in Perl although I haven't done much beyond one-liners recently. Guess what this does (when you feed it to the shell) :
perl -e 'print map{("J CANT SPEL HUORK\n\t"=~/./sg)[-70+ord]}Of the programming languages I know, Perl is the most useful and the most fun. This is just an opinion since I don't know all the programming languages around. More on that on the "Fun with Perl" mailing list.
"WXXXXFSMKGIJTKROUGNOUPGRIHVOUWW"=~/./g'