Wednesday, 26 October 2011

Installing Matlab with standalone user on Ubuntu Linux

OK, after doing this in an awkward manner a couple of times, here is how I install Matlab on Ubuntu with a standalone license:

  • Download the files from Mathworks
  • Run the install script with sudo (as root), but DO NOT activate the license yet. Choose custom install, use default install location, tick the box for creating symbolic links.
  • After installing, try to run Matlab (not as root). The activation procedure will start automatically. Register your own user name for the standalone license.
  • Matlab (with GUI) can now be run by calling the command "matlab -desktop". To create a application launcher for it, use the "Main Menu" program (also called Alacarte, can be installed with the Ubuntu Software Center). Get a logo for the launcher here, or put it right where it belongs by using this command:
sudo wget http://upload.wikimedia.org/wikipedia/commons/2/21/Matlab_Logo.png -O /usr/share/icons/matlab.png

I also recommend having a look at the Ubuntu Documentation for Matlab installation. It might not always be completely up to date, but the procedure doesn't change much between releases.

Monday, 10 October 2011

Merging images into movie using FFmpeg

Let's say that you have a number of images, named image001.jpeg, image002.jpeg, image003.jpeg etc., and you want to merge them into a single movie, for example to create a time-lapse video. FFmpeg is a great commend-line tool for doing this kind of stuff. To use FFmpeg to create the movie "outmovie.mp4", with 25 frames per second and reasonable quality, enter

ffmpeg -i image%03d.jpeg -sameq -r 25 outmovie.mp4

Note the format image%03d.jpeg, indicating that the numbering of the files has three digits with (possible) leading zeros. To set the output bitrate explicitly to for example 64 kbits/s, use the switch "-b 64k" rather than "-sameq". See the FFmpeg documentation for lots of other possibilities.

Wednesday, 5 October 2011

Converting images from PDF to PNG using ImageMagick

I usually prefer vector formats like PDF for my figures, but some times I need to make a PNG version. ImageMagick is my tool of choice to do this, since it can be called from the command line. My initial try was something like this:

convert figure.pdf figure.png

which indeed converts the figure from PDF to PNG, but with a much too low resolution in the PNG image. After reading up on the subject on the Magick-users mailing list and the ImageMagick documentation, I found out that the default resolution at which the PDF file is read is 72 DPI. To read with a higher resolution, for example 600 DPI, use the -density option:

convert -density 600 figure.pdf figure.png

As a little side comment, I could mention that I first tried to do this because when I saved a figure from Inkscape as PNG, the resolution was very poor. The workaround was then to save as PDF and convert to PNG. However, afterwards I remembered that Inkscape also has a "export bitmap" option, which will allow you to set the density before saving to PNG. Oh well, the ImageMagick conversion may still come in useful some day...