VIZA 654 / CSCE 646 : Digital Image
Fall 2020

Project 04: Image Manipulations First Review: Oct. 05
Submissions Due: Oct. 12
 

Problem Description:

The goal of this project is to learn global manipulations and use them to create aestetic results. Most of these operations can be seen under Image/Adjustments in Photoshop such as "Curves, Posterize or Replace Color" operations or in filters. You will also learn how to use parametric functions.

Project Requirements:
The three tasks in this case are the following. Our goal is to implement something that you cannot create by using commercial software. In each case, provide start with a standard approach and create your own using an unconventional input such an image.

  1. Manipulate colors in an image using an interpolating curve. Curve parameters will be given as a list of numbers such as (r0,r1,r2,r3...,rn) which means a parametric curve that passes through from points (0,r0), (1/n,r1), (2/n,r2), (3/n,r3) and (1,rn). We suggest to start with piecewise-linear curve and extend to hermitian cubics later. If you finish piecewise-linear, you will get full credit.
  2. Replace Hues in an image taking hues from another image. For the information about how to compute hues, see below.
Bonus: An curve interface can give you bonus points up to half of the project credit.

For the required parts of the project, implement your operations only using the basic programming operations such as while or for loops and basic mathematical operations such as addition, subtraction, multiplication, division and power. In other words, no high level operation provided by some programming languages such as HSV to RGB conversion is allowed.


Project Submission:

Please write the program in either Processing or Java or C or C++. For C and C++ use OpenGL and GLUTgraphics routines for the display. Upload your program and all essential files to webassign as a "as small as possible" zip directory. In your program, include comments about the program and your name. Also make sure to provide information that and instructions on how to run it.


Code to convert RGB colors to HSV colors  (taken from Foley, Van Dam, Feiner and Hughes, pg. 592)

/*
  Input RGB color primary values: r, g, and b on scale 0 - 255
  Output HSV colors: h on scale 0-360, s and v on scale 0-1
*/

#define maximum(x, y, z) ((x) > (y)? ((x) > (z)? (x) : (z)) : ((y) > (z)? (y) : (z)))
#define minimum(x, y, z) ((x) < (y)? ((x) < (z)? (x) : (z)) : ((y) < (z)? (y) : (z)))

void RGBtoHSV(int r, int g, int b, double &h, double &s, double &v){

  double red, green, blue;
  double max, min, delta;

  red = r / 255.0; green = g / 255.0; blue = b / 255.0;  /* r, g, b to 0 - 1 scale */

  max = maximum(red, green, blue);
  min = minimum(red, green, blue);

  v = max;        /* value is maximum of r, g, b */

  if(max == 0){    /* saturation and hue 0 if value is 0 */
    s = 0;
    h = 0;
  }
  else{
    s = (max - min) / max;           /* saturation is color purity on scale 0 - 1 */

    delta = max - min;
       if(delta == 0)                    /* hue doesn't matter if saturation is 0 */
      h = 0;
    else{
      if(red == max)                  /* otherwise, determine hue on scale 0 - 360 */
        h = (green - blue) / delta;
      else if(green == max)
        h = 2.0 + (blue - red) / delta;
      else /* (blue == max) */
        h = 4.0 + (red - green) / delta;
      h = h * 60.0;
      if(h < 0)
        h = h + 360.0;
    }
  }
}