<--begin container-->

Homework 4

1. Create a poster based on interpreting an image.

Beautiful People

Beautiful People

Source

//cycle through all the images and set the histogram values
	int numPictures = myPictures.size();
	for (int pics = 0; pics < numPictures; pics++) {
		unsigned char * pixels = myPictures[pics].getPixels();
		for (int i = 0; i < width; i++) {
			for (int j = 0; j < height; j++) {
				int pixelValue = pixels[j * width + i];
				histogramValues[pics][pixelValue]++;
				total[pics] += pixelValue;
			}
		}
	}
	
	//calculate average value for each image
	for (int pics = 0; pics < numPictures; pics++) {
		average[pics] = total[pics]/(width * height);
		xpos[pics] = ofMap(average[pics], 0, 255, 0, 1200);
		ypos[pics] = ofRandom((ofGetHeight())-(pics), ofGetHeight());
		if (average[pics] <= 10) {
			lineSize[pics] = 10;
		} else {
			lineSize[pics] = average[pics];
		}
	}
	
	//store x and y positions for elements for each image
	for (int pics = 0; pics < numPictures; pics++) {
		for (int i = 0; i < 256; i++) {
			radius = histogramValues[pics][i]/lineSize[pics];
			//save the x and ys for the lines
			px[pics][i] = xpos[pics] + cos(angle)*(radius/2);
			py[pics][i] = ypos[pics] + sin(angle)*(radius/2);
			//sine curve
			angle -= i;
		}
	}

Analysis of Mariyln Manson's "Beautiful People" music video. Histrogram values for all frames in the video are used to created the 'elements', each element arranged in a circular fashion. The size and x position of the element is dictated by the average brightness of darkness of that frame. Click on the image for a larger view.

2. Gaussian blur and median filtering on a noisy image

Gaussian blur and Median filter

Source

for (int i = 0; i < width; i++){
		for (int j = 0; j < height; j++){
			
			int pixIndex = j * width + i;
			
			int i_m_1 = MAX(0, i-1);
			int i_p_1 = MIN(width-1, i+1);
			int j_m_1 = MAX(0, j-1);
			int j_p_1 = MIN(height-1, j+1);
			
			int ne = (j_m_1 * width + i_m_1);
			int n_ = (j_m_1 * width + i    );
			int nw = (j_m_1 * width + i_p_1);
			int _e = (j     * width + i_m_1);
			int me = (j     * width + i    );
			int _w = (j     * width + i_p_1);
			int se = (j_p_1 * width + i_m_1);
			int s_ = (j_p_1 * width + i    );
			int sw = (j_p_1 * width + i_p_1);
			
			//place the values in the array
			sortArray[0] = pixelsMedian1[ne];
			sortArray[1] = pixelsMedian1[n_];
			sortArray[2] = pixelsMedian1[nw];
			sortArray[3] = pixelsMedian1[_e];
			sortArray[4] = pixelsMedian1[me];
			sortArray[5] = pixelsMedian1[_w];
			sortArray[6] = pixelsMedian1[se];
			sortArray[7] = pixelsMedian1[s_];
			sortArray[8] = pixelsMedian1[sw];
			
			qsort(sortArray, 9, sizeof(int), compare);
			
			int newValue = sortArray[4];
			
			if (newValue < 0) newValue = 0;
			if (newValue > 255) newValue = 255;
			
			pixelsMedian1[pixIndex]  = newValue;
		}
	}
	
	texture3.loadData(pixelsMedian1, width, height, GL_LUMINANCE);

The column in the middle is the image with gaussian blur and the right column is the image with median filter - top amount = 2 and bottom amount = 4. The gaussian blur seems to be better at removing points of noise although I like the effect the median filter creates. Click on the image for a larger view.