Utilizing Wolfram Language for HackTX 2015

Hey, y’all. Hope everyone is doing alright and life is treating you well!

So this last weekend I attended my first hackathon, HackTX. For those of y’all that don’t know what a hackathon is, it’s a 24 hr lock-in where you build (or “hack”) some kind of program, occasionally utilizing some kind of library or software that the various sponsors make available to participants; these events have tons of sponsors, who are eager to see what students can do with their products. Thus, these events also function as recruiting opportunities for students seeking internships at tech companies. There is a ton of free stuff to get, great food to eat, and fun to be had at hackathons, and I encourage everyone to try and attend one (even if you’re not a computer science student; I’m not!) if they’re able to.

HackTX is the largest hackathon in the state of Texas, and people from all over come to this event. This year there were ~500 participants checked in, and with sponsors and staff/volunteers, the number of people at this event came close to around 600!

hack3

Tons of participants and spectators alike during the expo! PC: Taylor Barnett

My team consisted of me and two other people, plus a freshman who was mostly just shadowing us (but I considered him a part of the team as well); we worked entirely using the Wolfram Language to build our program. The idea was to take an image and generate a unique 2D cellular automaton structure based on your facial features. We ran into some issues, however: one of which was pattern recognition. We wanted to have a cellular automaton built that was specific to one image, that meant that if we iterated the image multiple times, we would want the same structure. Since the images would primarily be selfies (that was our hope!), that meant that the pattern recognition issues manifested as a facial recognition problem. To get around this, we used a built in function called EdgeDetect. This essentially inverts the image, and maps the contours of the face more easily, which gets rid of our pattern recognition issue.

Screen Shot 2015-09-28 at 10.15.25 PM

An example of what EdgeDetect does. Ignore how tired I look in this coffee shop.

Another issue we ran into was cloud deployment; the Wolfram Development Platform currently doesn’t support a lot of the image processing features available to the language, so our original idea of deploying it and creating an interactive microsite for everyone wasn’t possible. There was no way to work around this other than to do everything in the Mathematica front-end.

Anyway, I wanna go back to talking about the process in more detail: remember that EdgeDetect function I mentioned before? Well, the output of EdgeDetect is a 2D square matrix, which satisfies something called a characteristic equation. Thus, eigenvalues (which are unique to the particular image) can be extracted. My project partner did this, and once he received the eigenvalues, I reverse engineered them to get something called a minimal polynomial, which has a special algebraic relationship with the cyclic behavior of totalistic (additive) cellular automata; I spent several hours reading a couple of formal math papers on the subject (I still don’t understand totally what’s going on, there’s a lot of algebraic field concepts that I am really unfamiliar with) and then spent another several hours writing the code to exploit the relationship; turns out, turning formal math into something codeable is quite difficult!

Screen Shot 2015-09-28 at 10.17.42 PM

The minimal polynomial constructed from the eigenvalue 14.6409… this is one of 14 eigenvalues that popped out of the characteristic equation, ensuring uniqueness.

This minimal polynomial was then evaluated with our indicator random variable (either x=0 or x=1), and since x=0 outputs a trivial solution, we’re only interested in the case when x=1. This output a numeric value, which lies outside of the range [1, 256] (256 is the highest decimal representation of a length 8 list of binary input, since 28 = 256. For some help understanding how binary can be represented as decimals, and vice versa, check out this page). Because of this, we needed to find a congruence between the numeric output and another number within [1, 256] so we could construct the automaton.

Screen Shot 2015-09-28 at 10.22.08 PM

-257 is congruent to 255 (mod 256).

All of this was done to preserve uniqueness of the structure, so that the image you feed the program gives you an automaton that is is yours and yours alone. Once this was finished, the number is read in as the first argument in the CellularAutomaton function, and the structure is built!

Screen Shot 2015-09-28 at 10.29.06 PM

a 2D totalistic cellular automata generated from the selfie you saw earlier! Since these structures evolve with time, there’s a slider to go from n=0 to n=100, where n is the number of steps. Currently, it’s at n=29

As you can see, this was pretty math intensive (especially for a hackathon)! I couldn’t have done it without the help of my team, so shoutout to them for being a part of this project and my overall first hackathon experience! And for also being there for moral/emotional support!

hack1

The team (from left to right): Saad, Ahmed and myself. We’re attempting to look serious.

hack2

Here’s a more candid photo of the three of us.

If you’re interested in taking a look at the code or want a more succinct description of what we did and where the motivation came from, check out our devpost submission. And like always, thanks for reading!

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s