Slide 1

Slide 1 text

Digital Image Processing Introduction (Week 1) NHSM - 4th year - Fall 2024 - Prof. Mohammed Hachama hachamam@gmail.com http://hachama.github.io/home/

Slide 2

Slide 2 text

Outline Introduction Image characteristics Digitization Geometric Transformations NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 2/23

Slide 3

Slide 3 text

Introduction NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 3/23

Slide 4

Slide 4 text

Information about the course • Image processing courses • Introduction to image processing (S7 - UEF721): Image = matrix • Computer vision (S8 - UEF823): More applications • Image processing (S9 - UEF911): Image = function (more elaborated mathematics) • UEF721 Course: 15 weeks • 1 lecture: slides, no written notes (see references if need be!) • 1 tutorial/practical session • 3 assignments (Chap. 1,2,3) • 3 individual projects (Chap. 4,5,6) NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 4/23

Slide 5

Slide 5 text

Information about the course • Career opportunities • Work in the field of signal/image/video processing, computer vision, or data science in general (in both industry or academia). • Be able to understand and implement recent publications in that field. • Understand latest machine learning and computer vision techniques. Many deep learning concepts are based on tools that will be introduced in this class. NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 4/23

Slide 6

Slide 6 text

Information about the course • Prerequisites • Linear algebra • Differential calculus • Probability and statistics • Fourier transform • Basics of optimization • Python programming NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 4/23

Slide 7

Slide 7 text

Information about the course • Evaluation • 3 Assignments = 1 points each, report submission • 3 Projects = 3 points each, 10 minutes oral presentation • CC = Assignments/3 + Projects/9 + Midterm/8 + participation (bonus)/2 • Exam = 20/20 • Individual work, sharp deadlines NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 4/23

Slide 8

Slide 8 text

Information about the course • Assignments • Assignment 1: Image manipulation, characteristics, geometric transformations • Assignment 2: spatial processing • Assignment 3: frequency domain processing • Projects • Project 1: Image compression - Fourier, Wavelets, Dictionaries • Project 2: Image restoration - Denoising, Debluring, Inpinting • Project 3: Image segmentation - Edges detection, Region classification NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 4/23

Slide 9

Slide 9 text

Information about the course • Books NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 4/23

Slide 10

Slide 10 text

Information about the course • Similar courses • CS 131 Computer Vision: Foundations and Applications (Stanford University) • Introduction to Computer Vision, CS5670, Spring 2023, Cornell Tech, www.cs.cornell.edu/courses/cs5670/2024sp/ • 16-385 Computer Vision, Spring 2020, Carnegie Mellon, www.cs.cmu.edu/∼16385/ • YouTube lectures • Image and video Processing: From Mars to Hollywood with a Strop at the Hospital, Guillermo Sapiro • Intro to Digital Image Processing, Rich Radke • Various codes • www.numerical-tours.com NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 4/23

Slide 11

Slide 11 text

Information about the course • Outline • Introduction (1 week) • Spatial Processing (2 weeks) • Frequency-domain processing (2 weeks) • Image Compression (1 week) • Exercises (1 week) • Mid-Term • Image Restoration (3 weeks) • Image Segmentation (3 weeks) • Evaluations (projects) (1 week) • Links • Course: http://github.com/hachama/introimg • Professor: https//hachama.github.io/home/ NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 4/23

Slide 12

Slide 12 text

Why automatic image processing? NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 5/23

Slide 13

Slide 13 text

Why automatic image processing? NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 5/23

Slide 14

Slide 14 text

Why automatic image processing? NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 5/23

Slide 15

Slide 15 text

Why automatic image processing? NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 5/23

Slide 16

Slide 16 text

Why automatic image processing? Importance of using automatic image processing! NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 5/23

Slide 17

Slide 17 text

What is an image? Image = representation of a scene • Scene: Set of objects that are in the field of vision • Light source: Sun, ambient lighting, spotlights, ... NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 6/23

Slide 18

Slide 18 text

What is an image? Image = matrix of intensities NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 6/23

Slide 19

Slide 19 text

What is an image? Image = matrix of intensities • Image = numbers! • Red, Green, Blue (RGB), K = 3 • RGB: Usual color-space for acquisition and display • Color-spaces for different purposes: HSV (Hue, Saturation, Value), YUV, YCbCr. NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 6/23

Slide 20

Slide 20 text

What is an image? Image = matrix of intensities • Discretization NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 6/23

Slide 21

Slide 21 text

What is an image? Image = matrix of intensities • Quantization NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 6/23

Slide 22

Slide 22 text

What is an image? Intensities = information • Thermal Imaging: temperature degrees NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 6/23

Slide 23

Slide 23 text

What is an image? Intensities = information • Magnetic resonance imaging (MRI) NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 6/23

Slide 24

Slide 24 text

What is an image? Intensities = information • X-ray scans NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 6/23

Slide 25

Slide 25 text

What is an image? Intensities = information • Radar Imaging NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 6/23

Slide 26

Slide 26 text

What is an image? Image = A mathematical object • Matrix/Tensor • Function I : E −→ F • Distribution • Random field • Surface/sub-manifold • ... NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 6/23

Slide 27

Slide 27 text

Image processing (1) What is image processing? • Transformation of a digital image into another image or extracting features, primitives, or information. NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 7/23

Slide 28

Slide 28 text

Image processing (1) What is image processing? NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 7/23

Slide 29

Slide 29 text

Image processing (1) What is image processing? NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 7/23

Slide 30

Slide 30 text

Image processing (1) What is image processing? NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 7/23

Slide 31

Slide 31 text

Image processing (2) Fundamental problems • Restoration NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 32

Slide 32 text

Image processing (2) Fundamental problems • Restoration NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 33

Slide 33 text

Image processing (2) Fundamental problems • Restoration NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 34

Slide 34 text

Image processing (2) Fundamental problems • Deconvolution NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 35

Slide 35 text

Image processing (2) Fundamental problems • Contours Detection NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 36

Slide 36 text

Image processing (2) Fundamental problems • Segmentation NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 37

Slide 37 text

Image processing (2) Fundamental problems • Matching NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 38

Slide 38 text

Image processing (2) Fundamental problems • Inpainting NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 39

Slide 39 text

Image processing (2) Fundamental problems • Rigid Registration NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 40

Slide 40 text

Image processing (2) Fundamental problems • Non-Rigid Registration NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 41

Slide 41 text

Image processing (2) Fundamental problems • Non-Rigid Registration NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 42

Slide 42 text

Image processing (2) Fundamental problems • Non-Rigid Registration NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 43

Slide 43 text

Image processing (2) Fundamental problems • Non-Rigid Registration NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 44

Slide 44 text

Image processing (2) Fundamental problems • Image decomposition NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 45

Slide 45 text

Image processing (2) Fundamental problems • Image fusion NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 46

Slide 46 text

Image processing (2) Fundamental problems • Image fusion NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 8/23

Slide 47

Slide 47 text

Image processing (3) Applications • Pattern recognition NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 9/23

Slide 48

Slide 48 text

Image processing (3) Applications • Optical character recognition (OCR) NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 9/23

Slide 49

Slide 49 text

Image processing (3) Applications • Optical character recognition (OCR) NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 9/23

Slide 50

Slide 50 text

Image processing (3) Applications • Scene recognition NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 9/23

Slide 51

Slide 51 text

Image processing (3) Applications • Inspection in manufacturing NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 9/23

Slide 52

Slide 52 text

Image processing (3) Applications • Compression NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 9/23

Slide 53

Slide 53 text

Image processing (3) Applications • Medical imaging NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 9/23

Slide 54

Slide 54 text

Image processing (3) Applications • Geographic Information Systems NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 9/23

Slide 55

Slide 55 text

Image processing (3) Applications • Geographic Information Systems NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 9/23

Slide 56

Slide 56 text

Image processing (3) Applications • Special effects NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 9/23

Slide 57

Slide 57 text

Image processing (3) Applications • Biometric identification NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 9/23

Slide 58

Slide 58 text

Image processing (3) Applications • Self-driving cars NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 9/23

Slide 59

Slide 59 text

Image processing (3) Applications • Augmented Reality NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 9/23

Slide 60

Slide 60 text

Image processing (3) Applications • Virtual Reality NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 9/23

Slide 61

Slide 61 text

Image characteristics NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 10/23

Slide 62

Slide 62 text

Image = matrix • Image = Matrix (I : {1, .., N} × {1, ..., M} −→ [0, 1]) • Pixel = indices + intensity NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 11/23

Slide 63

Slide 63 text

Image = matrix • Image = Matrix (I : {1, .., N} × {1, ..., M} −→ [0, 1]) • Pixel = indices + intensity • Frame = Origin + Axes NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 11/23

Slide 64

Slide 64 text

Image = matrix • Image = Matrix (I : {1, .., N} × {1, ..., M} −→ [0, 1]) • Pixel = indices + intensity • Frame = Origin + Axes • Pixel neighborhood system: 4-neighbors (2 horizontals + 2 verticals) NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 11/23

Slide 65

Slide 65 text

Image = matrix Pixel neighbors • 4-neighbors (2 horizontals + 2 verticals) (x + 1, y), (x − 1, y), (x, y + 1), (x, y − 1) • 4 diagonal (x + 1, y + 1), (x + 1, y − 1), (x − 1, y + 1), (x − 1, y − 1) • 8-Neighbors • Some pixels can call outside the image! NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 11/23

Slide 66

Slide 66 text

Image = matrix Distances between pixels • Given two pixels p(x, y) and q(s, t) • Manhattan distance: D1 (p, q) = |x − s|+|y − t| ? ? ? ? ? ? ? ? ? ? ? ? 0 ? ? ? ? ? ? ? ? ? ? ? ? NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 11/23

Slide 67

Slide 67 text

Image = matrix Distances between pixels • Given two pixels p(x, y) and q(s, t) • Euclidean Distance: D2 (p, q) = [(x − s)2 + (y − t)2]1/2 ? ? ? ? ? ? ? ? ? ? ? ? 0 ? ? ? ? ? ? ? ? ? ? ? ? NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 11/23

Slide 68

Slide 68 text

Image = matrix Distances between pixels • Given two pixels p(x, y) and q(s, t) • chessboard distance: D3 (p, q) = maximum(|x − s|, |y − t|) ? ? ? ? ? ? ? ? ? ? ? ? 0 ? ? ? ? ? ? ? ? ? ? ? ? NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 11/23

Slide 69

Slide 69 text

Image = matrix Image = Vector representation NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 11/23

Slide 70

Slide 70 text

Image = matrix Image = Vector representation Linear algebra tools: linear operator, matrix decomposition, norms, optimization, ... NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 11/23

Slide 71

Slide 71 text

Types of regions NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 12/23

Slide 72

Slide 72 text

Characteristics For an image I: • Dynamic: max I − min I • Luminance: Lum = Mean (I) • Contrast: C1 = N i=1 M j=1 (I(i, j) − Lum)2 N.M , C2 = max I − min I max I + min I NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 13/23

Slide 73

Slide 73 text

Format and storage • A bit (Binary-Digit) = ”The basic element with which the computer works. Its value is 1 or 0. • 8 bits = 28 = 256 possible values (16 bits = 65.536). • 1 Byte = 1 octet = 8 bits. • Binary Image 512 × 512: 512 × 512 × 1 = 262144 bits = 32768 bytes. • 512 × 512 8-bit gray-level image: 512 × 512 × 1 = 262144 bytes. • 512 × 512 color image, with a byte used to store each color: 512 × 512 × 3 = 786432 bytes. • 2 hours color video: 1000x1000x24x30x60x120 = 5184 × 109 bits = 648Go! NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 14/23

Slide 74

Slide 74 text

Format and storage • A bit (Binary-Digit) = ”The basic element with which the computer works. Its value is 1 or 0. • 8 bits = 28 = 256 possible values (16 bits = 65.536). • 1 Byte = 1 octet = 8 bits. • Binary Image 512 × 512: 512 × 512 × 1 = 262144 bits = 32768 bytes. • 512 × 512 8-bit gray-level image: 512 × 512 × 1 = 262144 bytes. • 512 × 512 color image, with a byte used to store each color: 512 × 512 × 3 = 786432 bytes. • 2 hours color video: 1000x1000x24x30x60x120 = 5184 × 109 bits = 648Go! We definitely need compression! NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 14/23

Slide 75

Slide 75 text

Format and storage • TIFF(.tif, .tiff): Tagged Image File Format, no compression, high quality, large size. Good for printing. • JPEG (.jpg, .jpeg): Joint Photographic Experts Group, Lossy compression, reduced size. Good for digital cameras, web use. • GIF: Graphics Interchange Format, used for web graphics, can be animated, limited to 256 colors, allow for transparency, small size. • PNG: Portable Network Graphics , lossless, support 16 million colors. • EPS (.eps) Encapsulated PostScript, vector file type, can be opened in applications such as Adobe Illustrator or CorelDRAW. • RAW Image Files (.raw, .cr2, .nef, .orf, .sr2, dicom, ...): created by a camera or scanner, hold a lot of information (intensities + metadata), need to be processed in an editor. NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 14/23

Slide 76

Slide 76 text

Digitization NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 15/23

Slide 77

Slide 77 text

Digitization Sampling + quantification NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 16/23

Slide 78

Slide 78 text

Quantification (1) Tonal resolution: 1,2, ..., 8 bits NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 17/23

Slide 79

Slide 79 text

Quantification (1) Tonal resolution NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 17/23

Slide 80

Slide 80 text

Quantification (1) Application 1: Compression by reducing the tonal resolution % Loading OpenCV library import cv2 as cv % Quantification ratio Q = 32 % Lecture of the input image im1 = cv.imread(’data/lake.jpg’,0) % Compression im2=(im1.astype(np.float32)/Q).astype(np.uint8) NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 17/23

Slide 81

Slide 81 text

Quantification (1) Application 1: Compression by reducing the tonal resolution Original image/1 NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 17/23

Slide 82

Slide 82 text

Quantification (1) Application 1: Compression by reducing the tonal resolution Image size/2 NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 17/23

Slide 83

Slide 83 text

Quantification (1) Application 1: Compression by reducing the tonal resolution Image size/4 NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 17/23

Slide 84

Slide 84 text

Quantification (1) Application 1: Compression by reducing the tonal resolution Image size/8 NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 17/23

Slide 85

Slide 85 text

Quantification (1) Application 1: Compression//False contours Image size/16 NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 17/23

Slide 86

Slide 86 text

Quantification (1) Application 1: Compression//Dithering: adding noise Image size/16 NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 17/23

Slide 87

Slide 87 text

Quantification (2) Application 2: Steganography Decimal/binary Representation 241 = (? ) × 20 + (? ) × 21 + (? ) × 22 + (? ) × 23 + (? ) × 24 + (? ) × 25 + (? ) × 26 + (? ) × 27 241 120 60 30 15 7 3 1 0 1 0 0 0 1 1 1 1 − NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 18/23

Slide 88

Slide 88 text

Quantification (2) Application 2: Steganography Bitplanes: Original / Bit 1 NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 18/23

Slide 89

Slide 89 text

Quantification (2) Application 2: Steganography Bitplanes: Original / Bit 2 NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 18/23

Slide 90

Slide 90 text

Quantification (2) Application 2: Steganography Bitplanes: Original / Bit 3 NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 18/23

Slide 91

Slide 91 text

Quantification (2) Application 2: Steganography Bitplanes: Original / Bit 4 NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 18/23

Slide 92

Slide 92 text

Quantification (2) Application 2: Steganography Bitplanes: Original / Bit 5 NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 18/23

Slide 93

Slide 93 text

Quantification (2) Application 2: Steganography Bitplanes: Original / Bit 6 NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 18/23

Slide 94

Slide 94 text

Quantification (2) Application 2: Steganography Bitplanes: Original / Bit 7 NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 18/23

Slide 95

Slide 95 text

Quantification (2) Application 2: Steganography Bitplanes: Original / Bit 8 NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 18/23

Slide 96

Slide 96 text

Quantification (2) Application 2: Steganography (Secret message) NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 18/23

Slide 97

Slide 97 text

Quantification (2) Application 2: Steganography (modification od bit 7) NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 18/23

Slide 98

Slide 98 text

Quantification (2) Application 2: Steganography (modification of bits 7, 6 and 5) NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 18/23

Slide 99

Slide 99 text

Sampling Spatial resolution: number of pixels NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 19/23

Slide 100

Slide 100 text

Sampling Spatial resolution: number of pixels • dpi: dots per inch (1 inch = 2.54 cm), ppp : points par pouce • Number of ”physical” pixels in an inch of a printed document. • ppc: points per centimeter ; ppm : points per millimeter • ppi (pixels per inch): # of ”squared” pixels in an inch of a screen. NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 19/23

Slide 101

Slide 101 text

Sampling Spatial resolution: number of pixels • Computation: we need to use three parameters • Physical dimensions of the final image (on a screen, printed) or of the source image (page to be scanned) - e.g., 30 x 20 cm • Final resolution - e.g., 118 ppc • Image size (in pixels) - e.g., 3072 x 2048 pixels NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 19/23

Slide 102

Slide 102 text

Sampling Spatial resolution: number of pixels • Example 1. You want to print a 13 x 10 cm photo. Your printer asks you to provide images with a resolution of at least 300 dpi. • minimal width: 13x300/2,54=1535 pixels • minimal height: 10x300/2,54=1181 pixels. NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 19/23

Slide 103

Slide 103 text

Sampling Spatial resolution: number of pixels • Example 2. A screen set at 75 ppi displays a photo with dimensions of 15 x 12 cm. What is the size of the image in pixels? • 75ppi=75/2,54 pixels/cm • Largeur de l’image : 15*75/2,54 = 443 px • Hauteur de l’image : 12*75/2,54 = 354 px NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 19/23

Slide 104

Slide 104 text

Sampling Aliasing = Distortion in the signal due to a low sampling frequency NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 19/23

Slide 105

Slide 105 text

Sampling Aliasing = Distortion in the signal due to a low sampling frequency NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 19/23

Slide 106

Slide 106 text

Sampling Aliasing = Distortion in the signal due to a low sampling frequency NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 19/23

Slide 107

Slide 107 text

Sampling Aliasing = Distortion in the signal due to a low sampling frequency • The bands change direction and thickness NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 19/23

Slide 108

Slide 108 text

Sampling Aliasing = Distortion in the signal due to a low sampling frequency • The bands change direction and thickness. NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 19/23

Slide 109

Slide 109 text

Geometric Transformations NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 20/23

Slide 110

Slide 110 text

Transformations Geometric Transformations NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 21/23

Slide 111

Slide 111 text

Transformations Geometric Transformations • Direct Transformation: (i′, j′) = T(i, j) NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 21/23

Slide 112

Slide 112 text

Transformations Geometric Transformations • Direct Transformation: (i′, j′) = T(i, j) NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 21/23

Slide 113

Slide 113 text

Transformations Geometric Transformations • Direct Transformation: (i′, j′) = T(i, j) NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 21/23

Slide 114

Slide 114 text

Transformations Geometric Transformations • Direct Transformation: (i′, j′) = T(i, j) NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 21/23

Slide 115

Slide 115 text

Transformations Geometric Transformations • Direct Transformation: (i′, j′) = T(i, j) NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 21/23

Slide 116

Slide 116 text

Transformations Geometric Transformations • Direct Transformation: (i′, j′) = T(i, j) NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 21/23

Slide 117

Slide 117 text

Transformations Geometric Transformations • Direct Transformation: (i′, j′) = T(i, j) • Points without images, Points outside the image NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 21/23

Slide 118

Slide 118 text

Transformations Geometric Transformations • Inverse Transformation: (i, j) = T−1(i′, j′) • Interpolation: Nearest neighbor, Bi-linear, ... NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 21/23

Slide 119

Slide 119 text

Transformations Geometric Transformations • Translation: i′ j′ = 1 0 0 1 i j + ti tj • Rotation: x′ y′ = cos θ sin θ − sin θ cos θ x y + 0 0 • Coordinates relative to the center of the image • Exercise: Implement and run simulations. NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 21/23

Slide 120

Slide 120 text

Transformations Geometric Transformations • Rotation: Coordinates relative to the center of the image NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 21/23

Slide 121

Slide 121 text

Transformations Geometric Transformations • Rotation: Interpolation by Nearest neighbor NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 21/23

Slide 122

Slide 122 text

Transformations Geometric Transformations • Rotation: Bi-linear Interpolation NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 21/23

Slide 123

Slide 123 text

Transformations Geometric Transformations • Change of scale: i′ j′ = αi 0 0 αj i j + 0 0 • Affine Deformation: i′ j′ = a1 a2 a3 a4 i j + b1 b2 • Exercise: Implement and run simulations. NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 21/23

Slide 124

Slide 124 text

Image Interpolation • Image interpolation is the process of estimating pixel values at non-integer coordinates. • It is used in various applications such as resizing, rotating, and warping images. • Types of Image Interpolation • Replication • Nearest Neighbor Interpolation • Bilinear Interpolation • Bicubic Interpolation NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 22/23

Slide 125

Slide 125 text

Image Interpolation Pixel replication • Produces a “jagged” result since each individual square pixel is made larger. NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 22/23

Slide 126

Slide 126 text

Image Interpolation Nearest Neighbor Interpolation • The simplest method where the value of the nearest pixel is assigned to the interpolated pixel. • Formula: I(x′, y′) = I(round(x), round(y)) Where: • I(x′, y′) is the intensity value at the point (x′, y′) in the output image. • I(x, y) is the intensity value at the point (x, y) in the input image. • round(x) and round(y) round the coordinates to the nearest integer, representing the nearest pixel in the input image. NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 22/23

Slide 127

Slide 127 text

Image Interpolation Bilinear Interpolation • Uses a weighted average of the closest 2 × 2 neighbors (four nearest pixels) to estimate the new pixel value. The interpolation is performed first in one direction (e.g., x-axis) and then in the other (y-axis), resulting in a smoother image than Nearest Neighbor. • Formula: I(x′, y′) = 1 i=0 1 j=0 I(x + i, y + j)(1 − |x′ − (x + i)|)(1 − |y′ − (y + j)|) The weights (1 − |x′ − (x + i)|) and (1 − |y′ − (y + j)|) are proportional to the distance of (x′, y′) from the corresponding neighboring pixels. NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 22/23

Slide 128

Slide 128 text

Image Interpolation Bicubic Interpolation • Considers the closest 4 × 4 neighbors (16 pixels) to estimate the new pixel value using cubic polynomials. • Formula: I(x′, y′) = 2 i=−1 2 j=−1 I(x + i, y + j)W (i, x′)W (j, y′) where W (k, t) is the cubic weight function. NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 22/23

Slide 129

Slide 129 text

Image Interpolation Comparison • Nearest neighbor is fast but may produce blocky images. • Bilinear provides smoother images, but may blur details. • Bicubic gives better quality with more computational cost. NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 22/23

Slide 130

Slide 130 text

Image Interpolation What about image warping? NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 22/23

Slide 131

Slide 131 text

Image Interpolation What about image warping? NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 22/23

Slide 132

Slide 132 text

Assignment 1 Write a python code that depends on the OpenCV library and that performs the following: 1. Read, display and save an image. 2. Manipulate pixels intensities and image channels. 3. Transform a matrix into a vector and vice-versa. 4. Compute and display some characteristics such as dynamic, luminance and contrast. 5. Perform compression by reducing the tonal resolution. 6. Perform different geometric transformations. 7. Perform a steganography. 8. Perform subsampling and upsampling. 9. Perfom image warping into a circle. NHSM - 4th year: Digital Image Processing - Introduction (Week 1) - M. Hachama (hachamam@gmail.com) 23/23