Writing multipage TIFF with Python

You can use the freeimage plugin to SciPy as one method to write multipage TIFF images. You can also use tifffile or libtiff.

On Windows you might see the error:
RuntimeError: Could not find a FreeImage library

On Linux you might see the error:
freeimage had a problem: Could not find a FreeImage library in any of…

To fix this on Windows, download the FreeImge DLL from


Then extract the file
to the following directory (assuming you’re using Anaconda Python)

To fix this on Linux, type
sudo apt-get install libfreeimage3

Example code (assuming you have image stored in C-ordered 3-D array images):

from skimage.io._plugins import freeimage_plugin as freeimg

or try this example test code



OpenCV cv.CalcOpticalFlowHS Horn-Schunck smoothness lambda parameter

More details to come, but I was comparing the performance of OpenCV to Matlab Computer Vision Toolbox for the dense estimates of optical flow given by the Horn Schunck algorithm. I was getting a very different result with OpenCV vs. Matlab for the Optical Flow Estimation. It seemed that OpenCV was washing out fine details in the optical flow. After carefully comparing Matlab Computer Vision and OpenCV outputs for Horn Schunck optical flow, I found that the default lambda/smoothness parameter of 1.0 for cv.CalcOpticalFlowHS is not the same as what Matlab calls 1.0.

I need to quantify this further, but for now I found that in OpenCV cv.CalcOpticalFlowHS setting lambda=0.001 gives results that are much more like Matlab–I can see the fine details. This is just a rough guess, if I have time I’ll quantify it in my forthcoming article on segmenting terabtyes of aurora borealis video in an hour!

PySide in Anaconda3

When using Matplotlib in Anaconda 3, and if you’re trying to use QT4Agg, you may get the error message
ImportError: No module named 'PySide'

To fix this, you can try (using your Anaconda3 pip)
pip install pyside
This will take several minutes and may require the prerequisites:

sudo apt-get install libxext-dev python-qt4 qt4-dev-tools build-essential


Reference: http://movingthelamppost.com/blog/html/2013/07/12/installing_pyqt____because_it_s_too_good_for_pip_or_easy_install_.html

Using USB-serial FTDI adapters with Intel Edison

The current Yocto kernel distro available for the Intel Edison (version 68 by configure_edison --version) does not include the FTDI driver. Thus when you plug a USB-serial adapter into the USB OTG host port, you’ll see it partially recognized in dmesg tail upon plugin, but you won’t see an assignment to a /dev/ttyUSB_ device.

You need to install the FTDI kernel module first.
opkg install kernel-module-ftdi-sio
This assumes you have already setup the unofficial opkg repository.

Now when you type dmesg tail you’ll see the line something like
usb: FTDI USB Serial Device converter now attached to ttyUSB0

You may have to update your kernel if this doesn’t work.

Connecting to Boston University’s 802.1x Wifi from a Linux device

If you don’t have a graphical desktop, BU’s Enterprise Wifi requires the following manual settigns. The settings below are from BU’s recommended settings.  Their webpage has now been updated per my suggestion.

# nano /etc/wpa_supplicant/wpa_supplicant.conf

paste at the end
ssid=”BU (802.1x)”

pairwise=CCMP TKIP
identity=”Your BU login”
password=”your Kerberos Password: be aware others can read this file!”


# reboot

This results in the feedback upon successful connection:

# wpa_cli -i wlan0 status

ssid=BU (802.1x)
key_mgmt=WPA2/IEEE 802.1X/EAP
Supplicant PAE state=AUTHENTICATED
selectedMethod=21 (EAP-TTLS)
EAP-TTLSv0 Phase2 method=MSCHAPV2

WriteLatex vs. ShareLatex

Short answer: Use ShareLatex

1) ShareLatex is much faster to compile. I have a 30 page journal article draft with numerous figures, and WriteLatex seems to take on the order of a minute to compile while ShareLatex was substantially less.

2) ShareLatex has far better error/warning feedback and a much better IDE overall. WriteLatex error/warnings keep disappearing and the line number with error is not clearly indicated.

3) ShareLatex is open-source. WriteLatex is NOT open source.

Intel Edison: Measuring USB voltage on breakout board

I have been trying out a variety of power sources. One is the 4xAA battery holder to female USB Verbatim 97928 available for about $10. It seems to have a well regulated 5.0 volt output.


The red arrow points to the side of the “74” diode that comes right off the micro USB connector. I measured 5.00 Volts there with the Edison running on the Verbatim 97928. On the other side (downstream) of the diode I measured 4.72 Volts with the Edison idling. This voltage drop is expected due to the forward bias diode voltage drop.

Under 100% of one core CPU load, I measured 4.98V on the USB side, and 4.66V on the Edison side of this diode while powering from the USB port on the Verbatim 97928. The miniscule apparent 20mV voltage drop on the battery/USB side of the diode is likely to come from ohmic losses in the USB connector and cable.

Based on measurements of Intel Edison power consumption, and assuming 2000mAh, I estimate 10-12 hours of battery life on 4xAA alkaline batteries assuming continuous 100% CPU of one of the two CPU cores (other core idle). Normally the Edison will be mostly resting, drawing perhaps 100mW.

Thus with mixed use, I might expect to get up to 4-5 days of continuous mixed use operation on 4xAA batteries for the Intel Edison.