Examples for Project 1

Grey

Image* greyImage(Image* theImage);
Converts theImage from color to grey scale. The luminance of the color pixel (r,g,b) is 0.3 * r + 0.59 * g + 0.11 * b.

Original

Grey

Extract Channel

void extractImageChannel(Image* theImage);
Extract a channel, as specified by the user, of theImage.  Leaves the specified channel intact.  Sets all other to zero.

Original

Red

Green

Blue

Brightness

void brightenImage(Image* theImage);
Changes the brightness of theImage by interpolating between a black image (factor = 0.0) and the original image (factor = 1.0). Interpolation darkens the image, and extrapolation brightens it.  See Graphica Obscura.

0.0

0.5

1.0

1.5

2.0

Negative

void negativeImage(Image* theImage);
Convert to "negative" by subtracting theImage from the all white image.

Original

"Negative"

Contrast

void contrastImage(Image* theImage);
Changes the contrast of theImage by interpolating between a constant grey image (factor = 0) and theImage (factor = 1). The user specifies the factor. The grey value used is the average luminance of theImage. Interpolation reduces contrast, extrapolation boosts contrast, and negative factors generate inverted images. See Graphica Obscura.

-0.5

0.0

0.5

1.0

1.7

Saturation

void saturateImage(Image* theImage);
Changes the saturation of theImage by interpolating between a grey level version of theImage (factor = 0) and theImage (factor = 1). The user specifies the factor. Interpolation decreases saturation, extrapolation increases it, and negative factors preserve luminance but invert the hue of the input image. See Graphica Obscura.

-1.0

0.0

0.5

1.0

2.5

Crop

Image* cropImage(Image* theImage);
Extract a sub-image from theImage given the coordinates of the lower left and upper right corners of the sub-image. The user specifies the coordinates of the sub-image.


(0,0) (96,128)


(30,30) (96,96)

Quantization by Rounding

Image* quantizeImage(Image* theImage);
Convert theImage to n bits per channel, as specified by the user, using uniform quantization.

The new number of levels per channel is L = 2n. The size of each input interval is a = L' / L, where L' is the old number of levels per channel. Each component c is mapped to floor(c / a). All the pixels within the same input interval are mapped to the same output level. Notice the contours that appear when nbits is low.


1

2

3

4

8

Quantization with Ordered Dither

Image* orderedDitherImage(Image* theImage);
Converts theImage to nbits bits per channel, as specified by the user, using ordered dithering. It is similar to uniform quantization, but pseudo-random noise is added to each component before quantization. The amount of noise added is determined by a Bayer's pattern matrix. The following examples used the matrix
Bayer2 = 3 1
0 2
For each pixel at (x,y), we compute i = x % 2, j = y % 2. Then, using a as defined for quantization, a component c is mapped to floor(c / a - 0.5 + Bayer2[i][j] / 3.0).

1

2

3

4

5

Quantization with Floyd-Steinberg Dither

Image* fsDither(Image* theImage);
Converts theImage to nbits per channel, as specified by the user, using Floyd-Steinberg dither with error diffusion. Each pixel (x,y) is quantized, and the quantization error is computed. Then the error is diffused to the neighboring pixels (x + 1, y), (x - 1, y - 1), (x, y 1 1), and (x + 1, y 1 1) , with weights 7/16, 3/16, 5/16, and 1/16, respectively.

1

2

3

4

5

Block Blur

void blockBlurImage(Image* theImage);
Blurs an image by convolving it with a n x n block filter; i.e. the filter in which each entry is 1/(n*n). The user specifies n, which must be odd.

n=1

n=3

n=7

n=15

Triangle Blur

void triangleBlurImage(Image* theImage);
Blurs an image by convolving it with a n x n triangle filter. The (i,j) entry in the triangle filter is tri(i,n) * tri(j,n)/M, where tri(k,n) = min(k,n-1-k)+1 and M is the normalization constant. The user specifies n, which must be odd.

n=1

n=3

n=7

n=15

Gaussian Blur

void gaussianBlurImage(Image* theImage);
Blurs theImage by convolving it with a n x n gaussian filter. The (i,j) entry in the gaussian filter is
2-((i*i + j*j)/sigma*sigma)/M
where M is the normalization constant. The user specifies n and sigma. In the examples below sigma=1.

n=1

n=3

n=7

n=15

Edge detect

void edgeDetect(Image* theImage);
Detect edges in theImage by convolving it with the edge detection kernel:
-1
-1
-1
-1
8
-1
-1
-1
-1

Original

Edges

Scale

Image* scaleImage(theImage);
Scales an image in x by sx, and y by sy. The result depends on the sampling method (point, bilinear, or Gaussian), which is chosen by the user. In the example below, the size of the Gaussian filter is 3x3.
scale1.jpg (26874 bytes)
Point
scale2.jpg (29226 bytes)
Bilinear
scale3.jpg (27586 bytes)
Gaussian
If minifying, instead of magnifying, first blur the image, then point sample. The size of the blur filter is the inverse of the minification factor, rounded up to the closest odd number greater than or equal to 3.

Rotate

void rotateImage(Image* theImage);
Rotates theImage by a user specified angle. The result depends on the current sampling method (point, bilinear, or Gaussian), which is chosen by the user. In the example below, the size of the Gaussian filter is 3x3.
rotate1.jpg (13595 bytes)
Point
rotate2.jpg (13842 bytes)
Bilinear
rotate3.jpg (13617 bytes)
Gaussian

Composite

void compositeImage(Image* theImage);
Composites theImage with a second image using a mask. The user specifies the input files for the second image and mask. .

Original Images

 

Fun

void Image::Warp(Image* theImage);
Warps an image using a creative filter of your choice. The user specifies the sampling method (point, bilinear, or gaussian.)
selecao.jpg (145753 bytes)
funk.jpg (8490 bytes)
Original
fun1.jpg (6775 bytes)
Point
fun2.jpg (10878 bytes)
Bilinear
fun3.jpg (10541 bytes)
Gaussian

Morph

Image** morphImage();
Morph two images using [Beier92]. 
 

before

after

 Quicktime (1.8mb)
 Windows AVI (4.2mb)