ASCII Art Converter

In the February Code Dojo, Jemma and I made an ASCII art converter in Java that takes an image as input and converts it into a text document which, when zoomed out far enough, imitates the original image.

The output text document, the input image, and the input image converted to greyscale.
From left to right, the output text document, the input image, and the input image converted to greyscale.

This was done by first iterating over every pixel in the image after it has been converted to greyscale. The luminance of every pixel was then calculated by using a formula found online:

// calc luminance in range 0.0 to 1.0; using SRGB luminance constants
float luminance = (red * 0.2126f + green * 0.7152f + blue * 0.0722f) / 255;

This luminance value was then stored in a very large 2D array. The array is then looped over and certain ASCII characters are chosen based on the luminance value selected.

diffLum is the difference between the largest value of luminance found (largeLum) and the smallest value of luminance found (smallLum), the addition of this as opposed to set values between 0 and 1.0 mean that the whole range of characters is still used even if there is not a great difference in the source image’s luminance values.

// choose brightness threshold as appropriate:
if (luminance <= (diffLum*0.1) + smallLum) {
    chars[x][y] = ' ';
} else if (luminance <= (diffLum*0.2) + smallLum) {
    chars[x][y] = '.';
} else if (luminance <= (diffLum*0.3) + smallLum) {
    chars[x][y] = ':';
} else if (luminance <= (diffLum*0.4) + smallLum) {
    chars[x][y] = '-';
} else if (luminance <= (diffLum*0.5) + smallLum) {
    chars[x][y] = '=';
} else if (luminance <= (diffLum*0.6) + smallLum) {
    chars[x][y] = '+';
} else if (luminance <=(diffLum*0.7) + smallLum) {
    chars[x][y] = '*';
} else if (luminance <= (diffLum*0.8) + smallLum) {
    chars[x][y] = '#';
} else if (luminance <= (diffLum*0.9) + smallLum) {
    chars[x][y] = '%';
} else {
    chars[x][y] = '@';
}

The chars array is then looped over and written into a text, .txt, file.

The solution works well however the output cannot be resized and so the source image must be downsized quite a bit before it is truly useful as an ASCII converter.

Global Game Jam 2016

At University of Southampton, I helped develop an isometric real time strategy town management game where you must balance resource management with your relationship to the gods. I joined a team which participated last year and used a game engine that was developed in last years game jam. The finished product was called Vikings vs Gods: Cheese fortress and was overall a quite good game.

http://globalgamejam.org/sites/default/files/styles/game_content__wide/public/games/screenshots/screenshot_313.png?itok=CHpnpXCs
Screenshot from Vikings vs Gods: Cheese Fortress

It the 48 hours, I helped develop the basic quests and gods outline and tried to overall polish the game through adding unique mouse cursor, splash/intro screen, win screen, death screen, as well as fixing some issues that were left over from when the game engine was used from last year.

Git repository can be found here: Click me

Global Game Jam page can be found here: Click me

How to extract images from a Word Document

After Googling this question and being disappointed at how much work was needed to find a good answer, the only useful post was this old post for Word 2007, here is a definitive blog post about the topic. This post assumes use of a Microsoft Word 2013 though the method would work on almost any word processor.

The by far simplest method is to save the document as a webpage. This is done by choosing the correct file type when saving as a new file. This is done as normal when saving the file but choosing a different “save as type”.

The save screen when saving the document.
The save screen when saving the document.

Next, simply navigate to the folder where you saved the document as a webpage and you should find a new folder called “Example_files” alongside the new .htm file. Inside the folder will be every photo within the document in a .jpg format along with some meta data and other stuff you dont need to worry about.

Hooray!

Are the Labour party secretly lizard monsters?

What is it about the politics of today that makes everyone just feel a little bit shit? It could be that politicians are simply out of touch with the modern day human being and that could be because MPs aren’t in fact human beings.

220px-The_Subsidised_Mineowner
A typical Conservative MP.

 

I, for one, welcome our reptilian overlords. After all, lizards are well known for being intergalactic space conquerors: can humans say the same about their achievements? I would say no.

Therefore, the only solution is a complete destruction of the current system of politics. We should collectively envision a world where people directly participate in politics through constant Lizard-to-People interactions in forums, meetings, and comedy festivals.