Computer Graphics Computer Graphics Exercise 1 Exercise 1 Halftoning and Color Halftoning and Color Transfer Transfer Due date: 24.03.05 Due date: 24.03.05
Dec 20, 2015
Computer GraphicsComputer Graphics
Exercise 1Exercise 1
Halftoning and Color TransferHalftoning and Color Transfer
Due date: 24.03.05Due date: 24.03.05
General DescriptionGeneral Description
The purpose of this part of the exercise is The purpose of this part of the exercise is to generate half tone images with two to generate half tone images with two techniques:techniques:
i.i. Ordered Dithering. Ordered Dithering.
ii.ii. Error Distribution. Error Distribution.
Program UsageProgram Usage
The program should be named The program should be named ““halftoning.exehalftoning.exe”. ”.
The programs gets from the The programs gets from the command linecommand line TWOTWO parameters: parameters:
1.1. Option Option –d–d or or –e–e
2.2. Input filenameInput filename
Program UsageProgram Usage
The program generates one output imageThe program generates one output image• dither_<input_name>dither_<input_name> ( (-d-d option) option)• errdiff_<input_name>errdiff_<input_name> ( (-e-e option) option)
General DescriptionGeneral Description
The purpose of this part is to implement a The purpose of this part is to implement a simple algorithm that transfers the colors simple algorithm that transfers the colors of one image onto another image.of one image onto another image.
The algorithmThe algorithm
You will find an affine mapping (Matrix + You will find an affine mapping (Matrix + translation) between the translation) between the colorcolor spaces of the two spaces of the two images.images.
For every pixel For every pixel ii of the first image, you take its of the first image, you take its color color ppii = ( = (rrii, g, gii, b, bii)), and apply the mapping M. , and apply the mapping M.
You obtain the new color for pixel You obtain the new color for pixel ii::
( )M A p p t
( )i iM p p
Mapping by PCAMapping by PCA
R
B
G
R
B
G
Find the axes by PCAFind the axes by PCA Compute the oriented bounding boxesCompute the oriented bounding boxes Define Define MM as the affine mapping between those boxes! as the affine mapping between those boxes!
Program UsageProgram Usage
The program should be named The program should be named ““ColorTransfer.exeColorTransfer.exe”. ”.
The programs gets from the The programs gets from the command linecommand line TWOTWO parameters: parameters:
1.1. First input filename (the one to map the First input filename (the one to map the colors onto) colors onto)
2.2. Second input filename (the one to take Second input filename (the one to take the colors from)the colors from)
Program UsageProgram Usage
The program generates one output imageThe program generates one output image
res_<input_name_1>res_<input_name_1>
Important Remarks Important Remarks
You should write the programs in C or C+You should write the programs in C or C++. +.
Document your program thoroughly. Document your program thoroughly. In this assignment there is In this assignment there is nono need to need to
open a window or use OpenGL in any open a window or use OpenGL in any way. way.
Important RemarksImportant Remarks
The work can be done in pairs.The work can be done in pairs. Submit your work on diskettes (or CD’s). Submit your work on diskettes (or CD’s).
Hardcopy of the documentation.Hardcopy of the documentation. Points will be rewarded for nice and Points will be rewarded for nice and
original images.original images.
More Important RemarksMore Important Remarks
Don't forget to check the number of Don't forget to check the number of parameters that your program receives.parameters that your program receives.
Don't forget to check memory allocations, Don't forget to check memory allocations, if they succeeded or failed. if they succeeded or failed.
Pay attention to the difference between Pay attention to the difference between bytes, int’s and float’s (Rounding error).bytes, int’s and float’s (Rounding error).
Pay attention to the borders of the image.Pay attention to the borders of the image.
A Little HelpA Little Help
IrfanView – An image viewer, editor.IrfanView – An image viewer, editor. FreeImage – A open source library for FreeImage – A open source library for
working with images.working with images. NewMat10 – matrix and linear algebra NewMat10 – matrix and linear algebra
librarylibrary
See the links on the exercise webpageSee the links on the exercise webpage