## Thursday, December 3, 2009

### Best Poster Award - DICTA 2009

Well the DICTA conference, which is "the main Australian conference on digital image processing, machine vision and related areas." is finally over. I presented my work, which is encompassed in my FTL library, as a poster.

The response to the work was overwhelming, and the end result was the Best Poster Award at the conference. Special thanks to my supervisor Imants Svalbe and Steve Morton for print and processing. I have added the poster to the FTL repository (so its logged). You can view it here.

A lot of interest was shown in the code of the work also, including from Canon Information Systems Research Australia (CISRA) personnel, hopefully it will increase its usage.

Cheers
Shakes - L3mming

## Thursday, November 19, 2009

### DGV 0.1 Stable Released

I have finally released a stable version of my DGV software. You can grab it on Sourceforge.
You can view some tutorials at the Google Code page.

What's DGV for? In my honours, I just wanted an easy, no fuss way to visualise my data (which was a 2D complex scalar field). To my dismay, I couldn't find one and ended up using Excel (I know.... really bad). So I wrote DGV as tool that allowed this. Most times I just wanted a tool view my data quickly. This is DGV's main goal. It has also been supplemented by my current Ph.D project on Image processing.

It has so far clocked over 2000 downloads and has far exceeded all my expectations. As such, it will be supported indefinitely into the future. I will also be adding my FTL Library to it soon, which should propel the software into the forefront of state-of-the-art Convolutions. The next major release will be after I submit my Ph.D Thesis (hopefully around March next year).

Note for Linux uses, the Linux build was built using the latest Ubuntu OS - Koala, so it requires the latest C++ standard libraries. In other words, it should run in any of the latest distros. This may be changed if it is found to be a major problem.

Cheers
Shakes - L3mming

## Sunday, August 23, 2009

### Discrete Geometry 3D Viewer

I thought I'd write list of features of my Discrete Geometry Viewer (DGV) program. I wrote this as a request from the New Projects section of the Linux Journal. The goal of DGV is to make visualisation of data as simple as possible (not something VTK is renowned for) while being intuitive and responsive.

In DGV, the image is placed into a 3D scene using OpenGL (via the VTK library), so it uses your graphics card to render the image. U can pan and zoom, adjust the gamma and rotate it. U can save what you're viewing or just export the data/image. U can also view the raw data in table form (may not be as useful to non-scientific users). From the table u can do surface and line plots. U can also add, subtract etc. images using the Operate feature. Finally, one can see the histogram of the image, which tells u statistical info on the image (output into console also).

The main feature of DGV is Filtering and Convolutions via Fast Fourier Transforms. This allows one to see the frequencies present within the image and edit them via the table. One can do crude Low-pass (smoothing), High-pass (edge detection) or band-pass filtering. DGV also features surface and line animations.

- Pixel values within viewer
- Saving animations
- Python Shell rather than simple console output. See my project called QPythonShell which allows one to embed a Python shell into Qt applications.
- More file formats
- More transforms, like the Number Theoretic Transforms (via my new Number Theoretic Transform C library).

Homepage, Sourceforge, Google Code and Qt Apps.org.

Cheers
Shakes - L3mming

## Saturday, August 15, 2009

### NTTW - The Number Theoretic Transform Library

I have just released my Number Theoretic Transforms (NTT) C library under GPL v3. I've called it NTTW to match FFTW, a well known Discrete Fourier Transform library. It's functions compute the NTTs using Cooley-Tukey's Fast algorithm. The current release only has dyadic length functions. Prime length functions will be released after I submit a journal paper I've been working on.

NTTW is to be part of a larger library called Finite Transform Library (FTL). You can call it Faster Than Light too. :P This new library will feature other transforms I've been working on in my Ph.D, as well as incorporating FFTW. More news later as I complete papers and libraries.

Cheers
Shakes - L3mming

## Thursday, August 6, 2009

### XeLaTeX 1,2,3...

I thought I'd explain how to get started with Xelatex as a three step process.

Firstly though..... why Xelatex?
1. For arbitrary text and maths fonts in your document.
2. Correct ligatures, kerning and other font features. This is only achieved in Latex using the microtype package, it is the default in Xelatex. See Beauty of Latex article.
3. Easier to use arbitrary fonts.
4. Unicode (UTF-8) encoding for special characters like international accents etc.
Step 1: Installing and Using Xelatex
Windows
: Xelatex can be found in Miktex 2.7 or above. Simply download and install Miktex Basic and install the xelatex package from the package manager. If any package is needed later on, Miktex will download and install it for you.
Linux: Install Texlive 2008 or above. Note that all versions of Ubuntu 9.04 and earlier have Texlive 2007. Download the Installer or the ISO file, burn the disc and run the install script ("install-tl"). See Texlive site for more detailed instructions. Go here to use Kile with Ubuntu after installing Texlive 2008.

Step 2: Using Xelatex
Using Xelatex is the same as using Latex. New to Latex? See this all you need guide. Create a new file and insert the following text into it.
%!TEX TS-program = xelatex%!TEX encoding = UTF-8 Unicode\documentclass[a4paper]{article}%XeLaTeX packages\usepackage{xltxtra}\usepackage{fontspec} %Font package\usepackage{xunicode}\title{Your Title}\author{Your Name}\date{\today}\begin{document}\maketitle\section{Section Title}Your text\subsection{Subsection Title}Your Text\end{document}
Save the file with any name. Then using the command line type "xelatex [FileName].tex" where you file is, or in a text editor like SciTE or Texmaker click on the build button. Open and view the PDF file to see the result.

Step 3: Installing and Changing the Font
Changing the font is easy in Xelatex, just add the line "\setmainfont[Mapping=tex-text]{Fontname}" in your preamble (the space before the begin document line) with "Fontname" being the name of the Font. Any font installed on your system is applicable. See my post on Xelatex Thesis Choices for example of using Minion Pro fonts. For instance "Times New Roman" is comon on most systems. Use can see the fonts installed on your system using OpenOffice or any other font application.
Installing a font is easy too. Find and download a font you like (the hard part), see my font survey post to get some free and open ones, and extract if in archive.
Windows Vista: Right click on the TrueType (ttf) file(s) or OpenType (otf) file(s). Then select install. Thats it! To determine the name of the font, either look for it in OpenOffice, Wordpad or MS Office. Or double click to preview and the name is given in the preview.
Ubuntu Linux: Copy the TrueType (ttf) file(s) or OpenType (otf) file(s) to "/usr/share/fonts/opentype". If there is no opentype directory, create it.

That's it... you're good to go. Post any questions below.

Cheers
Shakes - L3mming

## Saturday, August 1, 2009

Having asked the opinions of some of my colleagues and my family (who are now quite sure I'm obsessed about fonts :D ) about the font choices, I have finally made the font choice for my thesis - Baskerville (or its open equivalent, see a sample).

The font has a great history starting from its inception in 1757, which makes it perfect for the type of I'm going for - a Classic font. Wikipedia says:

Baskerville is a transitional serif typeface designed in 1757 by John Baskerville (1706-1775) in Birmingham, England. Baskerville is classified as a transitional typeface, positioned between the old style typefaces of William Caslon, and the modern styles of Giambattista Bodoni and Firmin Didot.

The Baskerville typeface is the result of John Baskerville's intent to improve upon the types of William Caslon. He increased the contrast between thick and thin strokes, making the serifs sharper and more tapered, and shifted the axis of rounded letters to a more vertical position. The curved strokes are more circular in shape, and the characters became more regular. These changes created a greater consistency in size and form.

Baskerville's typeface was the culmination of a larger series of experiments to improve legibility which also included paper making and ink manufacturing. The result was a typeface that reflected Baskerville's ideals of perfection, where he chose simplicity and quiet refinement. His background as a writing master is evident in the distinctive swash tail on the uppercase Q and in the cursive serifs in the Baskerville Italic. The refined feeling of the typeface makes it an excellent choice to convey dignity and tradition.

The open alternatives include Baskervald from ADF Fonts, GFS Baskerville from Greek Font Society (which is Greek only, still good from Physicists/Mathematicians though. Map it to the XeLaTeX Greek fonts), Open Baskerville (UFO Font only.... don't know how to get to Opentype yet) and Boisk Font which is inspired by Baskerville. I will add more as I find them.

Cheers
Shakes - L3mming

## Wednesday, July 29, 2009

### A Font Survey...

I have recently been looking into Opentype fonts that I can use with XeLaTeX and in my thesis.

The first nice option is Minion/Myriad Pro combination (see previous post), but the fonts aren't open... just free for personal use. Another nice option is the Cambria/Cambria Math but there might be licensing issues since they require MS Windows on the Machine.

The free fonts with equivalent metrics to common fonts are another good option. There's a list of other free fonts also. Matching maths used to be a problem with XeLaTeX, though now the mathspec package makes this easy by allowing one to mix and match symbols and fonts together with simple commands (as shown in previous post for MnSymbol).

OpenOffice has some nice fonts install too... FreeSerif and Nimbus. Charis and Gentium are also good but don't have Small caps support. Fontin has won alot of praise but didn't blow me away. Asana Math doesnt have Italics.

I'm not satisfied by the current choices for math symbols either. Latin Modern (XeLaTeX default) math is nice, MnSymbol is ok and Cambria is very nice but not free.... sigh... the search continues.

Cheers
Shakes - L3mming

EDIT: Some more great links to font list.
Great set of GNU fonts is availble at ADF Fonts too. I'm looking forward for the official Science Publication Fonts.

## Tuesday, July 28, 2009

### XeLaTeX Thesis Choices....

I have spent many hours trying to get my thesis looking just right using XeLaTeX. XeLaTeX is basically an extension to LaTeX based on XeTeX which uses unicode fonts. To me this means that I get to use any font thats freely available very easily. (Not sure whether you should convert from Word? See The Beauty of LaTeX article).

Anyhoo... some interesting facts. Most LaTeX packages can be used with XeLaTeX. In fact I converted to it by changing my template to:
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[a4paper,11pt,final,openright,twoside]{memoir}
\RequireXeTeX %Force XeTeX check

%XeLaTeX packages
\usepackage{xltxtra}
\usepackage{fontspec} %Font package
\usepackage{xunicode}
\defaultfontfeatures{Scale=MatchLowercase}

%Select fonts
\setmainfont[Mapping=tex-text]{Minion Pro}
\setmonofont{Courier Std}

\date{}

\begin{document}

\maketitle
\chapter{Title}

\section{Section Title}

\subsection{Subsection Title}
\end{document}

You can then replace Minion Pro, Myriad Pro and Courier Std fonts (which come with Acrobat Reader 9) to any font installed on your system. You will need to compile the document using XeLaTeX rather than LaTeX. Simply reconfigure the latex button of your favourite editor. For those interested in getting MnSymbol package (i.e. the Minion Pro Maths package) to work with XeLaTeX, replace the Select Font part with:
\setprimaryfont{Minion Pro}
\setmainfont[Mapping=tex-text]{Minion Pro}
\setmonofont{Courier Std}
\setmathsfont[Set=Greek,Uppercase=Italic,Lowercase=Italic]{Minion Pro}

Also replacing the XeLaTeX packages section to:
\usepackage[MnSymbol]{mathspec}
\usepackage{xltxtra}
%\usepackage{fontspec}
\usepackage{xunicode}
\defaultfontfeatures{Scale=MatchLowercase}

You can control which font goes to which math font (rm, it etc.). See the mathspec package documentation for details. My experience of XeLaTeX has been quite enjoyable so far, hopefully it stays that way.

Some very useful packages that I've found for my thesis so far has been:
1. Memoir package.... a must really.
2. Natbib... another must
3. The rest in code form:
%Call other packages
\usepackage{varioref} %extends \pageref via \vref to automate things like "on the next page"
\usepackage{memhfixc} %Allows Hyperref in Memoir
\usepackage{graphicx}
\usepackage[draft]{pdfpages}
\usepackage{mdwmath} %Math alignment
\usepackage{mdwtab}
\usepackage[printonlyused,withpage]{acronym} %acronyms package

% Notation package
\usepackage[intoc]{nomencl}% Notation equation ref [refeq]
\makenomenclature

%Temporary Packages
\usepackage[draft]{fixme} %Fix me margin notes and list

4. Others include ntheorem and svn-multi (if you intend on using Subversion for versioning)
Some things to consider though.... XeLaTeX is found in MikTeX 2.7 (Windows) and TeXLive 2008 (Windows/Linux). Ubuntu Linux only uses TeXLive 2007 which is too old and so you will need to install the latest version of TeXLive.... (New version will be out soon)... MikTeX 2.7 has just updated memoir so grab it now if you're on Windows.

Anyway, hope that helps anyone thinking of using XeLaTeX.

Cheers
Shakes - L3mming

EDIT: I have corrected the Minion Pro Math code.
EDIT: I have made the source for a basic but full thesis template is available on GitHub. Enjoy!

## Monday, July 27, 2009

### Windows float to integer compiler woes...

Got my Number Theoretic Transforms to run faster than FFTs from FFTW on Linux via GCC. After attempting to run it on Windows x64 to bench similar result, I found it ran extremely slowly. :(

This was very distressing as what I found was that the truncation of floating pointing numbers to integers is rerouted to a compiler specific function called __ftol (thats float to long), which isn't fast enough.

I found some good links explaining this like Intel Notes on Floating Point-to-Integer Latency and Herf's Know your FPU page. These pages sum up the design flaw in the MSVC 2008 x64 compiler, as most work arounds can be done painlessly only on the x86 version of the compiler.

Apparently they've decided that this function is fast enough, and already marked the compiler flag '/QIfist', which stops it from being used in the x86 compiler, for deprecation!
"No compiler option is needed. The compiler has made significant improvements in float to int conversion speed."
Sigh. I guess this is true for regular use, but my work requires tens to hundreds of milliseconds... and __ftol makes a significant difference. Incidentally, the compiler flag '/fp:fast' did help speed up the program but it is still 2-3 times slower than the GCC version.

I also tried the code
int ftol_ambient(double d) { int i; __asm {     fld d     fistp i } return i;}
Turns out the x64 compiler doesn't support inline assembly.... grrr....

Might have to implement the float casting using SSE (SIMD) intrinsics. Looks like I may have to switch compilers to stick or Linux.

Cheers
Shakes - L3mming

EDIT: The x64 compiler doesn't support inline assembly because it has been replaced with intrinsics. The way to achieve truncation is to use the following code:
static inline int round (double const x){    return _mm_cvtsd_si32(_mm_load_sd(&x));}

### A L3mming's blog...

Just thought I'd start a blog for sharing those "wonderful" Ph.D moments. It will mostly feature some developer findings, XeLaTeX experiences and other life moments that might be beneficial to others.

I guess I should introduce myself a tad... I mainly work on Digital Processing in my Ph.D (or Ph.DuD as I like to call it) using C/C++. I enjoy the Number Theory in my work and the challenges in learning new stuff. I work in Windows and Linux, though I prefer Linux when not gaming.

I have written a scientific visualisation tool called DGV of which I just recently released a new version and hope to release my Ph.D code after its submission.

My wife is expecting our first child in about a month and my 3 years limit (out of 3 1/2) for my Ph.D ends around the same time so It should be very interesting lol.

Well I hope to keep blogging regularly, perhaps fortnightly or as things come about.

Cheers
Shakes - A L3mming