Fairey posters (posterizing)

Pages: 12
i need help in posterizing. the project is basically turning a picture into something similar to the obama hope poster. i finished the border and the hope lettering, but i am lost as far as how i'm supposed to change the color of the picture.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include <iostream>
#include "csufmedia.h"
#include <cmath>
using namespace std;

int main() 
{
  load_canvas("donuts.ppm");

  int x, y; 
  for (x = 0; x < canvas_width(); x++)  // loop through every x coordinate
  {
    for (y = 0; y < canvas_height(); y++)  // and through every y coordinate
	{

      // get the red, green, and blue intensities for the pixel at
      // coordinate (x, y)
      double r = get_red(x, y),
	g = get_green(x, y),
	b = get_blue(x, y);

      // compute new RGB intensities
      double new_r = 1 - r, // Inversion. You will need different code here
	new_g = 1 - g,      // to do posterization.
	new_b = 1 - b;

	 
      // Update the color of the pixel in the canvas.
      set_pixel(x, y, new_r, new_g, new_b);
    }
  }

   
  // border
 rectangle(0, 0,   // left side
	    10, 1024,       // width: 10 pixels, height: 1024 pixels
	    .99, .89, .65); // beige

 rectangle(802, 0,   // right side
	    10, 1024,       // width: 10 pixels, height: 1024 pixels
	    .99, .89, .65); // beige

 rectangle(0, 0,   // top
	    812, 10,       // width: 812 pixels, height: 10 pixels
	    .99, .89, .65); // beige

 rectangle(0, 1014,   // bottom
	    812, 10,       // width: 812 pixels, height: 10 pixels
	    .99, .89, .65); // beige

 //rectangle
 rectangle(10, 914,   // bottom
	    792, 100,       // width: 792 pixels, height: 100 pixels
	    0, .19, .30); // navy

 // H in hope
 rectangle(327, 924,   // right leg
	    10, 80,       // width: 10 pixels, height: 80 pixels
	    .44, .59, .62); // light blue

 rectangle(287, 959,   // middle
	    40, 10,       // width: 40 pixels, height: 10 pixels
	    .44, .59, .62); // light blue

 rectangle(277, 924,   // left leg
	    10, 80,       // width: 10 pixels, height: 80 pixels
	    .44, .59, .62); // light blue

  // O in hope
  vertical_semicircle(387, 924,   // right side
		      30,       // inner radius: 30 pixels
		      40,       // outer radius: 40 pixels
		      true,     // make it leftward
		      .44, .59, .62); // light blue

   vertical_semicircle(347, 924,   // left side
		      30,       // inner radius: 30 pixels
		      40,       // outer radius: 40 pixels
		      false,     // make it rightward not leftward
		      .44, .59, .62); // light blue

   // P
   rectangle(437, 924,   // leg
	    10, 80,       // width: 10 pixels, height: 80 pixels
	    .44, .59, .62); // light blue

   vertical_semicircle(447, 924,   // half circle of P
		      20,       // inner radius: 20 pixels
		      30,       // outer radius: 30 pixels
		      true,     // make it rightward not leftward
		      .44, .59, .62); // light blue

   // E
   rectangle(487, 924,   // leg
	    10, 80,       // width: 10 pixels, height: 80 pixels
	    .44, .59, .62); // light blue

   rectangle(497, 959,   // top
	    30, 10,       // width:30 pixels, height: 10 pixels
	    .44, .59, .62); // light blue

   rectangle(497, 924,   // middle
	    30, 10,       // width: 30 pixels, height: 10 pixels
	    .44, .59, .62); // light blue

   rectangle(497, 994,   // bottom
	    30, 10,       // width: 30 pixels, height: 10 pixels
	    .44, .59, .62); // light blue

  save_canvas("donuts2.ppm");

  return 0;
}


that's what i have so far.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 int x, y; 
  for (x = 0; x < canvas_width(); x++)  // loop through every x coordinate
  {
    for (y = 0; y < canvas_height(); y++)  // and through every y coordinate
	{

      // get the red, green, and blue intensities for the pixel at
      // coordinate (x, y)
      double r = get_red(x, y),
	g = get_green(x, y),
	b = get_blue(x, y);

      // compute new RGB intensities
      double new_r = 1 - r, // Inversion. You will need different code here
	new_g = 1 - g,      // to do posterization.
	new_b = 1 - b;

	 
      // Update the color of the pixel in the canvas.
      set_pixel(x, y, new_r, new_g, new_b);
    }
  }


was given by the professor and we have to change it around to posterize the picture, that's where i'm stuck...
Hey Im in your class, and I was wondering if the dimensions have to be changed for every picture?
cpscnewb stop changing to different ones mannn just tel me if you finished the posterization so ill show you how to do the rest if you show me the posterization
If i had the posterization code Id give it to you, lol
wowowowow i guess ill just do it then since nobody is helping
.
Last edited on
in the sample code he gave us he uses for loops (nested) so I think it will be easier to do it that way
the for loops are to count the pixels
wait so do we need to put anything between the nested for loops? the teacher put a { there
yea thats where you put the if statements, but before the if statements you put the values that you calculate
hmm somethings telling me i might have to use arrays because they are good at comparing the closest things... i think
or was this assigned before we learned about arrays?
.
Last edited on
ok i successfully ran the example code so ill see how far i can get by manipulating that
it compiiled, my only problem is it's not reading the donuts ppm, for some reason
ok thanks but i noticed that you didnt use else if when you had a bunch of ifs but i guess that doesnt matter
oh yeah i changed it right now to the last 3 ifs to be else if
actually i dont think it matters it ran perfectly thanks a lot man
im still going to try to figure it out bymyself though since i probably need to learn this
OH btw try to make sure that your code works for the elephant picture aswell, i dont think your letters are going to work for that
Pages: 12