The code I used can be found below. All parts of this project were written in Processing.
Download Average Colors program.
Download Interface program.