Tallin, November 2007 Introduction to Selected Concepts of Image Processing Jiří Jan Department of Biomedical Engineering Brno University of Technology Czech Republic Tallin, November 2007 Overview of the lectures I. Images as multidimensional signals • • II. analogue nD signals and systems, 2D FT digital 2D images and operators, 2D DFT Image enhancement • • • III. contrast transforms sharpening noise smoothing Reconstruction of images from tomographic projections • parallel projections – – – • algebraic methods slice theorem based reconstruction filtered back projection fan projections 1 I. Images as multidimensional signals • continuous representation of images (both in space and in values) = analogue 2D, 3D or 4D image • discrete representation of images (both in space and in values) = digital image data (2D, 3D, 4D) Analogue (continuous) images Images as signals 2D image (with scalar values) f ( x, y ) x ∈ − xmax , xmax , y ∈ − ymax, ymax – different representations – profiles 2 Images with scalar pixel values: f ( x, y ) - grey-scale - black-and-white (binary) Images with vector pixel values, e.g. : f ( x, y ) = f re (x, y ) + j f im ( x, y ) – 2D image with complex values – colour image in e.g. RGB components f ( x, y ) = [ f R ( x, y ), f G (x, y ), f B ( x, y )] T f (x ) Multidimensional images x = [x,y,z] x = [x,y,t ] x = [x,y,z,t ] e.g. 3D or 4D Some important 2D elementary signals 2D Dirac impulse (df.) while δ ( x, y ) = ∞ ∞ pro x = 0 ∧ y = 0 0 pro x ≠ 0 ∨ y = 0 ∞ ∫ ∫ δ (x, y )dxdy = 1 −∞ −∞ Approximation by a function sequence δ m (x, y ) = m 2 rect(mx, my ) rect(x,y ) = 1 for x ≤ 0.5, y ≤ 0.5 0 otherwise lim δ m ( x, y ) = δ ( x, y ) m →∞ 3 The most important properties of the 2D Dirac impulse (δ-distribution): • filtering property of the δ-distribution ∞ ∫ ∫ ∞ −∞ −∞ f ( x, y )δ ( x − ξ , y − η ) dxdy = f (ξ ,η ) • shift to arbitrary position δ ( x − ξ , y − η) • expression via the 2D Fourier transform δ ( x, y ) = Harmonic 2D signal (e.g. image) ∞ 1 4π 2 ∫ ∫ ∞ −∞ −∞ e − j (ux + vy )du dv f ( x, y ) = A cos(u 0 x + v 0 y + ϕ ) - frequencies in directions x, or y: u, or v - absolute spatial frequency w0 = u 02 + v 02 - spatial period P = 2π u 02 + v 02 - direction of the „wave“ ⎛ v0 ⎝ u0 ϑ = arctan⎜⎜ ⎞ ⎟⎟ ⎠ - phase shift of the „wave“ ϕ - spatial shift of the first ridge d=P ϕ 2π = ϕ w 4 2D systems – description in the original domain Definition (input-output df., i.e. as a mapping, described by an operator): g ( x, y ) = P{ f (x, y )} This can easily be generalised to multidimensional case (3D, 4D) Classification of 2D systems according to different criteria: linearity - linear systems – principle of superposition applies ⎧ ⎫ P ⎨∑ ai f i ( x, y )⎬ = ∑ aiP{ f i (x, y )} ⎩í ⎭ i - nonlinear systems – principle of superposition does not apply spatial extent of the operator influence - point-wise operators - local operators - global operators variability of the operator in space: - spatially invariant operators - isoplanar - spatially variable operators (e.g. adaptive) - anisoplanar isotropy: - isotropic operators - anisotropic operators (e.g. possibly directional) 5 2D linear systems – mathematical description in the original domain f ( x, y ) = ∞ ∫ ∫ ∞ f (s, t )δ (x − s, y − t ) ds dt −∞ −∞ g ( x, y ) = P g ( x, y ) = ∫ {∫ ∞ ∫ ∞ −∞ −∞ ∞ f (s, t )δ ( x − s, y − t ) ds dt } ∞ ∫ P{ f (s, t )δ (x − s, y − t ) }ds dt −∞ −∞ =∫ ∞ ∞ ∫ f (s, t )P{δ (x − s, y − t ) }ds dt −∞ −∞ impulse response (point-spread-function PSF) (generally space-variable) h( x, y, s, t ) = P{δ ( x − s, y − t ) } output of the system – the superposition integral g ( x, y ) = ∫ ∞ ∞ ∫ h(x, y, s, t ) f (s, t )ds dt −∞ −∞ physical interpretation of the superposition integral example: an optical system 6 special case: the isoplanar (space-invariant) system P{δ ( x − s, y − t ) } = h( x − s, y − t ) output: the convolutional integral g ( x, y ) = ∫ ∞ ∞ ∫ h(x − s, y − t ) f (s, t )ds dt −∞ −∞ = h ( x, y ) * f ( x , y ) = h * f ( x, y ) 2D Fourier transform Definition of the forward transform: F (u , v ) = FT2D { f (x, y )} = ∫ ∞ ∫ ∞ −∞ −∞ f ( x, y ) e − j (ux + vy )dx dy as a generalisation of the 1D FT: F1 (u , y ) = ∫ ∞ −∞ f ( x, y ) e − jux dx ∞ F2 (u, v ) = ∫ F1 (u, y ) e − jvy dx = −∞ ∫ ⎡⎢⎣∫ ∞ ∞ −∞ −∞ f ( x, y ) e − jux dx ⎤ e − jvy dy = FT2D { f ( x, y )} ⎥⎦ sketch of coordinates in the original and spectral domain 7 Examples: - spectrum of a square F (u , v ) = FT2D {rect(x, y )} = sin u / 2 sin v / 2 = sinc(u / 2, v / 2) u/2 v/2 - spectrum of a rectangle . Example 2: - spectrum of a natural image original image its spectrum amplitude spectrum phase spectrum 8 Example 3: - spectrum of the 2D Dirac impulse non-existent but can be defined as the limit case of the sequence: Fm (u, v ) = m 2 thus 1 sinc(u/ 2m, v / 2m ) m2 FT2D {δ (x, y )} = lim Fm (u, v ) = 1 m →∞ Definition of the 2D inverse Fourier transform f ( x, y ) = FT -1{F (u , v )} = FT -1{FT{ f ( x, y )}} It can be derived that: f ( x, y ) = FT -1{F (u, v )} = ∞ 1 4π 2 ∫ ∫ ∞ −∞ −∞ F (u, v ) e j (ux + vy )du dv 9 Physical interpretation of the 2D FT Explanation on the image formed by a single concrete harmonic component: [ f ( x, y ) = A cos(u 0 x + v0 y + ϕ ) = 1 A e j (u0 x +v0 y +ϕ ) + e − j (u0 x+v0 y +ϕ ) 2 ] for the first term, the spectrum is given by a shifted δ-impulse, as visible from the inverse FT: FT −1{F1 (u , v )} = ∞ ∞ 1 4π ϕ ( ∫ ∫ [2 Aπ δ (u − u , v − v )e ] e j ux + vy ) j 2 2 0 0 dudv = − ∞− ∞ A j (u0 x + v0 y +ϕ ) e 2 (similarly for the second term) thus the spectrum of the complete harmonic signal is F (u, v ) = FT{A cos(u 0 x + v 0 y + ϕ )} = F1 (u, v ) + F2 (u , v ) = [ 2 Aπ 2 δ (u − u 0 , v − v 0 )e jϕ + δ (u + u 0 , v + v 0 )e − jϕ original image (cropped) ] and its spectrum (cropped) schematic sketch (magnified) 10 The spectrum of a single real harmonic component is symmetrical complex conjugate. As a natural image can be considered an infinite set of harmonic components, its spectrum can be understood as an infinite set of such pairs of impulses. Consequences: • to a rotation of an image, the same rotation of its spectrum corresponds • the spectrum must have the same symmetry as its components, should the image be real-valued: F (u , v ) = F * (− u ,−v ) Basic properties of the 2D FT - linearity 1 ⎛u v⎞ F⎜ , ⎟ ab ⎝ a b ⎠ - change-of-scale rule FT{ f (ax, by )} = - shift rule FT{ f (x − a, y − b )} = F (u, v )e − j (ua + vb ) { } FT f (x, y )e − j (u0 x +v0 y ) = F (u − u0 , v − v0 ) - convolutional property FT{ f ( x, y )* g ( x, y )} = F (u, v )G(u, v ) FT{ f ( x, y ) g ( x, y )} = - Parseval’s theorem ∞ ∞ ∫∫ 1 4π 2 f ( x, y ) g * ( x, y ) dxdy = − ∞− ∞ F (u, v )* G (u, v ) ∞ ∞ ∫ ∫ F (u, v ) G (u, v )dudv * −∞−∞ → total energy preservation law ∞ ∞ ∫∫ − ∞− ∞ f ( x, y ) dxdy = 2 ∞ ∞ ∫ ∫ F (u, v ) 2 dudv − ∞− ∞ 11 2D systems – description in the frequency domain g ( x, y ) = ∫ ∞ ∞ ∫ h(x − s, y − t ) f (s, t )ds dt = h * f (x, y ) −∞ −∞ G (u, v ) = FT{h * f ( x, y )} =∫ ∞ ∫ ⎡⎢⎣∫ ∫ h(x − s, y − t ) f (s, t ) ds dt ⎤⎥⎦ e ∞ −∞ −∞ G (u, v ) = ∫ ∞ ∞ ∞ ∫ f (s, t )⎡⎢⎣∫ ∫ h(x − s, y − t )e ∞ −∞ −∞ G (u , v ) = ∫ ∞ −∞ −∞ ∫ ∞ −∞ −∞ ∞ ∞ − ∞ −∞ − j (ux + vy ) − j (ux + vy ) dx dy dx dy ⎤ ds dt ⎥⎦ f (s, t ) H (u , v ) e − j (us + vt ) ds dt H(u,v)=FT{h(x,y)} – frequency response G (u , v ) = H (u , v ) F (u , v ) (or frequency transfer) of the (space-invariant) system Alternative possibility of calculating the output of the system: F (u , v ) = FT2D { f ( x, y )} -1 {H (u, v ) F (u, v )} g ( x, y ) = FT2D examples of image processing by linear space-invariant systems (2D filters) original image filter responses processed images 12 (cont. of the examples) original spectrum frequency response frequency response (cont. of the examples) frequency response 13 Stochastic images as realisations of a stochastic field Basic concepts: (generalisation of 1D case of stochastic process) – family of functions – associated experiment – local stochastic variables – local characteristics – stochastic field (2D stochastic process) – correlation between two and more points – correlation functions – homogeneous (stationary) fields – ergodic fields 14