View
3
Download
0
Category
Preview:
Citation preview
Graphics
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Image Processing
고려대학교 컴퓨터 그래픽스 연구실
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Overview
Image RepresentationWhat is an image?
Sampling and ReconstructionKey steps in image processing
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
What is an Image?
An image is a 2D rectilinear array of pixels
Continuous image Digital image
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
What is an Image?
An image is a 2D rectilinear array of pixels
Continuous image Digital image
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
What is an Image?
An image is a 2D rectilinear array of pixels
Continuous image Digital image
A pixel is a sample, not a little square!!
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Image Acquisition
Pixels are samples from continuous functionPhotoreceptors in eyeCCD cells in digital cameraRays in virtual camera
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Quantization
Artifact due to limited intensity resolutionFrame buffers have limited number of bits per pixelPhysical devices have limited dynamic range
255 150 75 0
255 150 75 0
255 150 75 0
255 150 75 0
255 150 75 0
255 150 75 0
255 150 75 0
255 150 75 0
255 150 75 0
255 150 75 0
255 150 75 0
255 150 75 0
255 150 75 0
255 150 75 0
255 150 75 0
Blue channel
Green channel
Red channel
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Image Display
Re-create continuous function from samplesExample: cathode ray tube
Image is reconstructed by displaying pixels with finite area (Gaussian)
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Image Resolution
Intensity resolutionEach pixel has only “Depth” bits for colors/intensities
Spatial resolutionImage has only “Width” x “Height” pixels
Temporal resolutionMonitor refreshes images at only “Rate” Hz
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Overview
Image RepresentationWhat is an image?
Sampling and ReconstructionKey steps in image processing
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Sampling and Reconstruction
Sampling
Reconstruction
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Sampling and Reconstruction
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Image Processing
Pixel operationsAdd luminanceAdd contrast
FilteringBlurDetect edge
WarpingScaleRotateWarps
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Adjusting Brightness
Simply scale pixel componentsMust clamp to range (e.g., 0 to 255)
Original Brighter
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Adjusting Contrast
Compute mean luminance L for all pixelsLuminance = 0.30*r + 0.59*g + 0.11*b
Scale deviation from L for each pixel componentMust clamp to range (e.g. 0 to 255)
Original Contrast
L
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Image Processing
Pixel operationsAdd luminanceAdd contrast
FilteringBlurDetect edge
WarpingScaleRotateWarps
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Adjusting Blurriness
Convolve with a filter whose entries sum to oneEach pixel becomes a weighted average of its neighbors
Original Blur
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
=
161
162
161
162
164
162
161
162
161
Filter
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Edge Detection
Convolve with a filter that finds differences between neighbor pixels
Original Edge Detection
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−−−−−−−−
=111181111
Filter
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Image Processing
Pixel operationsAdd luminanceAdd contrast
FilteringBlurDetect edge
WarpingScaleRotateWarps
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Image Warping
Move pixels of imageMappingResampling
Warp
Source Image Destination Image
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Overview
MappingForwardReverse
ResamplingPoint samplingTriangle filterGaussian filter
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Mapping
Define transformationDescribe the destination (x, y) for every location (u, v) in the source (or vice-versa, if invertible)
u
v
x
y
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Example Mappings
Scale by factor :x = factor * uy = factor * v
Scale0.8
u
v
x
y
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Example Mappings
Rotate by θ degrees:x = u cos θ – v sin θy = u sin θ + v cos θ
u
v
Rotate30
x
y
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Example Mappings
Shear in X by factor :x = u + factor * vy = v
Shear in Y by factor :x = uy = v + factor * u
Shear X1.3
u
v
x
y
Shear Y1.3
u
v
x
y
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Other Mappings
Any function of u and v :x = fx(u, v)y = fy(u, v)
Fish-eye Swirl Rain
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Image Warping Implementation I
Forward mapping :for(int u=0; u<umax; u++) {
for(int v=0; v<vmax; v++) {float x = fx(u,v);float y = fy(u,v);dst(x,y) = src(u,v);
}}
Source Image Destination Image
(u, v)(x, y)f
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Forwarding Mapping
Iterate over source image
Rotate-30
u
v
x
y
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Forwarding Mapping – NOT
Iterate over source image
Rotate-30
u
v
x
y
Many source pixels can map to same destination pixel
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Forwarding Mapping – NOT
Iterate over source image
Rotate-30
u
v
x
y
Many source pixels can map to same destination pixel
Some destination pixels may not be covered
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Image Warping Implementation II
Reverse mappingfor(int x=0; x<xmax; x++) {
for(int y=0; y<ymax; y++) {float u = fx
-1(x,y);float v = fy
-1(x,y);dst(x,y) = src(u,v);
}}
Source Image Destination Image
(u, v)(x, y)f
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Reverse Mapping
Iterate over destination imageMust resample sourceMay oversample, but much simpler!
Rotate-30
u
v
x
y
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Resampling
Evaluate source image at arbitrary (u, v)
(u, v) does not usually have integer coordinates
Source Image Destination Image
(u, v)(x, y)
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Overview
MappingForwardReverse
ResamplingPoint samplingTriangle filterGaussian filter
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Point Sampling
Take value at closest pixelint iu = trunc(u+0.5);int iv = trunc(v+0.5);dst(x, y) = src(iu, iv);
This method is simple, but it causes aliasing
Rotate-30
Scale0.5
u
v
x
y
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Triangle Filtering
Convolve with triangle filter
Input Output
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Triangle Filtering
Bilinearly interpolate four closest pixelsa = linear interpolation of src(u1, v2) and src(u2, v2)b = linear interpolation of src(u1, v1) and src(u2, v1)dst(x, y) = linear interpolation of “a” and “b”
(u1, v2)
(u1, v1)
(u2, v2)
(u2, v1)
a
b
(u, v)
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Gaussian Filtering
Convolve with Gaussian filter
Width of Gaussian kernel affects bluriness
Input Output
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Gaussian Filtering
Compute weighted sum of pixel neighborhood :Weights are normalized values of Gaussian function
(u, v)
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Filtering Methods Comparison
Trade-offsAliasing versus blurringComputation speed
Point Bilinear Gaussian
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Image Warping Implementation III
Reverse mappingfor(int x=0; x<xmax; x++) {
for(int y=0; y<ymax; y++) {float u = fx
-1(x,y);float v = fy
-1(x,y);dst(x,y) = resample_src(u,v,w);
}}
Source Image Destination Image
(u, v)(x, y)f
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Image Warping Implementation III
Reverse mappingfor(int x=0; x<xmax; x++) {
for(int y=0; y<ymax; y++) {float u = fx
-1(x,y);float v = fy
-1(x,y);dst(x,y) = resample_src(u,v,w);
}}
Source Image Destination Image
(u, v)(x, y)f
w
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Example: Scale
Scale (src, dst, sx, sy) :float w ≈ max(1/sx, 1/sy)for(int x=0; x<xmax; x++) {
for(int y=0; y<ymax; y++) {float u = x/sx ;float v = y/sy;dst(x,y) = resample_src(u,v,w);
}}
Scale0.5
u
v
x
y
(u, v)
(x, y)
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Example: Rotate
Rotate (src, dst, theta)for(int x=0; x<xmax; x++) {
for(int y=0; y<ymax; y++) {float u = x*cos(-θ)-y*sin(-θ)float v = x*sin(-θ)+y*cos(-θ)dst(x,y) = resample_src(u,v,w);
}}
u
v
Rotate30
x
y
(u, v) (x, y)
KUCG
Graphics Lab @ Korea Universitykucg.korea.ac.kr
Example: Fun
Swirl (src, dst, theta)for(int x=0; x<xmax; x++) {
for(int y=0; y<ymax; y++) {float u = rot(dist(x,xcenter)*θ)float v = rot(dist(y,ycenter)*θ)dst(x,y) = resample_src(u,v,w);
}}
u
v
Swirl45
x
y(u, v) (x, y)
Recommended