Download presentation
Presentation is loading. Please wait.
Published byStanley Poole Modified over 6 years ago
1
Kyoungju Park kjpark@cau.ac.kr http://graphics.cau.ac.kr
Computer Graphics Kyoungju Park
3
Image Processing 2D generalization of signal processing
Image as a two-dimensional signal Point processing: modify pixels independently Filtering: modify based on neighborhood Compositing: combine several images Image compression: space-efficient formats Related topics (not in this lecture or this course) Image enhancement and restoration Computer vision
4
Outline Point Processing Filters Dithering Image Compositing
Image Compression
5
Point Processing f(v) = v identity; no change
f(v) = 1-v negate an image (black to white, white to black) f(v) = vp, p<1 brighten f(v) = vp, p>1 darken f(v) v Processing Examples -> Topics -> Image Processing->Brightness
6
PImage img; void setup() { size(200, 200); frameRate(30); img = loadImage("wires.jpg"); } void draw() { loadPixels(); for (int x = 0; x < img.width; x++) { for (int y = 0; y < img.height; y++ ) { int loc = x + y*img.width; float r = red (img.pixels[loc]); float maxdist = 50; float d = dist(x,y,mouseX,mouseY); float adjustbrightness = 255*(maxdist-d)/maxdist; r += adjustbrightness; color c = color(r); pixels[loc] = c; } updatePixels();
7
Convolution filters gaussian box tent
8
PImage img; int w = 80; float[][] matrix = { { -1, -1, -1 }, { -1, 9, -1 }, { -1, -1, -1 } }; void setup() { size(200, 200); frameRate(30); img = loadImage("end.jpg"); } void draw() { image(img,0,0); int matrixsize = 3; loadPixels(); for (int x = width/4; x < 3*width/4; x++) { for (int y = height/4; y < 3*height/4; y++ ) { color c = convolution(x,y,matrix,matrixsize,img); int loc = x + y*img.width; pixels[loc] = c; updatePixels();
9
color convolution(int x, int y, float[][] matrix,int matrixsize, PImage img)
{ float rtotal = 0.0; float gtotal = 0.0; float btotal = 0.0; int offset = matrixsize / 2; for (int i = 0; i < matrixsize; i++){ for (int j= 0; j < matrixsize; j++){ int loc = (x + i - offset) + img.width*(y + j - offset); rtotal += (red(img.pixels[loc]) * matrix[i][j]); gtotal += (green(img.pixels[loc]) * matrix[i][j]); btotal += (blue(img.pixels[loc]) * matrix[i][j]); } return color(rtotal,gtotal,btotal);
10
Blurring Filters A simple blurring effect can be achieved with a 3x3 filter centered around a pixel, More blurring is achieved with a wider nn filter: Original Image Blur 3x3 mask Blur 7x7 mask
11
Image Filtering: Blurring
original, 64x64 pixels 3x3 blur 5x5 blur
12
Blurring Filters Average values of surrounding pixels
Can be used for anti-aliasing What do we do at the edges and corners? For noise reduction, use median, not average Eliminates intensity spikes Non-linear filter Processing Examples -> Topics -> Image Processing->Blur
13
Example: Noise Reduction
Image with noise Median filter (5x5)
14
Example: Noise Reduction
Original image Image with noise Median filter (5x5)
15
Example of Edge Filter Original image Edge filter, then brightened
16
Image Filtering: Edge Detection
17
Dithering Dithering takes advantage of the human eye's tendency to "mix" two colors in close proximity to one another.
18
Dithering Dithering takes advantage of the human eye's tendency to "mix" two colors in close proximity to one another. original no dithering with dithering Colors = 224 Colors = 28 Colors = 28
19
Floyd-Steinberg Error Diffusion
20
Floyd-Steinberg Error Diffusion
Enhances edges Retains high frequency Some checkerboarding From
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.