Quick and dirty border detection code. Includes sample image.