Brightness and geometric transformations

Similar documents
Chapter 18. Geometric Operations

Broad field that includes low-level operations as well as complex high-level algorithms

Image preprocessing in spatial domain

Image preprocessing in spatial domain

EXAM SOLUTIONS. Image Processing and Computer Vision Course 2D1421 Monday, 13 th of March 2006,

Image segmentation. Václav Hlaváč. Czech Technical University in Prague

EE795: Computer Vision and Intelligent Systems

Sampling and Reconstruction

N-Views (1) Homographies and Projection

Intensity Transformations and Spatial Filtering

Motivation. Intensity Levels

Intensity Transformation and Spatial Filtering

Computer Graphics and Image Processing

INTRODUCTION TO IMAGE PROCESSING (COMPUTER VISION)

Digital Image Processing COSC 6380/4393

Chapter 3: Intensity Transformations and Spatial Filtering

Introduction to Digital Image Processing

Terrain correction. Backward geocoding. Terrain correction and ortho-rectification. Why geometric terrain correction? Rüdiger Gens

Lecture 4 Image Enhancement in Spatial Domain

IMAGE SEGMENTATION. Václav Hlaváč

Lecture 2 Image Processing and Filtering

UNIT - 5 IMAGE ENHANCEMENT IN SPATIAL DOMAIN

CS4670: Computer Vision

IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN

Computer Vision I - Basics of Image Processing Part 2

EE795: Computer Vision and Intelligent Systems

Image Enhancement. Digital Image Processing, Pratt Chapter 10 (pages ) Part 1: pixel-based operations

Lecture 4. Digital Image Enhancement. 1. Principle of image enhancement 2. Spatial domain transformation. Histogram processing

Edge and local feature detection - 2. Importance of edge detection in computer vision

CS4442/9542b Artificial Intelligence II prof. Olga Veksler

EEM 463 Introduction to Image Processing. Week 3: Intensity Transformations

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Computer Vision I. Announcements. Fourier Tansform. Efficient Implementation. Edge and Corner Detection. CSE252A Lecture 13.

Biometrics Technology: Image Processing & Pattern Recognition (by Dr. Dickson Tong)

Motivation. Gray Levels

Lecture 4: Spatial Domain Transformations

EECS 556 Image Processing W 09. Interpolation. Interpolation techniques B splines

CS4442/9542b Artificial Intelligence II prof. Olga Veksler

Image Processing: Final Exam November 10, :30 10:30

Anno accademico 2006/2007. Davide Migliore

Computer Vision I - Filtering and Feature detection

Babu Madhav Institute of Information Technology Years Integrated M.Sc.(IT)(Semester - 7)

Perspective Mappings. Contents

Mosaics. Today s Readings

Sampling, Aliasing, & Mipmaps

Geometric Rectification of Remote Sensing Images

Sampling, Aliasing, & Mipmaps

Digital Image Processing

Blacksburg, VA July 24 th 30 th, 2010 Georeferencing images and scanned maps Page 1. Georeference

Ulrik Söderström 16 Feb Image Processing. Segmentation

Vivekananda. Collegee of Engineering & Technology. Question and Answers on 10CS762 /10IS762 UNIT- 5 : IMAGE ENHANCEMENT.

CS6670: Computer Vision

Geometric Correction of Imagery

C E N T E R A T H O U S T O N S C H O O L of H E A L T H I N F O R M A T I O N S C I E N C E S. Image Operations II

Lecture 7: Most Common Edge Detectors

DIGITAL TERRAIN MODELLING. Endre Katona University of Szeged Department of Informatics

Training i Course Remote Sensing Basic Theory & Image Processing Methods September 2011

Announcements. Mosaics. How to do it? Image Mosaics

Motion. 1 Introduction. 2 Optical Flow. Sohaib A Khan. 2.1 Brightness Constancy Equation

Image Enhancement: To improve the quality of images

DD2423 Image Analysis and Computer Vision IMAGE FORMATION. Computational Vision and Active Perception School of Computer Science and Communication

Last update: May 4, Vision. CMSC 421: Chapter 24. CMSC 421: Chapter 24 1

Computer Graphics. Chapter 4 Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

Lecture #5. Point transformations (cont.) Histogram transformations. Intro to neighborhoods and spatial filtering

ME/CS 132: Introduction to Vision-based Robot Navigation! Low-level Image Processing" Larry Matthies"

Spatial Enhancement Definition

Computer Vision 2. SS 18 Dr. Benjamin Guthier Professur für Bildverarbeitung. Computer Vision 2 Dr. Benjamin Guthier

Lecture 6: Edge Detection

Feature descriptors and matching

Types of Edges. Why Edge Detection? Types of Edges. Edge Detection. Gradient. Edge Detection

Digital Image Processing, 3rd ed. Gonzalez & Woods

Sampling, Aliasing, & Mipmaps

Computer vision: models, learning and inference. Chapter 13 Image preprocessing and feature extraction

Image Acquisition + Histograms

CHAPTER 1 Introduction 1. CHAPTER 2 Images, Sampling and Frequency Domain Processing 37

Announcements. Image Matching! Source & Destination Images. Image Transformation 2/ 3/ 16. Compare a big image to a small image

EN1610 Image Understanding Lab # 3: Edges

Computer Vision I. Announcement. Corners. Edges. Numerical Derivatives f(x) Edge and Corner Detection. CSE252A Lecture 11

6.837 LECTURE 7. Lecture 7 Outline Fall '01. Lecture Fall '01

EECS490: Digital Image Processing. Lecture #17

Filtering Images. Contents

Sampling: Application to 2D Transformations

Introduction to Digital Image Processing

Image Enhancement 3-1

ENG 7854 / 9804 Industrial Machine Vision. Midterm Exam March 1, 2010.

Color Dithering with n-best Algorithm

Ulrik Söderström 17 Jan Image Processing. Introduction

Image Processing Fundamentals. Nicolas Vazquez Principal Software Engineer National Instruments

Higher Course Year /16

Video Mosaics for Virtual Environments, R. Szeliski. Review by: Christopher Rasmussen

Introduction to Computer Vision. Human Eye Sampling

Image and Multidimensional Signal Processing

Dietrich Paulus Joachim Hornegger. Pattern Recognition of Images and Speech in C++

morphology on binary images

Midterm Examination CS 534: Computational Photography

03 Vector Graphics. Multimedia Systems. 2D and 3D Graphics, Transformations

Matching. Compare region of image to region of image. Today, simplest kind of matching. Intensities similar.

Digital Image Processing Fundamentals

DD2429 Computational Photography :00-19:00

CHAPTER 3 IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN

Transcription:

Brightness and geometric transformations Václav Hlaváč Czech Technical University in Prague Czech Institute of Informatics, Robotics and Cybernetics 166 36 Prague 6, Jugoslávských partyzánů 1580/3, Czech Republic http://people.ciirc.cvut.cz/hlavac, vaclav.hlavac@cvut.cz also Center for Machine Perception, http://cmp.felk.cvut.cz Outline of the lecture: Brightness scale transformation. γ-correction. Histogram equalization. Pseudocolor. Brightness corrections. Geometric transformations. Interpolation of image function values.

Image preprocessing, the intro 2/37 The input is an image, the output is an image too. The image is not interpreted. The aim Contrast enhancement (which is useful only if the human looks at the image). To suppress the distortion (e.g., correction of the geometric distortion caused by spherical shape of the Earth taken from a satellite). Noise suppression. Enhancement of some image features needed for further image processing, e.g., edge finding.

Taxonomy of the image preprocessing methods 3/37 Taxonomy according to the neighborhood size of the current pixel. Neighborhood Example of the operation Actually processed neighborhood Brightness scale transform The same for all pixels Single pixel Brightness corrections The current pixel Geometric transforms A current pixel (theoretically), a small neighborhood (practically) Local Local filtration A small neighborhood Global Fourier transform The whole image Image restauration Point Local Global input input input output output output

Brightness histogram 4/37 The brightness histogram is the estimate of the probability distribution of the phenomenon that a pixel has a certain brightness. 3500 3000 2500 2000 1500 1000 500 0 input image 0 50 100 150 200 250 brighness histogram

Transformation of the gray scale 5/37 g(i) input gray scale, f(i) output gray scale, f 255 i = 0,..., imax (maximal brightness). Contrast enhancement Threshold Negative 0 255 g Notes: Some transformations are implemented in HW, e.g., in the display card (e.g. in the VGA mode). Thresholding: converts a gray scale image into a binary image. It yields two regions. How to chose an appropriate threshold?

Nonlinearity in the intensity, γ correction 6/37 Why cameras perform nonlinear brightness transformation, the γ-correction? In the cathode-ray tube (vacuum) displays, brightness U γ, where U is the grid voltage and γ is usually 2.2. The effect is compensated in cameras by the inverse function to preserve the linear transfer characteristic in the whole transmission chain. Having input irradiance E and the input voltage of the camera U, the inverse function is U E (1/γ), usually U E 0.45. Although the brightness of LCD monitors depends on the input voltage linearly, the γ-correction is still in use to secure the backward compatibility.

Example of two different thresholds 7/37 3500 3000 2500 2000 1500 1000 500 0 0 50 100 150 200 250

The aim is: Histogram equalization To enhance the contrast for a human observer by utilizing the gray scale fully; To normalize the brightness of the image for the automatic brightness comparison. 8/37 3500 3500 3000 3000 2500 2500 2000 2000 1500 1500 1000 1000 500 500 0 0 0 50 100 150 200 250 histogram of the input image 0 50 100 150 200 250 histogram after equalization

Increased contrast after the histogram equalization 9/37 original image increased contrast

Derivation of the histogram equalization 10/37 Input: The histogram H(p) of the input image with the gray scale p = p 0, p k. Aim: to find a monotonic transform of the gray scale q = T (p), for which the output histogram G(q) will be uniform for the entire input brightness domain q = q 0, q k. k k G(q i ) = H(p i ). i=0 i=0 The equalized histogram the uniform distribution. f = N 2 q k q 0.

Derivation of the histogram equalization (2) The ideal continuous histogram is available only in the continuous case. 11/37 N 2 q q q 0 G(s) ds = q 0 1 q k q 0 ds = N 2 (q q 0 ) q k q 0 = p p 0 H(s) ds. p p 0 H(s) ds. p p 0 H(s) ds. q = T (p) = q k q 0 N 2 p p 0 H(s) ds + q 0. Discrete case, cumulative histogram q = T (p) = q k q 0 N 2 p i=p 0 H(i) + q 0.

Example: Contrast enhancement by a histogram equalization example original equalized histogram max. contrast in Photoshop 12/37

Pseudocolor 13/37 Unchanged System (Windows) Spectrum Black body Pseudocolor displays a grayscale image as a color image by mapping each intensity value to a color according to a lookup table or a function. The mapping table (function) is called the palette. Pseudocolor is often used to display a single channel data as temperature, distance, etc.

Brightness corrections The new brightness f(i, j) depends on the position in the input image i, j of the input image g(i, j). The multiplicative model of the disturbance is often considered: f(i, j) = e(i, j) g(i, j). 14/37 Two approaches: 1. The corrective coefficients are obtained by capturing some etalon area with the known brightness c. This is used to compensate the irregular illumination. (The AGC in the camera has to be switched off when capturing the etalon area). The captured image is f c (i, j) = e(i, j) c e(i, j) = f c(i, j) c 2. The approximation of the background by some analytic surface and its subtraction from the original image.

Geometric transform, a motivation in 2D 15/37 y y The vector transform T can be split into two components T(x,y) x What are the conditions ensuring a one-to-one mapping? x x0 = Tx(x, y), y 0 = Ty (x, y). Geometric transforms are used for Size change, shift, rotation, slanting according to the transformation known in advance. Undoing geometric distortions. The geometric distortions are often estimated from examples, images.

Topographic view of the digital intensity image 16/37 Recall that we considered the image f(x, y) as a landscape in the introduction lecture. y 8 7 6 5 4 3 2 1 1 2 3 x 4 5 6 7 8 The image intensity (brightness) f(x, y) corresponds to the height at the position x, y. f(4,5) A digital image provides only samples on a discrete grid illustrated as the orange arrows. 8 7 6 5 4 3 2 1 y 1 x 2 3 4 5 6 7 8

Topographic view, the geom. transformed image The digital image provides samples in the discrete grid only. See the top right picture. Consider the example: The image is shifted half a pixel in the x-axis direction. See the bottom right picture. The issue: There is no image function f(x + 0.5, y) value available. The solution: Interpolate the missing value from the neighboring image function values. Q: Why neighboring values only? 8 7 6 5 4 3 2 1 y 8 7 6 5 4 3 2 1 y 1 1 x x 2 2 f(4,5) 3 3? 4 4 5 5 6 6 7 8 7 8 17/37

Artistic rendering; maybe of a sampled image Photos are from the exhibition Design Block in Prague in October 2012. 18/37 The artistic piece of work illustrates our topographic view at the image function f (x, y), which can be represented by a collection of poles.

Two needed steps due to the discrete raster 19/37 1. Transformation of pixel coordinates provides new positions of a pixel, which is calculated in continuous coordinates (real numbers) because the outcome can be off the original raster. Issues: Part of the new transformed image lies off the image. Transformations are not invertible because some approximations were needed. 2. Approximation of the brightness function seeks the integer brightness value for the integer coordinate, which matches best the newly calculated position x, y given as real numbers.

Transformation of pixel coordinates The geometric transformation x = Tx(x, y), y = Ty(x, y) is often approximated by a polynomial of m-th order. 20/37 x = m m r a rk x r y k, y = m m r b rk x r y k. r=0 k=0 r=0 k=0 The formula is linear with respect to the coefficients ark, brk. The unknown coefficients can be obtained by solving a system of linear equations, in which pairs of corresponding control points (x, y) and (x, y ) are known. If the system of linear equations were solved deterministically, only a few pairs of control points corresponding to the number of unknown parameters would suffice. However, very many control point pairs are used in practice, which leads to an overdetermined system of linear equations. The unknown coefficients a rk, b rk are estimated using the least-squares method.

A basic set of 2D planar transformations 21/37 y Euclidean translation projective affine original similarity Inspiration R. Szeliski. x

Bilinear, affine transformation of coordinates 22/37 If the geometric transformation changes slowly with respect to the position then approximating polynomials of lower order m = 2 or m = 3 suffice. Bilinear transformation x = a 0 + a 1 x + a 2 y + a 3 xy, y = b 0 + b 1 x + b 2 y + b 3 xy. Affine transformation, which is even more special, comprises practically needed rotation, translation and slant. x = a 0 + a 1 x + a 2 y, y = b 0 + b 1 x + b 2 y.

Homogeneous coordinates matrix notation 23/37 Homogeneous coordinates are common in theoretical mechanics, projective geometry, computer graphics, robotics, etc. The key idea is to represent the point in the space of the dimension increased by one. The point [x, y] is expressed in the 3D vector space as [λx, λy, λ], where λ 0. To simplify expressions, often only one of the infinitely many forms is used [x, y, 1].

Affine transformation expressed in a matrix form 24/37 The affine mapping is expressed after introducing homogeneous coordinates as x y 1 = a 1 a 2 a 0 b 1 b 2 b 0 0 0 1 x y 1. Notes: Relation to the PostScript language. The complicated geometric transforms (deformations) can be approximated by tiling the image into smaller rectangular areas. The simpler transform is used to express distortions in each tile, maybe estimated from the control points.

Applying the geometric transformation Dual expression 25/37 The input image has to be mapped by the transform T to the output image. T Two dual approaches: Forward mapping: (x, y ) = T (x, y). Backward mapping: (x, y) = T 1 (x, y ). T -1 The difference between the two expressions is due to the needed brightness interpolation.

Forward, backward mapping comparison 26/37 Forward mapping Output coordinates (x, y ) can lie off the raster. Two or more input pixels can be mapped to the same output pixel. Some output pixels might not get a value assigned. Gaps occur. Backward mapping For each pixel in the output image (x, y ), the position in the input image (x, y), where the gray value should be taken from is computed using T 1. No gaps will appear. Problem: T 1 might not always exist.

Image function approximation The principally correct answer provides the approximation theory. The continuous 2D function is estimated from available samples. 27/37 Often, the estimated 2D function is approximated locally by a 2D polynomial. Interpolation is a special case of approximation, when the estimated value lies within known samples. Q: Why is the approximation by polynomials popular? A 1 : A polynomial has a few parameters only. The best values of the parameters are sought using an optimization method. Polynomials have continuous derivatives. Consequently, the optimum can be derived analytically or can be computed numerically using the gradient method. A 2 : In the case that the approximation polynomial parameters are estimated experimentally, there are usually many more examples than parameters. Having in mind A 1, the needed derivatives can be expressed analytically.

Three used interpolation methods 28/37 Three interpolation methods are used to estimate the value of 2D image function, e.g. after geometric transformations: 1. Nearest neighbor. 2. Bilinear interpolation. 3. Bicubic interpolation. Note: The prefix bi in bilinear/bicubic means that 1D interpolace is applied in one dimension first and in the second dimension next. For each of three methods, we will explain the idea of the interpolation function in three figures. We will show how the interpolation looks in 1D case. Two steps of the interpretation in 2D will be explicated next. After three methods are explained, we will illustrate methods behavior on one practical example, enlarging the text 20 times..

The nearest neighbor interpolation 29/37 Assigns the value of the nearest sample in sampled image g s raster to the value to the image function f(x, y). f(x, y) = g s (round (x), round (y)). 1D nearest neighbor 2D nearest neighbor step 1 2D nearest neighbor step 2

Bilinear interpolation 30/37 Consider one pixel (a square) in a discrete raster. We know four values of an image function f in its corner points (black circles). We seek the value of the continuous image function f(x, y) for the point (x, y) (red circle) lying outside known samples. In the first step, the function is 1D approximated in one coordinate system direction by linearly fitting two pairs of image function extreme values by a (blue) straight line segments. In the second step, two locations (green circles) are found on two blue line segments corresponding to point (x, y). These locations are fitted linearly again (green line segment). This yields the sought value f(x, y) (red circle). 1D linear 2D bilinear step 1 2D bilinear step 2

Bilinear interpolation, calculation in 2D The interpolated value f(x, y) is calculated by a linear combination of four avaialble samples f s (x, y). The influence of each samples depends on the proximity to the interpolated point in the linear combination. 31/37 f(x, y) = (1 a)(1 b) g s (l, k) + a (1 b) g s (l + 1, k) + b (1 a) g s (l, k + 1) + ab g s (l + 1, k + 1), where l = ceil (x), a = x l, k = ceil (y), b = y k. (l+1,k) (l+1,k+1) (x,y) (l,k) (l,k+1)

Bicubic interpolation The input consists of 16 samples fs in the sampling grid. The output is the interpolated image function value f(x, y) for the location (x, y) (red circle) lying outside of the sampling grid. In the first step, the interpolation is in one coordinates direction by four 1D polynomials (four blue curves). In the second step, the four locations (green circles) are found corresponding to the location (x, y). These points are interpolated by one 1D cubic polynomial yielding sought value (red circle). 32/37 1D cubic 2D bicubic step 2

Three interpolation method illustrated as surfaces Input data are deliberately in a low resolution 7 7 resolution. 33/37

Input image for comparing three interpolations 34/37 Times Roman Ideal 36 x 132 px Times Roman Real 36 x 132 px

Image enlarging 20x, comparison, three methods 35/37 Ideal Times Roman Karel Čapek Nearest neighbor Bilinear Bicubic

Approximation as 2D convolution 36/37 Instead of the originally continuous image function f(x, y), its sampled variant f s (l, k) is available. The outcome of the approximation (interpolation) is the brightness fn(x, y), where index n denotes individual interpolation methods. The brightness can be expressed as a 2D convolution f n (x, y) = f s (l, k) h n (x l, y k). l= k= Function hn is the interpolation kernel. h1 for nearest neighbor, h2 for bilinear interpolation, h 3 for bicubic interpolation. Often, the local approximation kernel is used, which covers only a small neighborhood of the current pixel, to save computations. The values of the kernel h n = 0 outside the kernel domain.

Three convolution kernels pictorially in 1D 37/37 h 1 Nearest neighbor -0.5 0 0.5 x h 2 Bilinear interpolation -1 0 1 x h 3 0.8 Bicubic interpolation 0.6 0.4 0.2-2.0-1.0 0-0.1 1.0 2.0 x