Task 051: image colour palette

The task is to generate an algorithm which generates a colour palette from an image: and in particular, a colour palette that is somehow representative for the image in question. The inspiration for this is the Twitter account CINEMA PALETTES, which was also discussed in an article in My Modern Met. Input is any raster image, for example a still frame from a movie you like. Your algorithm should analyse the image, and return 3-10 characteristic colours.

Overview

The template application 051colormap from the repository grcis serves as the basis of this project. This is a simple application in which it is possible to load an input image, and a resulting palette is then calculated. Within the application, the method Colormap.Generate() is responsible for calculating the palette. This method must be re-written, and the relevant location in the source Colormap.cs indicated via comment brackets:

  // !!!{{
  // !!!}}

Your code modifications do not have to be restricted to the area given by the brackets: if you want, you can also add helper data structures, and the like. The only restriction is that all changes you make to the framework must be in the subset of files that are to be submitted as solution (see below).

Screenshot

Technical details

The input image is passed to your method via the Bitmap input parameter, from which you can read data via BitMap.GetPixel(x,y) (details can be found here: Bitmap). The prototype already does this, to make it easier for you. The number of colours that should be output can be found in numCol (but you do not have to use this parameter, though - you can work with fixed palette lengths, or make this dependent on the image).
The output palette is written into the array colors, which you have to initialise to the correct size before using it, like so: colors = new Color[ 4 ]; for e.g. four colours.

Please hand in only the modified file Colormap.cs! DO NOT send us the entire Visual Studio project! If you have an input image for which your program generates particularly nice or interesting results, you can also attach it to the mail - but please keep the file size small!

Performance considerations

For a palette analysis, smaller input images of 600x400 pixels (or so) are usually sufficient. Restricting yourself to smaller input images is particularly important if you work with more sophisticated palette identification algorithms.

Support

If you need functions for conversions between color spaces, or similar mathematical infrastructure: a place to look for such things is common/MathSupport.cs.

What to hand in

You have to send the file Colormap.cs via mail to the lecturer.
In the first line, put your name in a comment.

Deadline

Hand in the assignment until: 8. 11. 2016

Points

Basic: 9 points, plus a possible bonus for really creative solutions.

Project

Visual Studio project: 051colormap.

Source file

Modify and hand in the source file: Colormap.cs
As a comment in the first line, please include your name!


Copyright (C) 2016 J. Pelikán & A. Wilkie, last change: 2019-05-09 17:52:59 +0200 (Thu, 09 May 2019)