Controlling LEDs from MATLAB

28 December 2010

As part of the GelSight project, I have been exploring options for controlling LEDs and cameras from MATLAB. I came across the Arduino platform and was able to develop a working system with almost no prior electronics experience. This post documents some of my initial experiments with controlling LEDs from MATLAB using an Arduino board.

Capturing Linear Images

01 July 2009

In a recent project, I had to capture and process linear images. In a linear image, the value at every pixel is directly related to the number of photons received at that location on the sensor. While most people do not have to worry about linearity, and in fact, consumer cameras apply nonlinear response curves to the captured data, scientists often derive relationships that assume linearity. In this post, I describe several methods for achieving linear images and describe a few pitfalls that I encountered while attempting to capture linear images.

Redirecting Old Websites

16 May 2009

I have been gone from Dartmouth for over a year and my website has remained active but somewhat broken due to neglect. It turns out that some of the blogs on that site are on the first page of google search results for related keywords. When my Dartmouth site finally goes away, it would be a shame if users encountered 404 errors when trying to access pages. I did some quick searching for the best way to redirect a page to a new location and it seems that a 301 redirect is a good option. I wrote a python script to redirect all the html pages on my site to their new urls and this script might be useful for other people facing the same problem.

Execute Text in Terminal

22 March 2009

Most of the code I've written in the last few years has either been in MATLAB or Python, and both languages have interactive shells. As a result, the way I typically work is to write a few lines of code in my editor and then execute them in the shell to check the results. This is a great way to work if you're doing scientific computing because it's important to know what your data looks like at every stage. But I find myself copying and pasting between my editor and the shell all day long, which takes 3 keystrokes for every text selection: command-c, command-tab, command-v. Using the scripts here, this process can be streamlined.

Photoshop + MATLAB

14 March 2009

As a researcher who works with digital images, I have two programs open all day long: Photoshop and MATLAB. Since Photoshop CS3 came out about two years ago, I have been increasingly using both programs together. I frequently send images to Photoshop from MATLAB and also read images back into MATLAB from Photoshop. In this post, I give a demonstration of some of my favorite ways to use these programs together.

Static Websites using Webby

27 January 2009

Until recently, the pages of this site were generated by the Joomla content management system (CMS). There were a number of reasons I initially chose a CMS for this site, including the ease of adding new content and the flexibility of being able to view the content in different ways. But over the last few months, I have become concerned by the idea that my content lives in a database in some unknown format, and that if I switch hosting services it may be complicated to migrate to another system. Also, a CMS is overkill for a site like this, where the content is static and updates are (unfortunately) few and far between.

A Quick Look Plugin for txt2tags

07 December 2008

Txt2tags is a lightweight markup language that can be converted into many different formats. I have been experimenting with it as a way of simplifying this site since I am uncomfortable with the idea that all of my content is stored in a remote database in some unknown format. I'll describe more about my experiences converting this site to txt2tags in future blogs; in this blog I thought I would share a Quick Look plugin I wrote to make txt2tags seem like less of an outsider on OS X.

Improving Your MATLAB Figures

05 March 2008

I admit it - I'm lazy when it comes to reading technical papers. I usually do a four step approach: abstract, figures, conclusion, and then the whole paper if I'm still interested after the first three steps. But too often the figures are so poorly made that I can't understand them without reading the paper. Many people make plots in MATLAB and it can be challenging to make the plots look good since the default settings are fine for the screen, but not for print. In this post, I describe some simple techniques for improving MATLAB figures and provide an example figure with code.

A Thesis Template

31 August 2007

A major milestone for a Ph.D. student is the point when he or she begins writing (or is given permission to begin writing) the dissertation. At this point, a good part of the work is complete (and hopefully published) and the task is to take this work and put it together into one document. As I began to compile my publications and organize them into a dissertation, I looked around for thesis templates that conformed to Dartmouth's specifications. I don't think I found anything, which is why I am posting this template.

Creating a Scientific Poster with LaTeX and OmniGraffle

05 May 2007

Some might accuse me of doing things the hard way, and I suppose they might be correct. Recently, I had to make a poster for a poster session and I was faced with the problem of choosing the appropriate tool for the job. Most people would probably use PowerPoint, but I've never been pleased with equations in Microsoft products. I've also had issues in the past with PowerPoint converting pdf figures into bitmap images. Adobe InDesign was also an option, but I decided it was too much for this job - I'd spend more time learning to use the program than actually making the poster. In the end, I settled on tools I'm familiar with: LaTeX and OmniGraffle. Perhaps a more complex solution than simply using PowerPoint, but the equations look good and the layout was simple.

Back to Vim

30 March 2007

About eight months ago, I switched back to vim as my main editor. I had been using TextWrangler for a few years, but before that I was a vim user, and somewhat of a power user as well. I think the main reason I had moved away from vim was the lack of tabs, or perhaps it was simply the un-maclike experience. TextWrangler offered a familiar interface and had a nice feature set (for the price). But, I was interested in an editor with more power and better syntax highlighting. I briefly tried TextMate, but wasn't impressed enough to switch. So I came back to vim, which now has tabs and can become somewhat maclike with plenty of customization.

Organized Research

05 January 2007

Over the last few years, I've developed a way of organizing my research that works quite well for me and may work well for others. I've decided to document it in hopes that it will help other students organize their research. Before I get into the details, here are the fundamental ideas behind my system.

Subversion

02 December 2006

I recently decided to put all my files under a real version control system. I've always had an ad hoc version control system anyway, grouping my files into experiments and keeping a journal of notes and results for each experiment, but there was no easy way to track the history of files and view recent changes. Also, I felt it was important to check-in the exact set of code and experimental data that produced published results and to be able to return to that state at any point. And finally, I run the same code on multiple computers (laptop and cluster) and version control is an easy way to sync files. So I spent an afternoon a few weeks ago setting up svn on a remote server and uploading projects. It wasn't completely painless though, and I've jotted down a few of the issues that came up in the process.

Build Jar with Externals

14 October 2006

In several different Java development projects, I've needed to create a single jar with my project classes and also bundle the external jars my project requires. A while ago, I wrote an Ant build script to do this and I figure this script could be useful for others.

Developing ImageJ Plugins in Eclipse

06 October 2006

Eclipse is a great Java development environment. Its refactoring, continuous compilation, and import management features really improve my productivity and make Java development far less painful. The downside, if you've never used it before, is having to learn a new IDE and having to search for where in the IDE to specify certain settings. Here is a small guide on how to configure Eclipse for ImageJ plugin development.

Creating Figures for Publication in MATLAB

14 August 2006

Recently, I ran into a snag with a publisher over non-embedded fonts in figures in my paper. While these figures displayed and printed fine from both Mac OS X and Windows, the publisher required that all fonts used in the paper be embedded in the PDF, including the standard PostScript (or Base 14) fonts. Using Adobe Acrobat's Preflight tool, I was able to see exactly where the problem was occurring - it was the axis and tick labels in figures I created using MATLAB.

Joomla static mirror

11 August 2006

After spending time figuring out how to get the CS department web server to talk to my existing joomla database, I decided it was just too slow. Pages were taking between 3 and 5 seconds to load and I think most of the delay was from communication between the two servers. Even with caching enabled, it wasn't fast enough for me.

Moving Joomla

10 August 2006

This site is now hosted on two different servers, both pointing to the same Joomla database. All in all, the process of moving the site was fairly painless. I tarred and gzipped all the files from one server and unpacked it on the other. I then modified configuration.php to contain the new webserver information and I left all the database info the same. Within minutes, the front page loaded on the new server.

Google Image Results

08 June 2006

This week, I have been researching radial lens distortion. I have a simple mathematical model of the distortion and an algorithm for estimating the parameters of the model. Everything works well in simulation so it's time to test the algorithm on real images. I remembered that the camera review site dpreview.com had detailed images of lens distortion for many different cameras. Rather than navigate through their multi-page reviews searching for the images, I did a Google image search: "distortion site:dpreview.com." This search returned over 20 pages of results, more than enough for testing my algorithm. Downloading all the images by hand would be a slow and painful process, so I wrote a python script to do the work for me. This script is coded to the specifics of this problem, but it could be modified to automate the downloading of any set of Google image results.

Dartmouth.edu

16 May 2006

The webmasters at Dartmouth have decided to force intel mac users to always use HTTPS when connecting to any site at dartmouth.edu. For whatever reason, I can no longer connect to the site, and other people have been reporting the same problem on the discussion forums at apple.com. When we attempt to connect, we get a "client certificate rejected" error. The page does load in other browsers, however.

New Music

09 May 2006

I went to a discussion yesterday entitled "What is New Music?" The point of the discussion was to attempt to define New Music; I left less than satisfied. Some of the proposed definitions included "any music made by a computer" and "we can't define New Music." The former is clearly untrue and many counter-examples come to mind: the music of David Cope is an obvious example, but I would propose that most music made by a computer is not new. The computer is just the latest tool for making music and while it can play many roles in the process, the computer can make any style of music, including old and new.

Key Bindings

03 May 2006

A feature I love about Mac OS X is the fact that key bindings are consistent across applications. Once your fingers learn apple-s for save, apple-q for quit, etc., you become much faster. The default cursor movement keystokes, however, are awkward: apple-rightarrow jumps to the end of the line, apple-leftarrow jumps to the beginning of the line, option-rightarrow and option-leftarrow skip by word. I don't like the fact that I have to move my right hand out of home position to use them. Users of UNIX systems are familiar with another convention, emacs-style key bindings, and these can be easily enabled on Mac OS X.

The Secret Dictionary

01 May 2006

One of the features I use quite often in OS X is the secret dictionary. I call it "secret" because it is accessed by an obscure keystroke, and I would bet that most Mac users are not aware of it. In any Cocoa application, type ctrl-apple-d while positioning the mouse over a word, you can try it now if you're viewing this page in Safari. A small dictionary window will pop up over the word. This feature works in Apple's apps: Safari, Mail, Stickies, etc., as well as some third party apps: TextWrangler, MacJournal, and OmniOutliner. I think it works in any application that uses Cocoa's built-in text editing tools. This makes me wonder how many other secret features are in the OS.

Vim.app

12 April 2006

I use TextWrangler as my default editor, but in cases where there's lots of repetitive editing to do, I prefer vim. Terminal vim is fine with me, the only downside is that it's a pain to launch files with it. The typical way I open a file is to drag it from the Finder onto TextWrangler in the Dock. This habit was developed because MATLAB files use the same extension as Objective-C files (.m) and if you open by double-clicking, you usually end up opening the wrong application. Anyway, the solution was to create a simple AppleScript that calls vim when you drop a file onto it.

MATLAB on MacBook Pro

11 April 2006

I did some simple testing of MATLAB on my MacBook Pro today. I compared MATLAB running (emulated) in OS X to MATLAB running in XP via Apple's Boot Camp and also in XP using a Parallels virtual machine. The results are somewhat surprising in that I was expecting MATLAB in Boot Camp to be fastest overall, but that isn't always the case.