A collection of articles, apps, and other digital resources, thematically tied to the subjects of art, design, programming and general philosophy. All content created by "The Imp".

This website does not use cookies, because they are high in sugar and saturated fat. (Yes, they are tasty too, I know, I know...)

Koart

05/04/2019

Above: Programatic assemblage art, composited by the resultant software. Here, it was supplied with the keyword "dramatic".

Some time in 2016, I was working on a project that needed a lot of imagery. After dismissing the creation of 5,000 illustrations, and the use of unembellished prefabricated stock imagery (most suited for marketing collateral, and typically quite prosaic, I thought), I began to wonder if some clever programming could help spice up existing royalty-free graphics.

I had a collection of such images stored on my hard disk. (In a previous project - a bid to make my image-sourcing process more streamlined for graphic design work - I had written and deployed a little crawler program that searched various sites for royalty-free images matching a predefined list of words). As each image was downloaded and archived locally with its keywords, this graphics morgue was appropriately queryable.

Version 1.0

The concept of combining images was technically quite simple: Use PHP to query the images database against a user-supplied search term, and then pipe the 2 - 8 most relevant images into a compositing class that leveraged the Imagemagick extension.

Below: 4 images compiled with the resultant software.

As the idea developed, I built a few notable features / figures into the program.

  • Generators The first draft of the software only had one compositing mode: Double exposure, which is shown above. Double exposure takes two images and lays one on top of the other, with a middling opacity. This did produce some interesting results, but it became desirable to have more compositing algorithms. I separated the compositing code from the main class, and exploded it into a separate parent class (Generator - an abstract class) and a subclass (Double). The additional subclasses developed included Montage, which composites several images over the top of one background image, and Glitch, which behaves similarly, also applying, however, a range of distortion effects to each of the input graphics.
  • Mutators Several operations were common to many compositors. For instance, overlaying one image over another, adding text to the image and applying a random positional and rotational transformation, or applying distortion effects randomly to a single layer. Each operation required quite a lot of code, so I created the concept of mutators to wrap verbose Imagemagick configurations and calls.
  • Thesaurus expansion At times, searching for an obscure word would yeild no results. To fix this, I had the idea of using a thesaurus implementation, and a map of related words (broader than synonymns) to widen the user's search terms.
  • Incidental text The juxtaposition of loosely related images was interesting, so I decided to encourage further interplays of meaning by superimposing lines of text, related to the search term, onto the graphic. I opted to achieve this in the simplest (but not the most flexible or computationally efficient) way by placing a small repository of txt files within the project directory, to be queried with a regular expression. (/term1|term2|term3/). I opted to supply the following texts for the software to draw from:
    • Grimm's Folktales
    • Arabian Nights
    • Bram Stoker's Dracula

Occasionally, a combination of good keywords, good programming, and luck, creates an assemblage of images that seems to tell a story. It implels the mind to think "Why are these images visually intertwined? How is it that they might be related?". The two images above feel a bit like movie posters or crime fiction covers, and to me, each contains so much more drama and intrigue than their constituent parts.

Above: Here, the combination of images works to create a compelling illusion of a portal or apparition. The aggregate on the bottom left has been created by superimposing a photograph directly over a differently filtered version of the same photograph. The magic of generating creative artefacts according to computational processes is that humans are one step removed from the creative action. Through randomness, loosely bridled with algorithms, a computer acting on basic instructions will combine things much more injudiciously than a person, and without bias. This can cause a computational artisan to yield very novel things - things that a human mind might overlook as the result of initially perceived unoriginality, perceived incompatability of concepts, creative habits and inclinations, and hyperviliant avoidance of cliches and faux-pas.

In order to combine two images of different size without producing unsightly hard edges, I use an alpha channel mask bitmap. I intially used simple radial gradients, but later experimented with grunge maps consiting of blemishes, spills, patches, flecks. In some cases, such as those shown below, a second image is not clearly visible, but the grunge map mask works in conjunction with a randomly generated background colour to add a certain aged sentimentality to the original photographs.

The bitmaps employed by the various generators / compositors as alpha channel masks are shown below.

Montage alpha mask bitmaps

(The afore-mentioned simple radial gradients)

Montage alpha mask bitmaps

(The afore-mentioned grunge maps)

Montage alpha mask bitmaps

As used by the glitch generator compositor

The "Glitch" compositor is a rather cunning device, as it riffs on the digital genesis of the images. Historically, art that has been created by computers has been pixellated and distorted. It is an aesthetic that can be exciting to - and perhaps expected by - the parametric art appreciator. It's a happy cliche - like the use of scratching in hip-hop, or the devil's triad in rock music. It is a bit of a trick, however, as it is purposely and artificially injected. I've achieved this aesthetic quite easily by tactfully employing some Imagemagick distortion filters, and through creating some good, techy-looking alpha masks.

Below: More various images created using the tool. Sometimes the juxtaposition has a special effect, but usually, it just creates the sense of a story, or a state of mind. There's something about the exhibition of loosely related information that is quite poetic - perhaps it is because there are parallels to a human's means of perceiving the world - tiny, idiosyncratic snapshots of an sea of information - some parts vivid, other parts neglected or forgotten. Or maybe its because the juxtaposition of more loosely related information is analogous to the way we experience dreams.

Version 2.0

The first version of the software worked well, but it existed in a kind of limbo. It was a module of another project, and it also had a dependancy on the custom-made personal organiser app that housed my graphical morgue. The last time I had updated the organiser app, I had not updated the art module, so the latter had become unusable.

Fast-forward to present day, and I am missing my graphics-generation stooge. I wanted to have it back online, so I began evaluating what needed to be done.

I rehashed the software as a self-contained system. I pulled it out of its original location, cancelled out environmental function calls, tidied the code, added in some new bells and whistles, and even slapped on a little web UI.

Surfaced parameters

  • Term The string of text to be searched for
  • Generator The compositor to be used
  • Width The desired final image width
  • Height The desired final image height
  • Texts The texts that would seed the overlaid text chunks. Users may pick more than one.
  • Order images by fulltext relevance The implementation of the image search is a MySQL FULLTEXT query, running in boolean mode. When this box is checked, the query has a WHERE clause to ensure that it only returns images where the relevance quantifier is greater than 0.5, and an ORDER BY clause to order by the relevance quantifier. If this box is not checked, the query specifies a minimum relevance of 0.3, and the records are ordered randomly. The query will always be limited to 10 records.
  • Shuffle slice of 10 If true, the 10 records mentioned above will be given a random order. This is intended to give a small amount of randomness to the image selection, when the "Order images by fulltext relevance" checkbox is active.
  • Use thesaurus expansion for images Specifies if the users search term should be broadened with additional words derived from the thesaurus and related word lookup system, when finding images.
  • Use thesaurus expansion for text Specifies if the users search term should be broadened with additional words derived from the thesaurus and related word lookup system, when finding text passages.
  • Use boolean quantifiers If true, the boolean quantifier > is placed next to all parts of the original search term, signifying them as more important, and a < is placed next to all words derived from this term using the thesaurus, signifying them as less important.
  • Shuffle thesaurus words When thesaurus lookups are enabled, thesaurus words, and related words are compiled into a single list, and ordered according to relevance to the original search term. If this checkbox is active, the list order is randomised.

To give you a feel for the art software API, here is some controller code, showing its customisation and invocation:

Due to the large amount of cached images that the tool requires to function, and the processing power needed to generate images, its not currently practical to migrate the app to an online environment and host it there for the world and his dog to use and abuse.

Therefore, in leiu of this, and in closing, here are some more images, created with the updated software. This time, I present them along with the original query terms.

Final thought

In essence, creativity, or at least, the effect of creativity, is a conceptual region that lies somewhere in between order and chaos. It seems that there are two paths to this destination. The first is brooding sophistication, such as the kind that underpins human intelligence and machine learning algorithms. The second, which I have used here, is merely a cunning and gentle pursuasion of the forces of chance.

castle

comic

crying

dramatic

dramatic

funny

heavy metal

intense

moose

ninja

sublime

tiger

elephant

happy

industrial

jazz

mountain

water

travel

blood fire

sinister

courage

portal

Notes

All images - excluding the ones in the section immediately above, tagged with the terms comic, funny, ninja and blood-fire - were created with creative-commons imagery. Please feel free to use them in your blog articles, social media posts, and elsewhere. Back-links are appreciated.

Comments (0)

Replying to: Noname

Error

Utilising this page as a billboard for marketing purposes is not allowed. Any messages posted by users that appear to be commercial in nature will be deleted, and any user found breaching this term will have their IP address reported to ICANN. This may result in their networks appearing in worldwide electronic communication blacklists.