DIGITAL IMAGE PROCESSING

Download For Human Perception. ▫ To make images more beautiful or understandable. ➢ Automatic Perception of Image. ▫ We call it Machine Vision, Comp...

0 downloads 610 Views 856KB Size
COURSE – ECE-411 IMAGE PROCESSING Er. DEEPAK SHARMA Asstt. Prof., ECE department. MMEC, MM University, Mullana.

Why Image Processing?  For Human Perception  To make images more beautiful or understandable  Automatic Perception of Image  We call it Machine Vision, Computer Vision, Machine Perception, Computer Recognition  For Storage and Transmission  smaller, faster, more effective  Image Processing for New Image Generation (New trends)  Computer Graphics introduced Image Processing and Computer Vision technologies ECE-411 (Image Processing)

The Electromagnetic Spectrum  Images based on radiation from the EM spectrum  EM : wave stream of mass less particles  Each particle contains energy

ECE-411 (Image Processing)

Example: a cell  Image of a cell corrupted by electronic noise.

 Result after averaging several noisy images (a common technique for noise reduction)

ECE-411 (Image Processing)

Example: an x-ray  An original x-ray image

 Result possible after contrast and edge enhancement

ECE-411 (Image Processing)

Example: image deblurring  Image of a human face blurred by uniform motion during exposure.

 Resulting image after application of a deblurring algorithm

ECE-411 (Image Processing)

Simple Image Model  Monochrome image (or simply image) refers to a 2dimensional light intensity function f(x,y).  x and y denote spatial coordinates  the value of f(x,y) at (x,y) is proportional to the brightness (or gray level) of the image at that point.

ECE-411 (Image Processing)

Simple image formation  f(x,y) = i(x,y)*r(x,y)  0 < i(x,y) < ∞ ; illumination or intensity of incident light  0 < r(x,y) < 1 ; reflectance or reflectivity of object.

 In real situation  Lmin ≤ f(x,y)) ≤ Lmax

ECE-411 (Image Processing)

Why Digital?  Unification of processing  Computers is at the center of information processing  Digital information is just right form for computer processing  Text, Image, Sound, Movie, and other Multimedia are digitized into computer  Noise reduction  Digital processing reduces noises  Guarantee the same quality regardless of time and place  Easy storage  Since the same form is used for every information, it can be stored in H/D, CD, DVD, Flash memory, etc.  Transmission  Less Bandwidth ECE-411 (Image Processing)

Digital image  A digital image is an image f(x,y) that has been discretized both in spatial coordinates and in brightness.  Considered as a matrix whose row and column indices represent a point in the image.  The corresponding matrix element value represents the gray level at that point.  The elements of such an array are referred to as:  image elements or picture elements (pixels or pels)

ECE-411 (Image Processing)

ECE-411 (Image Processing)

Digital Image Processing  The field of digital image processing refers to processing digital images by using computers.  Image processing is a branch in which both the input and output of a process are images.  The goal of computer vision is to use computers to emulate human vision, including learning, making inferences and taking actions.  The area of image analysis is in between image processing and computer vision.

ECE-411 (Image Processing)

Types of Processes in Image Processing  There are 3 types of computerized processes.  Low level processes  mid level processes and  high level processes.  Low-level processes involve primitive operations such as image preprocessing to reduce noise, contrast enhancement and image sharpening.  Here both the input and output are images.

 Mid-level processing involves segmentation (partitioning image into regions), description of objects to reduce them to a form so that a computer can process and classification (recognition) of objects.  Here inputs are images but outputs are attributes extracted from images. ECE-411 (Image Processing)

 In high-level processing, we ‘make sense’ of a collection of recognized objects.  The process of acquiring an image of a text, processing it, extracting (segmenting) individual characters, describing characters suitable for computer processing and recognizing those individual characters are in the scope of digital image processing.  Making sense of the content of the page (text) is viewed as the domain of image analysis and computer vision. ECE-411 (Image Processing)

Fundamental steps in Digital Image Processing  Image acquisition  Image enhancement  Image Restoration  Color Image Processing  Image Compression  Morphological Processing  Image Segmentation  Representation and description  Recognition ECE-411 (Image Processing)

Fundamental steps in Digital Image Processing

ECE-411 (Image Processing)

Steps in an image processing system  Image acquisition  This stage involves preprocessing, such as scaling.  Acquire a digital image using an image sensor  In detail, devices that are sensitive to energy(electromagnetic, sound, … )  If not digital, an analog-to-digital conversion process is required  The nature of the image sensor (and the produced image) are determined by the application  In general, CCD(charge-coupled device) or CMOS sensors are widely used  Examples : Digital camera, Video camera, Scanner, .. ECE-411 (Image Processing)

CCD (Charged-Coupled Device) cameras  Tiny solid state cells convert light energy into electrical charge.  The image plane acts as a digital memory that can be read row by row by a computer.

ECE-411 (Image Processing)

Steps in an image processing system 

Image enhancement – Here we bring out details that were obscured or highlight some features of interest in an image. (eg) increasing the contrast of an image.



Image Restoration – Here we talk about how to improve the appearance of an image. Unlike enhancement, which is subjective, this is objective.



Color Image Processing – Due to Internet, this area is becoming popular. Various color models are worthy to know.



Wavelets – Representing the images in various degrees of resolution in the basis of wavelets. ECE-411 (Image Processing)

Steps in an image processing system 

Compression – It is a technique for reducing the storage required to save an image or bandwidth needed to transmit.



Morphological Processing – It deals with tools for extracting image components that are useful in the representation and description of shape.

ECE-411 (Image Processing)

Steps in an image processing system  Segmentation     

Broadly defined: breaking an image into its constituent parts In general, one of the most difficult tasks in image processing Good segmentation simplifies the rest of the problem Poor segmentation make the task impossible Output is usually raw pixel data: may represent region boundaries, points in the region itself, etc.  Boundary representation can be useful when the focus is on external shape characteristics (e.g. corners, rounded edges, etc.)  Region representation is appropriate when the focus is on internal properties

ECE-411 (Image Processing)

Steps in an image processing system  Representation & description  Representation: transforming raw data into a form suitable for computer processing  Description (also called feature extraction) deals with extracting features that result in some quantitative information of interest or features which are basic for differentiating one class of objects from another  In terms of character recognition, descriptors such as lakes (holes) and bays help differentiate one part of the alphabet from another

ECE-411 (Image Processing)

Steps in an image processing system  Recognition & Interpretation  Recognition: The process which assigns a label to an object based on the information provided by its descriptors  may be the alphanumeric character A  Interpretation: Assigning meaning to an ensemble of recognized objects.  35487-0286 may be a ZIP code

ECE-411 (Image Processing)

The knowledge base • Knowledge about a problem domain is coded into an image processing system in the form of a knowledge database  May be simple:  detailing areas of an image expected to be of interest  May be complex  A list of all possible defects of a material in a vision inspection system  Guides operation of each processing module  Controls interaction between modules  Provides feedback through the system ECE-411 (Image Processing)

Steps in an image processing system  Not all image processing systems would require all steps/processing modules  Image enhancement for human visual perception may not go beyond the preprocessing stage  A knowledge database may not be required  Processing systems which include recognition and interpretation are associated with image analysis systems in which the objective is autonomous (or at least partially automatic)

ECE-411 (Image Processing)

Components of an Image Processing System

ECE-411 (Image Processing)

Basic components of a general-purpose system used for digital image processing 

Image sensors – Two elements are needed to acquire digital images.   

First one is the physical device that is sensitive to energy radiated by the object that we want to image. The second one, called the digitizer, is a device for converting the output of the physical sensing device into digital form. Ex. - in a digital video camera, the sensors produce an electrical output proportional to light intensity.

ECE-411 (Image Processing)

Basic components of a general-purpose system used for digital image processing 

Specialized Image Processing Hardware  It consists of digitizer plus hardware that performs other primitive operations such as an arithmetic logic unit (ALU), which performs arithmetic and logical operations on entire image.  This type of hardware is also called as front-end subsystem and its characteristic is speed.  This unit does things that require fast data throughputs which main computer cannot handle.  Computer – In an image processing system it is a generalpurpose computer. 

Software – It consists of specialized modules that does specific tasks (eg. matlab) ECE-411 (Image Processing)

Basic components of a general-purpose system used for digital image processing    

   

Mass storage – An image of 1024 X 1024 size, storing the intensity of each pixel in 8 bits, requires one megabyte of storage. For short-time storage, we can use computer memory. Another method is to use a specialized board called frame buffer, that store one or more images and can be accessed rapidly. They enable us to instantaneously zoom, scroll (vertical shift) and pan (horizontal shift). For on-line storage magnetic disks or optical-media are used. The archival storage needs massive capacity but are accessed infrequently. Image Displays – These are mainly color TV monitors. Hardcopy – These ECE-411 devices include laser printers, film (Image Processing) cameras, inkjet units, etc.

Sampling & Quantization  Image sampling  Digitization of spatial coordinates (x,y)  Quantization  Amplitude digitization  The quality of a digital image is determined to a large degree by the number of samples and discrete gray levels used in sampling and quantization

ECE-411 (Image Processing)

Sampling & Quantization

ECE-411 (Image Processing)

ECE-411 (Image Processing)

The intensity variation sampled at regular intervals along the scan line 300

250

200

150

100

50

0

10

20

30

40

50

60

ECE-411 (Image Processing)

70

80

90

100

Four level intensity quantization of sampled scan line 260 240 220 200 180 160 140 120 100 80 60

0

10

20

30

40

50

60

ECE-411 (Image Processing)

70

80

90

100

Formulation of Digital Image

ECE-411 (Image Processing)

ECE-411 (Image Processing)

Image Resolution Spatial Resolution (x,y)  Spatial resolution is the smallest discernible detail in an image  A line pair : a line and its adjacent space  A widely used definition of resolution is the smallest number of discernible line pairs per unit distance .  Ex: 100 line pairs/mm  But, unit distance or unit area is omitted in most cases ECE-411 (Image Processing)

Spatial Resolution

ECE-411 (Image Processing)

Image Resolution(Cont..)  Gray-level Resolution  Gray-level resolution is the smallest discernible change in gray level (but, highly subjective!)  Due to hardware considerations, we only consider quantization level  Usually an integer power of 2. The most common level is 28=256  However, we can find some systems that can digitize the gray levels of an image with 10 to 12 bits of accuracy.

ECE-411 (Image Processing)

Gray-level Resolution

ECE-411 (Image Processing)

Storage  For MxN image with L(=2k) discrete gray level  The number, b, of bits required to store the image is

b = M*N*k bits  Ex1: 1024x1024x8bit = 1Mbytes

 Common image file formats      

GIF (Graphic Interchange Format) PNG (Portable Network Graphics) JPEG (Joint Photographic Experts Group) TIFF (Tagged Image File Format) PGM (Portable Gray Map) FITS (Flexible Image Transport System) ECE-411 (Image Processing)

Overview of MATLAB Data Types Data Types

Logical (0 or 1)

Char

Numeric

Integer

Signed

Unsigned

Function handling

Structure

Fraction

Single

Double

Cell or Array

Overview of MATLAB Data Types  Data types in MATLAB  Double (64-bit double-precision floating point)  Single (32-bit single-precision floating point)  Int32 (32-bit signed integer)  Int16 (16-bit signed integer)  Int8 (8-bit signed integer)  Uint32 (32-bit unsigned integer)  Uint16 (16-bit unsigned integer)  Uint8 (8-bit unsigned integer)

Image types  x(m,n) = 0 or 1: binary image  x(m,n) = 0, 1, 2, … P-1: grayscale image  P typically something like 256, 512 or some power of 2.  256 is really the most common  0 = black, P = white  x(m,n) = [0 to P-1, 0 to P-1, 0 to P-1]  Red, green, blue color image  Like three grayscale images  x(m,n) = index into color map.  Color map = three column table with all possible colors  Image index says which row in that table gives RBG valuesfor that pixel  So long as table is known, very easy to store indices

Image Type

Difference between Indexed Image and RGB Image Indexed Image

RGB Image

Important MATLAB commands      

imread: Read an image figure: creates a figure on the screen. imshow(g): which displays the matrix g as an image. pixval : turns on the pixel values in our figure. impixel(i,j): the command returns the value of the pixel (i,j) iminfo: Information about the image.

Converting between Data classes and Image types  Converting between data classes  Converting between Image classes to data classes  Converting between Image classes Note : When converting between data classes, it is important to keep in mind the value range for each data classes should be in range.

Converting between data classes  General syntax for converting data classes  A = given data class  B = data class in which we want to convert A B = data_class(A)  Ex : A in uint8 and we want to convert in to double, then  B = double(A)

Converting between data classes • Ex 1:double to unsigned integer of 8 bit A= 34.6500 >> B =uint8(A) B= 35

Converting between data classes  Ex 2 : Double to unsigned integer of 8 bit A= 265.7800 >> B = uint8(A) B= 255 >> C = -2.76 C= -2.7600 >> D = uint8(C) D= 0 Note : Here range of unsigned integer of 8 bits is [0 255]

Converting between data classes    

Rule for conversion Convert to ‘0’ all the values are less than ‘0’. Convert to 255 all the values are greater than 255 Convert numbers between 0-255 to corresponding integer values. E.g.: 5.8 convert into 6

Converting between Image classes to data classes  Conversion should perform necessary scaling for the toolbox to recognize the data as valid image data.  Ex: im2uint8  Function set all the value less than 0 to 0  And set 1 all the value those are greater than 1  Now image range is in [0 1]  Multiplies 255 to all values and round off to integer.  Now range is in [0 255]

Converting between Image classes to data classes  Ex 3: image of class double to unsigned integer 8 f= 1.4897 0.6715 1.6302 1.4090 -1.2075 0.4889 1.4172 0.7172 1.0347 >> g=im2uint8(f) g= 255 171 255 255 0 125 255 183 255

 Ex 4: unsigned integer8 to double >> h = uint8(h) h= 26 67 12 212 156 178 23 45 67 >> g = im2double(h) g= 0.1020 0.8314 0.0902

0.2627 0.0471 0.6118 0.6980 0.1765 0.2627

 Ex 4:  Function im2double convert input image to double format in range [0 1].  Divide all values by 255 (in case of uint8, if uint16 than divide by 65535)  Range of image in double format must be [0 1]  Function mat2gray convert any matrix to gray image of double data class.

 Ex 5 : any matrix to image h= 26 67 12 212 156 178 23 45 67 >> g = mat2gray(h) g= 0.0700 0.2750 0 1.0000 0.7200 0.8300 0.0550 0.1650 0.2750

Ex 6 : any matrix to binary image using threshold 0.6 h= 26 67 12 212 156 178 23 45 67 >> g = mat2gray(h) g= 0.0700 0.2750 0 1.0000 0.7200 0.8300 0.0550 0.1650 0.2750

>> g=im2bw(h,0.6) g= 0 0 0 1 1 1 0 0 0

 Ex 6:  Function im2bw(f,T) convert any image into binary image with threshold T.  All the values less than T are set to 0  All the values greater than T are set to 1  First all values are converted into double and than threshold is applied.

Some important function function

convert input into

Valid input Image data class

im2uint8

uint8

Logical,uint8,uint16 and double

im2uint16

uint16

Logical,uint8,uint16 and double

mat2gray

double (in range [0,1])

Logical,uint8,uint16 and double

im2double

double

Logical,uint8,uint16 and double

im2bw

logical

uint8,uint16 and double

Converting between Image classes     

Important function gray2ind - intensity image to index image ind2gray - indexed image to intensity image rgb2gray - RGB image to grayscale rgb2ind - RGB image to indexed image

Ex 7: rgb image to gray >> f = imread('lenna.png'); >> g = rgb2gray(f); >> subplot(1,2,1);imshow(f); >>subplot(1,2,2);imshow(g);

Array Indexing  MATLAB support many powerful indexing scheme that simplifying array manipulation and improve the efficiency of program.  For image processing toolbox  Vector indexing  Matrix indexing  Images are represented in matrix.

Vector Indexing • • • •

Array of dimension 1xn : row vector Array of dimension nx1 : column vector First element will start from 1 not from 0 (zero) Ex: consider following vector v = [3 8 2 7 5 9 1 4] Different commands for vector indexing 1. v(3) = [3 8 2 7 5 9 1 4] = 2 % to access 3rd element 2. V’ = produce column vector of “v” Note : transpose operator (.‘)

Vector Indexing(cont.) 3. 4. 5. 6. 7.

v(1:3) produce element from index 1 to 3 v(1:3) = [3 8 2 7 5 9 1 4] = 3 8 2 v(3:5) = [3 8 2 7 5 9 1 4] = 2 7 5 v(end) = [3 8 2 7 5 9 1 4] = 4 % to access last element of array v(5:end) = [3 8 2 7 5 9 1 4] = 5 9 1 4 % to access 5th to last element v(: ) = produce column matrix

8. 9.

V(1:2:end) = [3 8 2 7 5 9 1 4] = 3 2 5 1 V([1 4 7]) = [3 8 2 7 5 9 1 4] = 3 7 1

Note : index 1:2:end means start from 1 count up by 2 and end with last element. Steps can be negative, Ex.: V(end:-2:1) = [3 8 2 7 5 9 1 4] = 3 2 5 1 Start with last element count down by 2 and end with first element

Matrix indexing  Matrix can be written in MATLAB >> A= [1 2 3; 4 5 6; 7 8 9] A= 1 2 3 4 5 6 7 8 9 >> size(A) ; % to find dimention of matrix 3 3

Matrix indexing(cont..)  Examples for matrix indexing 1. To extract element of 3rd row ,2 column A= 1 2 3 4 5 6 7 8 9 A(3,2) = 8 Note : general format is A(row, column)

2. To extract all element from 2nd row A(2,:) = 4 5 6 3. To extract all element from 3rd column A(:,3) = 3 6 9 4. to fetch top 2 row A(1:2,1:3) = 1 2 3 4 5 6 Same for to fetch last 2 column A(1:3, 2:3)