Wednesday, October 14th, 2009

Example MATLAB Code Testing SSIM and CW-SSIM

While learning about structural image quality techniques, I implemented some test code to experiment a bit. Since I didn’t have the MATLAB image processing toolbox conveniently available, I shell out (call external command line programs) to some Imagemagick functions a bit, so watch out for that.

See my test code for the complex wavelet domain structural similarity metric (CW-SSIM). Note that I’m also using Eero Simoncelli’s steerable pyramid tools.

/image processing   〆   permalink

Sunday, September 27th, 2009

Updating NumPy, SciPy, and Matplotlib

I recently upgraded to NumPy to 1.4.0.dev7419, SciPy to 0.8.0.dev5953, and matplotlib version 0.99.1.1.

svn co http://svn.scipy.org/svn/numpy/trunk numpy
cd numpy
python setup.py build
python setup.py install
cd ..

svn co http://svn.scipy.org/svn/scipy/trunk scipy
cd scipy
python setup.py build
python setup.py install
cd ..

python
>>> import numpy
>>> numpy.__version__    # '1.4.0.dev7419'
>>> numpy.test('1','10') # 26 errors in 2231 tests, but usable
>>> import scipy
>>> scipy.__version__    # '0.8.0.dev5953'
>>> scipy.test('1','10') # 165 errors in 4515 tests, but usable

rm -rf /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib*
wget http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99.1/matplotlib-0.99.1.1.tar.gz/download
open matplotlib-0.99.1.1.tar.gz
cd matplotlib-0.99.1.1
python setup.py build
python setup.py install
cd ..

ipython -pylab
>>> plot([1,2,3])

/developer   〆   permalink

Monday, July 13th, 2009

Python Link Roundup

Intra-package References

I just found out that Python 2.5 or newer allows relative imports, something I had been writing custom code to work around. Python documentation gives examples in 3 forms:

from . import echo
from .. import formats
from ..filters import equalizer

Packaging Tools

Alex Clemesha explains modern python hacker tools virtualenv, Fabric, and pip. I find all three of them intersting.

pip is an alternative to easy_install where you can install and upgrade python packages easily with commands like:

pip install -U ipython

Fabric facilitates deploying code to a remote location.

virtualenv lets you setup and manage working environments that aren’t littered with everything you ever installed into your global site-packages directory.

I also recommend virtualenvwrapper, which puts a nice interface on top of virtualenv.

/developer   〆   permalink

Thursday, March 12th, 2009

Ophthalmology Explained: What are those numbers in an eyeglasses prescription?

After visiting the Ophthalmologist yesterday, I received a prescription for corrective lenses with some crazy numbers on it. It looked something like this:

        SPH    CYL  AXIS
O.D.: -1.00  +0.75   180
O.S.: -1.25  +0.75   165

What does all that mean? I turned to the Wikipedia explanation for answers.

It turns out that this is a precription for distance vision only (near vision corrections are usually not necessary for a 25-year-old).

What are the abbreviations?

  • O.D. abbreviates oculus dexter, Latin for “right eye”
  • O.S. abbreviates oculus sinister, Latin for “left eye”
  • SPH stands for spherical diopter units
  • CYL stands for cylindrical diopter units
  • AXIS defines the angle of the CYL correction in degrees

The spherical component is the main correction as it acts equally to correct blur in all directions. The cylindrical component corrects blur in only one direction — therefore it is useful in correcting astigmatism. The axis angle defines the direction of the necessary cylindrical correction.

Addenda (2011 April 24):
In addition, my pupillary distance is 65 mm. This distance from pupil center to center is useful for ordering glasses online (such as at Warby Parker).

/life   〆   permalink

Sunday, February 1st, 2009

My Hat Size

Future me, your head is 22 5/8 inches around, making you a hat size 7 1/4. You will thank present me for that information one day.

/life   〆   permalink

Saturday, January 31st, 2009

Agreed. Git is Awesome.

I agree with every word in Fine. Git is Awesome.

/developer   〆   permalink

Saturday, January 17th, 2009

Mercurial and Git Links

Useful Mercurial Setup suggestions from Ted Naleid.

Daily Git tips at git ready.

/developer   〆   permalink

Saturday, January 3rd, 2009

Introducing numpyIO.py

I implemented numpyIO.py because I often use scipy.io.numpyio.fread() and scipy.io.numpyio.fwrite(), but I don’t want to depend on scipy. It uses numpy’s tofile/fromfile functions instead.

Why might you want this instead of SciPy’s numpyio? Well, I can think of a few reasons:

  • it imports faster because it only depends on numpy, not scipy
  • easier to package with py2exe or py2app
  • it is slightly faster
  • it lets you avoid rewriting legacy code that makes extensive use of scipy’s deprecated fread/fwrite

Grab the numpyIO project from bitbucket or clone the repo with:

hg clone http://bitbucket.org/lannybroo/numpyio

/developer   〆   permalink

Saturday, January 3rd, 2009

Updating to Python 2.6 on Mac OS X Leopard 10.5.6

Install Python from source.

cd ~/tmp
wget http://www.python.org/ftp/python/2.6.1/Python-2.6.1.tgz
untar Python-2.6.1.tgz
cd Python-2.6.1
mate Mac/README
./configure --enable-framework
make
make install
cd ..

Update setuptools so that easy_install works.

wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c9-py2.6.egg
sh setuptools-0.6c9-py2.6.egg

Add the following to my .profile so that the binaries installed by easy_install take precedence over my old Python 2.5 stuff.

export PATH=/Library/Frameworks/Python.framework/Versions/2.6/bin:$PATH

Easy install various packages I use frequently.

easy_install IPython
easy_install nose
easy_install pexpect
easy_install cheetah
easy_install clonedigger
easy_install pyserial
easy_install markdown2
easy_install euclid
easy_install psyco

Do the slightly tougher installs: NumPy (svn rev 6271), SciPy (svn rev 5300), matplotlib, and euclid. See http://www.scipy.org/Installing_SciPy/Mac_OS_X for details. Before starting, I also updated to the latest apple developer tools, although this isn’t strictly necessary.

wget http://r.research.att.com/gfortran-4.2.3.dmg
open gfortran-4.2.3.dmg # install using GUI

wget http://www.fftw.org/fftw-3.2.tar.gz
untar fftw-3.2.tar.gz
cd fftw-3.2
./configure
make
sudo make install
cd ..

svn co http://svn.scipy.org/svn/numpy/trunk numpy
cd numpy
python setup.py build
python setup.py install
cd ..

svn co http://svn.scipy.org/svn/scipy/trunk scipy
cd scipy
python setup.py build
python setup.py install
cd ..

python
>>> import numpy
>>> numpy.test('1','10') # 6 problems in 1897 tests, but usable
>>> import scipy
>>> scipy.test('1','10') # 168 errors of 3990 tests, but usable

sudo port install libpng
sudo port install freetype
easy_install matplotlib

ipython -pylab
>>> plot([1,2,3])

svn checkout http://pyeuclid.googlecode.com/svn/trunk/ pyeuclid
cd pyeuclid
python setup.py install
cd ..

Install wxPython and PythonCard for GUI development.

wget http://downloads.sourceforge.net/wxpython/wxPython2.8-osx-unicode-2.8.9.1-universal-py2.6.dmg
wget http://downloads.sourceforge.net/wxpython/wxPython2.8-osx-docs-demos-2.8.9.1-universal-py2.6.dmg
open wxPython2.8-osx-unicode-2.8.9.1-universal-py2.6.dmg
open wxPython2.8-osx-docs-demos-2.8.9.1-universal-py2.6.dmg

wget http://prdownloads.sourceforge.net/pythoncard/PythonCard-0.8.2.tar.gz
untar PythonCard-0.8.2.tar.gz
cd PythonCard-0.8.2
python setup.py install
open /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PythonCard/samples/minimal/

Then, Ctrl-click and open minimal.py with Python Launcher to test.

/developer   〆   permalink