Brad's Blog

web dev, django, running, food, or whatever

Shrinking Images with Python 2008-02-15

My wife had a very large image, and she needed some smaller versions of it. Well, I thought I'd just fire up The GIMP and create a few shrunken versions, but by the time The GIMP loaded on my G4 Mac mini, I'd almost finished writing the python coded needed to do the task for me!Writing code is good!import Imagefrom sys import argvdef shrink(filename): im = Image.open(filename) w,h = im.size # Create images that ...

Tracking a Laser pointer with Python and OpenCV 2008-01-24

A recent thread on the OpenCV mailing list (entitled: "Tracking laser dots") discussed techniques that could be used to track the dot from a laser pointer. This sounded like something fun, so I finally got around to trying it out. Essentially this could be done acheived by the following algorithm: Grab the video frame. Convert the video frame to the HSV color space. Split the frame into individual components (separate images for H, S, and V). Apply a threshold to ...

Super Spicy Creamy Veggie Chili 2008-01-14

I like food. I like to eat it... I like to make it. A few days ago I got a craving for some chili, and I almost had all of the ingredients that I needed. What I didn't have, was meat. So, I decided to improvise, and what resulted was the recipe below. It's sure to give all the gastric goodness of any other spicy bowl of chili!Ingredients:1 can black beans.1 can dark red kidney ...

Computing Correlation Coefficients in Python 2007-12-05

A useful technique for matching objects in images is to compute the images' Correlation Coefficients. Essentially, you take any image and compute the correlation between it and another, smaller image containing ONLY the object that you want to identify. The resulting correlation image should contain bright spots where there is a high correlation (or match) between the two images. Here's a simple python script to compute the correlation between two images: https://github.com/bradmontgomery/correlation It requires PIL ...

Announcing pgSlideShow 2007-10-31

I've just released a simple little application called pgSlideShow. It's a free image slideshow application written in Python using pygame. It recursively searches a given directory for image files, and then displays them on a computer screen in Fullscreen mode. You can get it here: http://bradmontgomery.net/pgSlideShow/https://github.com/bradmontgomery/pgSlideShow

On the Move... 2007-10-16

Well, I've just created my account here at blogger.com, and I'll have to try it out for a while before I decide whether or not I'm happy. I've been using my own system for a while, and normally, I'm happy with a simple, stream-lined app, but I've begun wanting new features that I just don't have time to build for myself...So, I'm here. We'll see how it works.

PyOpenGL on OS X 2007-10-16

Update: July 7, 2010: For the past year or so I've been using virtualenv, virtualenvwrapper, and pip to manage and install python packages, and I highly encourage everyone to use these tools! It may take a bit to learn how to use these tools, but once you do, the rewards are great! (especially when using 3rd party python libraries on Mac OS X).To install PyOpenGL using the aforementioned tools, you'd simply do the following.Create a virtual ...

Pygame on OS X with python 2.5 2007-09-23

I've used Pygame on Mac OS X in the past, but my installation recently stopped working for some reason, so I decided to grab the binaries and re-install. After checking out the Pythonmac list, I was a little disappointed to see that there were only Pygame binaries for Python 2.4. Below is a list of software that I installed (in the necessary order) to get pygame working with Python 2.5 on OS X. All of these (except ...

$100 iPhone Early adopter Credit 2007-09-15

There's been a lot of hoop-la about the steep price-drop of the iPhone, and a lot of people have widely ranging opinions about the $100 credit.Well, I (actually, my wife) willingly paid the initial price, and I've been absolutely happy with my iPhone! I also grabbed my $100 credit. All I had to do was hit Apple's website and type in my phone number, and my iPhone's serial number.$100 is $100! Woot!

The Never-ending "To-Learn" List 2007-09-10

I'm officially a student! August marked the beginning of a new semester for me, and this time I'm a full-time student. After being on the faculty side of things for a while, I'm actually having a great time being a student again. One of the major benefits of being a student is that I'm actually getting to dive into that never-ending list of technology tools that I've been wanting to learn how to use!Just ...