IMAGE PROCESSING Vedat Tavşanoğlu

Similar documents
Introduction to DSP ECE-S352 Fall Quarter 2000 Matlab Project 1

Digital Image Processing. Digital Image Fundamentals II 12 th June, 2017

SECTION I - CHAPTER 2 DIGITAL IMAGING PROCESSING CONCEPTS

Sampling and Reconstruction of Analog Signals

Filtering in the spatial domain (Spatial Filtering)

Prof. Feng Liu. Fall /04/2018

Image and Video Processing

Image Enhancement using Histogram Equalization and Spatial Filtering

Image Filtering. Median Filtering

Filters. Materials from Prof. Klaus Mueller

Section 7.6 Graphs of the Sine and Cosine Functions

Prof. Feng Liu. Winter /10/2019

The Discrete Fourier Transform. Claudia Feregrino-Uribe, Alicia Morales-Reyes Original material: Dr. René Cumplido

Transforms and Frequency Filtering

Computer Vision, Lecture 3

Lecture 2: SIGNALS. 1 st semester By: Elham Sunbu

Graphs of sin x and cos x

Images and Filters. EE/CSE 576 Linda Shapiro

Motion illusion, rotating snakes

1.Discuss the frequency domain techniques of image enhancement in detail.

How to Graph Trigonometric Functions

Prof. Vidya Manian Dept. of Electrical and Comptuer Engineering

DIGITAL IMAGE PROCESSING Quiz exercises preparation for the midterm exam

L A B 3 : G E N E R A T I N G S I N U S O I D S

02/02/10. Image Filtering. Computer Vision CS 543 / ECE 549 University of Illinois. Derek Hoiem

PASS Sample Size Software

LINEAR EQUATIONS IN TWO VARIABLES

Image features: Histograms, Aliasing, Filters, Orientation and HOG. D.A. Forsyth

EE482: Digital Signal Processing Applications

DSP First. Laboratory Exercise #11. Extracting Frequencies of Musical Tones

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering. EIE2106 Signal and System Analysis Lab 2 Fourier series

Lab P-4: AM and FM Sinusoidal Signals. We have spent a lot of time learning about the properties of sinusoidal waveforms of the form: ) X

LAB 2: Sampling & aliasing; quantization & false contouring

Objective: Investigate patterns in vertical and horizontal lines, and. interpret points on the plane as distances from the axes.

Frequency Domain Enhancement

Image Filtering. Reading Today s Lecture. Reading for Next Time. What would be the result? Some Questions from Last Lecture

Chapter 4: Patterns and Relationships

Last Lecture. photomatix.com

Signal Processing First Lab 20: Extracting Frequencies of Musical Tones

Qäf) Newnes f-s^j^s. Digital Signal Processing. A Practical Guide for Engineers and Scientists. by Steven W. Smith

>>> from numpy import random as r >>> I = r.rand(256,256);

DSP First Lab 06: Digital Images: A/D and D/A

Digital Image Processing. Lecture # 6 Corner Detection & Color Processing

Problem Set 1 (Solutions are due Mon )

Determining MTF with a Slant Edge Target ABSTRACT AND INTRODUCTION

10 GRAPHING LINEAR EQUATIONS

Matlab (see Homework 1: Intro to Matlab) Linear Filters (Reading: 7.1, ) Correlation. Convolution. Linear Filtering (warm-up slide) R ij

30 lesions. 30 lesions. false positive fraction

IIR Filter Design Chapter Intended Learning Outcomes: (i) Ability to design analog Butterworth filters

Experiments #6. Convolution and Linear Time Invariant Systems

Log Booklet for EE2 Experiments

Defense Technical Information Center Compilation Part Notice

Instruction Manual for Concept Simulators. Signals and Systems. M. J. Roberts

Preparing Remote Sensing Data for Natural Resources Mapping (image enhancement, rectifications )

CS 445 HW#2 Solutions

EEL 6562 Image Processing and Computer Vision Box Filter and Laplacian Filter Implementation

Linear Time-Invariant Systems

Q A bitmap file contains the binary on the left below. 1 is white and 0 is black. Colour in each of the squares. What is the letter that is reve

Project 0: Part 2 A second hands-on lab on Speech Processing Frequency-domain processing

Solution Q.1 What is a digital Image? Difference between Image Processing

The Scientist and Engineer's Guide to Digital Signal Processing By Steven W. Smith, Ph.D.

Detection and Verification of Missing Components in SMD using AOI Techniques

DIGITAL IMAGE PROCESSING (COM-3371) Week 2 - January 14, 2002

DIGITAL SIGNAL PROCESSING CCC-INAOE AUTUMN 2015

Image Enhancement in spatial domain. Digital Image Processing GW Chapter 3 from Section (pag 110) Part 2: Filtering in spatial domain

Digital Image Processing COSC 6380/4393

Solution Set #2

Using Curves and Histograms

4. Measuring Area in Digital Images

CSCI 1290: Comp Photo

The quality of the transmission signal The characteristics of the transmission medium. Some type of transmission medium is required for transmission:

Image Processing for feature extraction

Digital Image Processing

Spectrum Analysis: The FFT Display

Lecture 17 z-transforms 2

Fuzzy Logic Based Adaptive Image Denoising

8.2 IMAGE PROCESSING VERSUS IMAGE ANALYSIS Image processing: The collection of routines and

Computer Graphics (Fall 2011) Outline. CS 184 Guest Lecture: Sampling and Reconstruction Ravi Ramamoorthi

Sect Linear Equations in Two Variables

AN ERROR LIMITED AREA EFFICIENT TRUNCATED MULTIPLIER FOR IMAGE COMPRESSION

Engineering Fundamentals and Problem Solving, 6e

CS3291: Digital Signal Processing

Fourier Series and Gibbs Phenomenon

DSP First Lab 03: AM and FM Sinusoidal Signals. We have spent a lot of time learning about the properties of sinusoidal waveforms of the form: k=1

Last Lecture. photomatix.com

Chapter 17. Shape-Based Operations

Traffic Sign Recognition Senior Project Final Report

CS 111: Programing Assignment 2

NAME STUDENT # ELEC 484 Audio Signal Processing. Midterm Exam July Listening test

Lesson 16: The Computation of the Slope of a Non Vertical Line

Spatial Analyst is an extension in ArcGIS specially designed for working with raster data.

Sharpening Spatial Filters ( high pass)

>>> from numpy import random as r >>> I = r.rand(256,256);

Lab 4 Fourier Series and the Gibbs Phenomenon

Performance Evaluation of Edge Detection Techniques for Square Pixel and Hexagon Pixel images

PASS Sample Size Software. These options specify the characteristics of the lines, labels, and tick marks along the X and Y axes.

CAP 5415 Computer Vision. Marshall Tappen Fall Lecture 1

SECTION 7: FREQUENCY DOMAIN ANALYSIS. MAE 3401 Modeling and Simulation

Biomedical Signals. Signals and Images in Medicine Dr Nabeel Anwar

Learning Log Title: CHAPTER 2: ARITHMETIC STRATEGIES AND AREA. Date: Lesson: Chapter 2: Arithmetic Strategies and Area

Transcription:

Vedat Tavşano anoğlu

Image Processing A Revision of Basic Concepts An image is mathematically represented by: where I( x, y) x y is the vertical spatial distance; is the horizontal spatial distance, both measured from the top left corner, and I( x, y) is the brightness of point ( x, y ). 2

Image Processing A typical black-and-white photograph is composed of shades of gray spanning from black to white, and is known as a continuous tone image. Digital image processing requires discrete pieces of data on a one-by-one basis. Therefore the continuous tone image must first be chopped into individual points of information. This chopping is referred to as sampling, because we are taking samples of brightness of the photograph at specific locations within it. 3

Image Processing As a result of sampling an image is discretized into a square grid of pixels, each of which is labelled with a pair of coordinates, one defining its line number and the other the column number. Digitising an image involves yet a further step: Discretization (quantization) of the brightness values in order to have a limited number of brightness levels, e.g., for an 8-bit system 256= 2 8. 4

Image Processing 0 1 2 3 4 5.. 0 1 2 3 4 5 6 7 8 9 10... 5 The discrete pixel numbering convention

Image Processing The frequency content of any physical signal depends on the rapidity of its change over a certain observation period. In DSP this period is referred to as record length. In an image the frequency components are spatial frequencies which relate to the rapidity of change in gray levels over a certain spatial distance. Since there are two dimensions there are two spatial frequency components, namely f x and f y. 6

Image Processing When dealing with the digitisation of an image, there is always the question of how good the representation is when compared with the original. We define the limitations of the digitisation process with the term resolution. When we speak of spatial resolution, we are describing how many pixels our digital image is divided into. 7

Image Processing An image is said to be composed of many basic frequency components, ranging from low to high. Rapid brightness transitions give rise to high spatial frequency and slow transitions to low spatial frequency. Wherever a sharp edge is present-say, a transition from black to white within a one pixel distance-the highest frequencies in the image are found. 8

Image Filtering Making use of this information, we may generate output images showing only,e.g., high-frequency or low frequency components, a class of operation known as spatial filtering. Additional spatial filtering operations make it possible to generate images that show only where individual sharp transitions occur. These processes ultimitaly yield image edge detection and enhancement. 9

Image Filtering Linear filtering of an image is accomplished through an operation called convolution. In convolution, the value of an output pixel is computed as a weighted sum of neighbouring pixels. The matrix of weights is called the convolution kernel, also known as the filter. 10

Image Filtering Example: 17 24 1 8 15 23 5 7 14 16 8 1 6 A 4 6 13 20 22 h 3 5 7 10 12 19 21 3 4 9 2 11 18 25 2 9 Input Image Convolution Kernel 11

Image Filtering Computing the (2,4) output pixel: 1. Rotate the convolution kernel 180 degrees about its centre element. 2. Slide the centre element of the convolution kernel so that it lies on top of (2,4) element of A. 3. Multiply each weight in the rotated convolution kernel by the pixel of A underneath. 4. Sum up the individual products from step 3. 12

Image Filtering 17 24 1 8 15 23 5 7 14 16 8 1 6 A 4 6 13 20 22 h 3 5 7 10 12 19 21 3 4 9 2 11 18 25 2 9 Values of rotated convolution kernel 13 Input image pixel values 17 23 4 10 11 24 5 6 12 18 1 7 2 7 13 6 19 25 8 9 14 20 21 The (2,4) output pixel value is: 2 5 1 15 16 22 3 9 4 3 8 Centre of kernel 12 8 9 154 7 7 145 16 3136 201 228 575

Image Filtering 8 1 6 h 3 5 7 4 9 2 14 This is called either of the following: Template Image mask Convolution kernel Impulse response

Image Filtering Examples of lowpass filter kernels: 1/10 1/10 1/10 1/10 2 /10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 2 / 5 1/10 1/10 1/10 1/10 15

Image Filtering Frequency Response 1/10 1/10 1/10 1/10 2 /10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 2 / 5 1/10 1/10 1/10 1/10 16

Let us once again repeat what we have already said earier: In an image the frequency components are spatial frequencies which relate to the rapidity of change in gray levels over a certain spatial distance. Since there are two dimensions there are two spatial frequency components, namely f x and f y. Now consider the image on the next page. The size of this image image is 128x128 pixels. Each of the black or white stripes is one pixel wide. The following image is of the same size whose stripes are 4 pixels wide. 17

18

19

Now bearing in mind that a pair of black and white stripes represents one cycle in the horizontal direction, the first figure has 64 cycles and the second contains 16. Therefore the frequency of change in the gray levels, namely, the spatial frequency, in the first one is four times larger than that in the second one. Now consider the second image. If we draw a straight line in the horizontal direction one can record the change in the gray levels on this line in the form a graph as in the following: 20

I x Now let us shift the ordinate axis by a quarter of a period in order to make the phase shift zero. 21

I x The Fourier series expansion of I(x) is given as: 1 1 1 I( x) 4( cos x cos3 0x cos50x 3 5 0...) 22

The fundemental period of this waveform is given as: X 0 units cycle It is obvious that X 0 shows a dimension on the image. The fundemental frequency is obtained as: F 0 1 cycle 2 radians / cycle 2 radians 0 X unit X unit / cycle X unit 0 0 0 23

24 Assume that the image has the size 0.256mx0.256m. We can write: 0.256 X 0. 016 0 16 1 cycles F0 62. 5 X m 0 This results in the following: m cycle 125 0 r / 1 1 1 I( x) 4( cos125 x cos 375 x cos 625 x...) 3 5 m

MATLAB program for plotting I(x) with continuous x close all x=0:1/25000:2/62.5; I1=(4/pi)*cos((125*pi)*x);I3=(4/(3*pi))*cos((3*125*pi)*x); I5=(4/(5*pi))*cos((5*125*pi)*x);I7=(4/(7*pi))*cos((7*125*pi)*x); I9=(4/(9*pi))*cos((9*125*pi)*x);I11=(4/(11*pi))*cos((11*125*pi)*x); I13=(4/(13*pi))*cos((13*125*pi)*x);I15=(4/(15*pi))*cos((15*125*pi)*x); I17=(4/(17*pi))*cos((17*125*pi)*x);I19=(4/(19*pi))*cos((19*125*pi)*x); I21=(4/(21*pi))*cos((21*125*pi)*x);I23=(4/(23*pi))*cos((23*125*pi)*x); I25=(4/(25*pi))*cos((25*125*pi)*x);I27=(4/(27*pi))*cos((27*125*pi)*x); I29=(4/(29*pi))*cos((29*125*pi)*x);I31=(4/(31*pi))*cos((31*125*pi)*x); I=I1-I3+I5-I7+I9-I11+I13-I15+I17-I19+I21-I23+I25-I27+I29-I31; figure,plot(i);title( Two periods of I(x) drawn using 31 harmonics'); 25

26

Sampling of I(x) implies the substitution: x nx s where n is an integer and X s represents sampling interval. It is obvious that X s shows a dimension on the image. Sampling of I(x) implies: I( x)] I( nx xnx s s ) 27

White=+1, Black=-1 1 I White=+1, Black=-1 x 128 pixels White=+1, Black=0 I 1 x 28

29 Applying this to the given I(x) we obtain: 1 1 1 I( nx s ) I( n) 4( cos X sn cos30 X sn cos50 X 3 5 Now let us have a closer look at 0 X s. We have already established that: 0 sn 0 X 0 X 2 X s 2 X where X 0 is the fundemental period of this waveform. Now using this in 0 Xs we can write: 0 s 0...)

I( n) 1 X 4( cos 2 X s 0 1 X n cos6 3 X s 0 1 X n cos10 5 X s 0 n...) Now consider the 128x128 pixel image having 16 periods of the square wave in the horizontal direction. In this case The sampling interval is given as: 0.256 X 0. 002 s 128 m sample The fundemental period of the waveform is given as: 30

Hence we obtain: X s which yields 0.256 X 0. 016 0 16 X 0 0.002 0.016 cycle 1 8 m 31 I( n ) 1 4( cos n 4 1 cos3 n 3 4 1 cos5 n 5 4...)

Using F s we have 1 X s samples m 1 F 1 F0 1 F0 I( n) 4( cos 2 n cos6 n cos10 F 3 F 5 F 0 n s and s F 0 1 X 0 cycles m s...) For the above example we get 32 F 1 X samples m F 1 X s 500, 0 62. 5 s 0 cycles m

33 A much simpler approach to determining dimensions on the image is taking the sampling interval as 1 pixel long. In this case all other dimensions are given by the number of pixels that fall into that dimension. In the case of previous example: X s 1pixel 0 It is evident that this ratio decreases as the sampling rate increases,i.e., the number of pixels taken from the image increases. We can make the following MATLAB programs to compute the Fourier series expansion of the horizontal changes in the image for four different values of the sampling rate., X s X 0 8 pixel, X 1 8

MATLAB Program for 128x128 size image, i.e., F s =500samples/m or 8 pixels (samples) per period X 0 close all n=0:1:7 x1=(4/pi)*cos((pi/4)*n); x3=(4/(3*pi))*cos((3*pi/4)*n); x=x1-x3 stem(x1); figure,stem(x3); figure,stem(x);,title('one period of 128x128 size image I(n) '); 34

35

close all n=0:1:7 x1=(4/pi)*cos((pi/4)*n); x3=(4/(3*pi))*cos((3*pi/4)*n); x5=(4/(5*pi))*cos((5*pi/4)*n); x7=(4/(7*pi))*cos((7*pi/4)*n); x9=(4/(9*pi))*cos((9*pi/4)*n); x11=(4/(11*pi))*cos((11*pi/4)*n); x13=(4/(13*pi))*cos((13*pi/4)*n); x15=(4/(15*pi))*cos((15*pi/4)*n); x17=(4/(17*pi))*cos((17*pi/4)*n); x19=(4/(19*pi))*cos((19*pi/4)*n); x21=(4/(21*pi))*cos((21*pi/4)*n); x23=(4/(23*pi))*cos((23*pi/4)*n); y=x1-x3 x=x1-x3+x5-x7+x9-x11+x13-x15+x17-x19+x21-x23 subplot(2,1,1),stem(y); %figure,stem(y);title('one period of 128x128 size image I(n) '); subplot(2,1,2),stem(x); %figure,stem(x);title('one period of 128x128 size image I(n) '); 36

37

MATLAB Program for 256x256 size image, i.e., F s =1000samples/m or 16 pixels (samples) per period close all n=0:1:15 x1=(4/pi)*cos((pi/8)*n); x3=(4/(3*pi))*cos((3*pi/8)*n); x5=(4/(5*pi))*cos((5*pi/8)*n); x7=(4/(7*pi))*cos((7*pi/8)*n); x=x1-x3+x5-x7 stem(x1); figure,stem(x3); figure,stem(x5); figure,stem(x7); figure,stem(x);,title('one period of 256x256 size image I(n) '); 38

39

MATLAB Program for 512x512 size image, i.e., F s =2000samples/m or 32 pixels (samples) per period close all n=0:1:31 x1=(4/pi)*cos((pi/16)*n); x3=(4/(3*pi))*cos((3*pi/16)*n); x5=(4/(5*pi))*cos((5*pi/16)*n); x7=(4/(7*pi))*cos((7*pi/16)*n); x9=(4/(9*pi))*cos((9*pi/16)*n); x11=(4/(11*pi))*cos((11*pi/16)*n); x13=(4/(13*pi))*cos((13*pi/16)*n); x15=(4/(15*pi))*cos((15*pi/16)*n); x=x1-x3+x5-x7+x9-x11+x13-x15 stem(x1); figure,stem(x3); figure,stem(x5); figure,stem(x7); figure,stem(x9); figure,stem(x11); figure,stem(x13); figure,stem(x15); figure,stem(x);,title('one period of 512x512 size image I(n) '); 40

41

MATLAB Program for 1024x1024 size image, i.e., F s =4000samples/m or 64 pixels (samples) per period close all n=0:1:64 x1=(4/pi)*cos((pi/32)*n); x3=(4/(3*pi))*cos((3*pi/32)*n); x5=(4/(5*pi))*cos((5*pi/32)*n); x7=(4/(7*pi))*cos((7*pi/32)*n); x9=(4/(9*pi))*cos((9*pi/32)*n); x11=(4/(11*pi))*cos((11*pi/32)*n); x13=(4/(13*pi))*cos((13*pi/32)*n); x15=(4/(15*pi))*cos((15*pi/32)*n); x17=(4/(17*pi))*cos((17*pi/32)*n); x19=(4/(19*pi))*cos((19*pi/32)*n); x21=(4/(21*pi))*cos((21*pi/32)*n); x23=(4/(23*pi))*cos((23*pi/32)*n); 42

x25=(4/(25*pi))*cos((25*pi/32)*n); x27=(4/(27*pi))*cos((27*pi/32)*n); x29=(4/(29*pi))*cos((29*pi/32)*n); x31=(4/(31*pi))*cos((31*pi/32)*n); x=x1-x3+x5-x7+x9-x11+x13-x15+x17-x19+x21-x23+x25- x27+x29-x31; stem(x1); figure,stem(x3); figure,stem(x5); figure,stem(x7); figure,stem(x9); figure,stem(x11); figure,stem(x13); figure,stem(x15); figure,stem(x); figure,stem(x);title('one period of 1024x1024 size image I(n)'); 43

44

45 close all x=0:1/25000:2/62.5; I1=(4/pi)*cos((125*pi)*x);I3=(4/(3*pi))*cos((3*125*pi)*x); I5=(4/(5*pi))*cos((5*125*pi)*x);I7=(4/(7*pi))*cos((7*125*pi)*x); I9=(4/(9*pi))*cos((9*125*pi)*x);I11=(4/(11*pi))*cos((11*125*pi)*x); I13=(4/(13*pi))*cos((13*125*pi)*x);I15=(4/(15*pi))*cos((15*125*pi)*x); I17=(4/(17*pi))*cos((17*125*pi)*x);I19=(4/(19*pi))*cos((19*125*pi)*x); I21=(4/(21*pi))*cos((21*125*pi)*x);I23=(4/(23*pi))*cos((23*125*pi)*x); I25=(4/(25*pi))*cos((25*125*pi)*x);I27=(4/(27*pi))*cos((27*125*pi)*x); I29=(4/(29*pi))*cos((29*125*pi)*x);I31=(4/(31*pi))*cos((31*125*pi)*x); I=I1-I3+I5-I7+I9-I11+I13-I15+I17-I19+I21-I23+I25-I27+I29-I31; figure,plot(i);title('one period of I(x) drawn using 31 harmonics'); J=I for k = 1:800 J=[J; I]; end figure,mesh(j) figure,imshow(j,[-1.25 1.25]'notruesize')

46

47