Computer Graphics Exercise 1 Halftoning and Color Transfer Due date:
Part 1 Halftoning
General Description The purpose of this part of the exercise is to generate half tone images with two techniques: i.Ordered Dithering. i.Ordered Dithering. ii.Error Distribution. ii.Error Distribution.
Original Image
Ordered Dithering
Error Diffusion Propagate the error to the Four surrounding neighbours
Program Usage The program should be named “ halftoning.exe ”. The programs gets from the command line TWO parameters: 1. Option –d or –e 2. Input filename
Program Usage The program generates one output image dither_ ( -d option) dither_ ( -d option) errdiff_ ( -e option) errdiff_ ( -e option)
Part 2 Color Transfer
General Description The purpose of this part is to implement a simple algorithm that transfers the colors of one image onto another image.
Example Colors Result:
The algorithm You will find an affine mapping (Matrix + translation) between the color spaces of the two images. For every pixel i of the first image, you take its color p i = (r i, g i, b i ), and apply the mapping M. You obtain the new color for pixel i :
In detail R B G R B G How to find a good mapping?
Mapping by PCA R B G R B G Find the axes by PCA Compute the oriented bounding boxes Define M as the affine mapping between those boxes!
Program Usage The program should be named “ ColorTransfer.exe ”. The programs gets from the command line TWO parameters: 1. First input filename (the one to map the colors onto) 2. Second input filename (the one to take the colors from)
Program Usage The program generates one output image res_ res_
General Guidelines
Important Remarks You should write the programs in C or C++. Document your program thoroughly. In this assignment there is no need to open a window or use OpenGL in any way.
Important Remarks The work can be done in pairs. Submit your work on diskettes (or CD’s). Hardcopy of the documentation. Points will be rewarded for nice and original images.
More Important Remarks Don't forget to check the number of parameters that your program receives. Don't forget to check memory allocations, if they succeeded or failed. Pay attention to the difference between bytes, int’s and float’s (Rounding error). Pay attention to the borders of the image.
A Little Help IrfanView – An image viewer, editor. FreeImage – A open source library for working with images. NewMat10 – matrix and linear algebra library See the links on the exercise webpage