Graphics Image Processing Graphics Lab Korea University Overview
Graphics Image Processing 고려대학교 컴퓨터 그래픽스 연구실 Graphics Lab @ Korea University
Overview n Image Representation n n KUCG What is an image? Sampling and Reconstruction n Key steps in image processing Graphics Lab @ Korea University
What is an Image? n KUCG An image is a 2 D rectilinear array of pixels Continuous image Digital image Graphics Lab @ Korea University
What is an Image? n KUCG An image is a 2 D rectilinear array of pixels Continuous image Digital image Graphics Lab @ Korea University
What is an Image? n KUCG An image is a 2 D rectilinear array of pixels Continuous image Digital image A pixel is a sample, not a little square!! Graphics Lab @ Korea University
Image Acquisition n KUCG Pixels are samples from continuous function Photoreceptors in eye n CCD cells in digital camera n Rays in virtual camera n Graphics Lab @ Korea University
Quantization n KUCG Artifact due to limited intensity resolution Frame buffers have limited number of bits per pixel n Physical devices have limited dynamic range n 255 150 255 255 150 150 75 750 255 150 75 750 255 150 75 750 0 0 Blue channel Green channel Red channel Graphics Lab @ Korea University
Image Display n KUCG Re-create continuous function from samples n Example: cathode ray tube Image is reconstructed by displaying pixels with finite area (Gaussian) Graphics Lab @ Korea University
Image Resolution n Intensity resolution n n Each pixel has only “Depth” bits for colors/intensities Spatial resolution n n KUCG Image has only “Width” x “Height” pixels Temporal resolution n Monitor refreshes images at only “Rate” Hz Graphics Lab @ Korea University
Overview n Image Representation n n KUCG What is an image? Sampling and Reconstruction n Key steps in image processing Graphics Lab @ Korea University
Sampling and Reconstruction KUCG Sampling Reconstruction Graphics Lab @ Korea University
Sampling and Reconstruction KUCG Graphics Lab @ Korea University
Image Processing § Pixel operations KUCG n Filtering Blur n Detect edge n Add luminance n Add contrast n n Warping Scale n Rotate n Warps n Graphics Lab @ Korea University
Adjusting Brightness n KUCG Simply scale pixel components n Must clamp to range (e. g. , 0 to 255) Original Brighter Graphics Lab @ Korea University
Adjusting Contrast n Compute mean luminance L for all pixels n n KUCG Luminance = 0. 30*r + 0. 59*g + 0. 11*b Scale deviation from L for each pixel component n Must clamp to range (e. g. 0 to 255) L Original More contrast Graphics Lab @ Korea University
Image Processing § Pixel operations KUCG n Filtering Blur n Detect edge n Add luminance n Add contrast n n Warping Scale n Rotate n Warps n Graphics Lab @ Korea University
Adjusting Blurriness n KUCG Convolve with a filter whose entries sum to one n Each pixel becomes a weighted average of its neighbors Original Blur Graphics Lab @ Korea University
Edge Detection n KUCG Convolve with a filter that finds differences between neighbor pixels Original Edge Detection Graphics Lab @ Korea University
Image Processing § Pixel operations KUCG n Filtering Blur n Detect edge n Add luminance n Add contrast n n Warping Scale n Rotate n Warps n Graphics Lab @ Korea University
Image Warping n KUCG Move pixels of image Mapping n Resampling n Warp Source Image Destination Image Graphics Lab @ Korea University
Overview n KUCG Mapping Forward n Reverse n n Resampling Point sampling n Triangle filter n Gaussian filter n Graphics Lab @ Korea University
Mapping n KUCG Define transformation n Describe the destination (x, y) for every location (u, v) in the source (or vice-versa, if invertible) v y u x Graphics Lab @ Korea University
Example Mappings n KUCG Scale by factor : x = factor * u n y = factor * v n v y Scale 0. 8 u x Graphics Lab @ Korea University
Example Mappings n KUCG Rotate by θ degrees: x = u cos θ – v sin θ n y = u sin θ + v cos θ n y v Rotate 30 u x Graphics Lab @ Korea University
Example Mappings n Shear in X by factor : x = u + factor * v ny=v n n KUCG v Shear X 1. 3 Shear in Y by factor : x=u n y = v + factor * u n y u x v y Shear Y 1. 3 u x Graphics Lab @ Korea University
Other Mappings n KUCG Any function of u and v : x = fx(u, v) n y = fy(u, v) n Fish-eye Swirl Rain Graphics Lab @ Korea University
Image Warping Implementation I n KUCG 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); } } (u, v) Source Image f (x, y) Destination Image Graphics Lab @ Korea University
Forwarding Mapping n KUCG Iterate over source image y v Rotate -30 u x Graphics Lab @ Korea University
Forwarding Mapping – NOT n KUCG Iterate over source image Many source pixels can map to same destination pixel y v Rotate -30 u x Graphics Lab @ Korea University
Forwarding Mapping – NOT n Iterate over source image Many source pixels can map to same destination pixel KUCG Some destination pixels may not be covered y v Rotate -30 u x Graphics Lab @ Korea University
Image Warping Implementation II n KUCG Reverse mapping for(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); } } (u, v) Source Image f (x, y) Destination Image Graphics Lab @ Korea University
Reverse Mapping n KUCG Iterate over destination image Must resample source n May oversample, but much simpler! n y v Rotate -30 u x Graphics Lab @ Korea University
Resampling n KUCG Evaluate source image at arbitrary (u, v) does not usually have integer coordinates (u, v) Source Image (x, y) Destination Image Graphics Lab @ Korea University
Overview n KUCG Mapping Forward n Reverse n n Resampling Point sampling n Triangle filter n Gaussian filter n Graphics Lab @ Korea University
Point Sampling n KUCG Take value at closest pixel n int 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 y v Rotate -30 Scale 0. 5 u x Graphics Lab @ Korea University
Triangle Filtering n KUCG Convolve with triangle filter Input Output Graphics Lab @ Korea University
Triangle Filtering n KUCG Bilinearly interpolate four closest pixels a = linear interpolation of src(u 1, v 2) and src(u 2, v 2) n b = linear interpolation of src(u 1, v 1) and src(u 2, v 1) n dst(x, y) = linear interpolation of “a” and “b” n a (u 1, v 2) (u 2, v 2) (u, v) (u 1, v 1) (u 2, v 1) b Graphics Lab @ Korea University
Gaussian Filtering n KUCG Convolve with Gaussian filter Input Output Width of Gaussian kernel affects bluriness Graphics Lab @ Korea University
Gaussian Filtering n KUCG Compute weighted sum of pixel neighborhood : n Weights are normalized values of Gaussian function (u, v) Graphics Lab @ Korea University
Filtering Methods Comparison n KUCG Trade-offs Aliasing versus blurring n Computation speed n Point Bilinear Gaussian Graphics Lab @ Korea University
Image Warping Implementation III n KUCG Reverse mapping for(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); } } (u, v) Source Image f (x, y) Destination Image Graphics Lab @ Korea University
Image Warping Implementation III n KUCG Reverse mapping for(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); } } (u, v) f (x, y) w Source Image Destination Image Graphics Lab @ Korea University
Example: Scale n KUCG 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); } v y } (u, v) Scale 0. 5 (x, y) u x Graphics Lab @ Korea University
Example: Rotate n KUCG 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); } y v } (x, y) (u, v) Rotate 30 u x Graphics Lab @ Korea University
Example: Fun n KUCG 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); } v } (u, v) y (x, y) Swirl 45 u x Graphics Lab @ Korea University
- Slides: 45