Task 051: image colour palette

Your task is to design the automatic calculation of a nice palette of colors, for example for web design. The color set must be based on an input raster image, from which several major colors should be extracted. The desired output is a palette of 3 to 10 colors. It is up to you how many colors you directly take from the picture, and how many you derive from it, for example by interpolating between shades you can find in the image. The main criterion is that the final colour palette is harmonic, not that all colours in the palette can actually be found in the image. There should still be some relation to the source image, though - use this freedom creatively!

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.

Inspiration

There are pages online that showcase palette extraction, such as Adobe Color CC (which used to be called Adobe Kuler).

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: 5. 11. 2017

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: 2015-10-19 15:55:04 +0200 (Th, 22 Okt 2015)