18
Digital Image Processing Laboratory Manual( V1.X) Subject Code: CS70X Semester: VII Year: 2014- 15 (Spring Semester) November 11, 2014 Faculty: Mr. Bhaskar Mondal Department of Computer Science and Engineering National Institute of Technology Jamshedpur Jamshedpur, Jharkhand, India- 831014

Dip lab manual

Embed Size (px)

Citation preview

Page 1: Dip lab manual

Digital Image ProcessingLaboratory Manual( V1.X)

Subject Code: CS70X

Semester: VII

Year: 2014- 15 (Spring Semester)

November 11, 2014

Faculty:Mr. Bhaskar Mondal

Department of Computer Science and EngineeringNational Institute of Technology Jamshedpur

Jamshedpur, Jharkhand, India- 831014

Page 2: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

Contents

1 Introduction 21.1 Course description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.4 Books . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.5 Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2 Fundamentals of Mat Lab/ Sci Lab 32.1 Some commands and programs in SCILAB . . . . . . . . . . . . . . . . . . . . . . . 32.2 Flow control in SCILAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.3 Loops in SCILAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3 Point Processing and Pixel Operations 63.1 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

4 Image Arithmetic 74.1 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

5 logical operations on Digital Image 85.1 Watermarking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85.2 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

6 Histogram Calculation and Equalization 96.1 Pseudo code: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96.2 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

7 Geometric Transformation 117.1 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

8 Image Restoration 128.1 Excercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

9 spatial filters 139.1 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

10 Frequency Domain Filtering 1410.1 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

11 morphological operations 1511.1 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

12 wavelet transform 1612.1 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Version: 1.0 Page 1

Page 3: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

1 Introduction

1.1 Course descriptionWe will cover the following topics Digital image fundamentals, Transformation in Spatial Domain,Transformation in Frequency Domain, Restoration and Reconstruction, Color Image Processing, Waveletsand Multi-resolution Processing, Image compression, Morphological Processing, Segmentation.

1.2 ScopeOne picture worth 1000 words!• Support visual communication• Facilitate inspection, diagnosis of complex systems like Human body• Manufacturing• Entertainment• Keep record, history• Managing multimedia information• Security,

– monitoring,– watermarking, etc

1.3 ObjectiveIntroduction to the basic concept and methodology of Digital image Processing like image acquisition,enhancement, color image processing, restoration, compression, morphological processing, segmenta-tion and its use in current systems that handle visual information, including television, photographs,x-rays etc. and further study and research in this field.

1.4 BooksR1 Gonzalez and woods;Digital Image Processing with MatLab, TMH

Evaluation Scheme

ECNo.

EvaluationComponent

Duration WeightageData &Time

Nature ofComponent

1.5 Instructions• Write and execute all programs either in MATLAB or SCILAB.• Do not use standard MATLAB functions whenever specified. Write program yourself without

using standard functions

Version: 1.0 Page 2

Page 4: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

2 Fundamentals of Mat Lab/ Sci LabYou may downlod SCILAB from http://www.scilab.

2.1 Some commands and programs in SCILAB1. Declaring matrices:

In SciLab, there is no need to declare variables; new variables are simply introduced as they arerequired.A = [123; 456; 789]

2. Keep following things in mind while declaring variables/matrices:• No spaces• Don’t start with a number• Variable names are case sensitive

3. Populating matrix elements with zeros:SciLab also provides a number of functions which can be used to populate a new matrix withparticular values. For example to make a matrix full of zeroes we can use the function zeros(m,n) which creates an m*n matrix of zeros as follows:B = zeros(3, 3)

4. Knowing size of matrix:Syntax: [rows, cols] = size(A);Above command gives result: rows=3, cols=3

5. Reading Image filemyImage=imread(‘File name with path’)If name of the image file is test.bmp and if it is in /home/chv folder above commands can bewritten as: myImage=imread(‘/home/chv/test.bmp’)

6. Displaying imageAfter reading image data using above function, we can display images in SciLab using imshowfunction. This function simply takes the array storing the image values as its only parameter.Syntax: imshow(<variable name>) Example: imshow(myImage);

7. Knowing size of image in pixels:Size of the image in pixels can be found out by following command: [Rows, Cols] =size(myImage)

8. Image resizingImage resizing can be done by following command: imresize(Image,Parameters);

imresize(myImage,[256,256],’nearest’); This command will convert image ofany size into image of 256x256 using nearest neighbor technique.

9. Converting Color image into Grayscale image:Color image can be converted into Grayscale image by matlab/scilab function rgb2gray. Exam-ple: myGrayImage=rgb2gray(myImage)

10. Converting Color image into Binary Image:Color image can be converted into Binary image using function im2bw: Example: myBWImage=im2bw(myImage)Where myImage is 2D image data.

11. Intensity profile along line given by two points on imageDrawing of intensity profile along single line on given image (Scan one line along the image anddraw intensity values (1-D signal)) can be done by function improfile()

Version: 1.0 Page 3

Page 5: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

Example: improfile(myImage,[0,150],[200,150]); If given image is chess-boardpattern, profile graph would be square wave.

12. Separate color image into three separate R,G,B planesIf we read given color image using imread() function, we get 3-D matrix. To separate out R,Gand B planes, we can read each plane separately as follows:Example: myImage=imread(‘RGBBar.bmp’);RED=myImage(:,:,1);GREEN=myImage(:,:,2);BLUE=myImage(:,:,3);

13. Combine three separate R,G,B planes to create color imageIf we have three R,G and B planes separately and if we want to create color image from it, wecan use concatenate function: Example: newImage=cat(3,RED,BLUE,GREEN)

2.2 Flow control in SCILABIf statements are simply used to make decisions in SciLabSyntax:if <condition> then<do some work>else<do some other work>endIf we wish to perform thresholding of an image we could use following statements in SCILAB Pro-gram: if ImageData(r, c) > threshold thenThresholdedImage(r, c) = 255;elseThresholdedImage(r, c) = 0;end

2.3 Loops in SCILABThere is for loop and while loop in SCILAB. While loop While loop repeat a piece of work as long asa condition holds true. The while loop in SciLab uses the following syntax: while <condition><perform some work repeatedly...>endFor loop in SCILAB is very popular for image processing because it is particularly useful for iteratingthrough the members of a matrix. The SCILAB for loop uses the following syntax: for index =<start>:<finish><Perform some work...>endExample: Following SCILAB code iterates through each pixel of image, does summation of pixelvalues, finds average pixel value which represents average brightness of the scene.myImage=imread(‘/home/chv/test.bmp’)

Rows, Cols= size(myImage)total = 0;for rowIndex = 1:Rowsfor colIndex = 1:Colstotal = total + ImageData(rowIndex, colIndex);

Version: 1.0 Page 4

Page 6: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

endendaverage=total/(Rows*Cols)

1. Saving two dimensional matrix in Image file imwrite(ImageData, ’ Testout.bmp’,’bmp’);This command writes ImageData in file “Testout.bmp”. It also supports ‘gif’, ‘jpg’ and ‘png’file formats.

2. Create image of size 512x512 black square using monochrome, 256 gray-level using paint orany other relevant software and save it file name “black.bmp” Read and display image usingSCILAB/MATLAB commands

3. Write MATLAB command for the following(a) Read color image ‘RGBBar.bmp’ given in working directory, convert it into Grey-scale

image.(b) Read color image ‘RGBBar.bmp’ given in working directory, Find size of the image, Resize

it to 256× 256

Version: 1.0 Page 5

Page 7: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

3 Point Processing and Pixel Operations1. Obtain Negative image2. Obtain Flip image3. Threshold operation (Thresholding)4. Contrast stretchingIntroduction: Image enhancement can be done in two domain: Spatial Domain and Transform

domain. In Spatial domain Image processing, there are two ways:• Point processing (Single pixel is processed at a time)• Neighborhood processing (Mask processing) Convolution of 3× 3 or 5× 5 or other size of mask

with imageIn point processing, Grey level transformation can be given by following equation

g(x, y) = T (f(x, y))→ s = T (r) (1)

Where, f(x, y) is original image, g(x, y) is transformed image s = gray level of transformed imager = gray level of original image.Threshold operation: In threshold operation, Pixel value greater than threshold value is made whiteand pixel value less than threshold value is made black.

s = 0ifr ≤ m (2)s = 255ifr > m (3)

Where m = thresholdThresholding Scan any document and use this method to make it clean

3.1 Exercise1. You may scan your own signature and make it clean with thresholding)

2. Run above program for different threshold values and find out optimum threshold value for whichyou are getting better result. filename=input(’Enter file name: ’,’s’);y=imread(filename);T=input(’Enter threshold value between 0 to 255: ’);if(ndims(y)==3)y=rgb2gray(y);endm,n=size(y);imshow(y);for i=1:mfor j=1:nif(y(i,j)>T)y(i,j)=255;elsey(i,j)=0;endendend

Version: 1.0 Page 6

Page 8: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

figure;imshow(y);

3. Write a program for Flip given image horizontally4. Modify program of horizontal flipping for getting vertical flipping. Apply it on some image5. In contrast stretching program take threshold values 50 and 100, Use slope 3 for gray levels

between 0 to 50, slope 2 for gray levels between 50 to 100 and slope 1 for rest gray levels.Modify and write program again. Execute it for some image.NOTE: Contrast Stretching means Darkening level below threshold value m and whitening levelabove threshold value m. This technique will enhance contrast of given image. Thresholding isexample of extreme constrast stretching.

4 Image ArithmeticIntroduction: Arithmetic operations like image addition, subtraction, multiplication and division ispossible. If there is two images I1 and I2 then addition of image can be given by:I(x,y) = I1(x,y) + I2(x,y)

Where I(x, y) is resultant image due to addition of two images. x and y are coordinates of image.Image addition is pixel to pixel. Value of pixel should not cross maximum allowed value that is 255for 8 bit grey scale image. When it exceeds value 255, it should be clipped to 255. To increase overallbrightness of the image, we can add some constant value depending on brightness required. In exampleprogram we will add value 50 to the image and compare brightness of original and modified image.

To decrease brightness of image, we can subtract constant value. In example program, value 100 issubtracted for every pixel. Care should be taken that pixel value should not less than 0 (minus value).Subtract operation can be used to obtain complement (negative) image in which every pixel is sub-tracted from maximum value i.e. 255 for 8 bit greyscale image.

Multiplication operation can be used to mask the image for obtaining region of interest. Black andwhite mask (binary image) containing 1s and 0s is multiplied with image to get resultant image. Toobtain binary image function im2bw() can be used.

Multiplication operation can also be used to increase brightness of the image.

Division operation results into floating point numbers. So data type required is floating pointnumbers. It can be converted into integer data type while storing the image. Division can be usedto decrease the brightness of the image. It can also used to detect change in image.

Calculate mean value: Mean value can be calculated by MATLAB function mean()

4.1 Exercise1. Write Program to read any image, resize it to 256× 256. Apply square mask shown in following

figure so that only middle part of the image is visible.2. Write your own matlab function addbrightness() and use it to increase brightness of given image.

Version: 1.0 Page 7

Page 9: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

5 logical operations on Digital ImageIntroduction: Bitwise logical operations can be performed between pixels of one or more than oneimage.

AND/NAND Logical operations can be used for following applications:

• Compute intersection of the images• Design of filter masks• Slicing of gray scale images

OR/NOR logical operations can be used for following applications:• Merging of two imagesXOR/XNOR operations can be used for following applications:• To detect change in gray level in the image• Check similarity of two images

NOT operation is used for:• To obtain negative image• Making some features clear

5.1 WatermarkingWatermarking using EX-OR operation:To provide copy protection of digital audio, image and video two techniques are used: encryption andwatermarking.

Encryption techniques normally used to protect data during transmission from sender to receiver.Once data received at receiver, it is decrypted and data is same as original which is not protected.

Watermarking techniques can compliment encryption by embedding secret key into original data.Watermarking can be applied to audio, image or video data. Watermarking technique used for canbe visible or non-visible. For visible watermarking technique, watermark image is visible on originalimage in light form. In non-visible watermarking technique, watermark image is hidden inside originalimage.

In digital watermarking, watermarking key bits are scattered in the image and cannot be identified.There are so many techniques being developed for secure and robust watermarking. Watermarkingusing EX-OR operation is simplest technique.

5.2 Exercise1. Write a program to demonstrate watermarking using EX-OR operation.2. Prepare any two images of size 256 × 256 in paint. Save it in JPEG format 256 gray levels.

Perform logical NOR, NAND operations between two images. Write program and paste yourresults.

Version: 1.0 Page 8

Page 10: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

6 Histogram Calculation and EqualizationIntroduction: Histogram is bar-graph used to profile the occurrence of each gray level in the image.Mathematically it is represented as h(rk) = nk Where rk is kth grey level and nk is number of pixelhaving that Grey level.

Histogram can tell us whether image was scanned properly or not. It gives us idea about tonaldistribution in the image.

Histogram equalization can be applied to improve appearance of the image.

Histogram also tells us about objects in the image. Object in an image have similar gray levels sohistogram helps us to select threshold value for object detection.

Histogram can be used for image segmentation.

6.1 Pseudo code:Calculate histogram:Loop over ROWS of the image i = 1 to rowsLoop over COLS of then image j = 1 to colsPixel value k = data(i, j)hist(k) = hist(k) + 1End COLS loopEnd ROWS loopCalculate sum of the hist:Loop over gray levels i = 0 to no. of gray levelssum = sum+ hist(i);sumofhist(i) = sum;End loopArea of image = rows× colsDm=Number of gray levels in the output imageLoop over ROWSLoop over COLSk = data(i, j)data(i, j) = (Dm/area)× sumofhist(k)End COLS loopEnd ROWS Loop

Standard MATLAB function for histogram and histogram equalization:

• imhist function computes histogram of given image and plotExample: myimage=imread(’tier.jpg’)imhist(myimage);• histeq function computes histogram and equalize it.

Version: 1.0 Page 9

Page 11: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

6.2 Exercise1. Write a program to compute the histogram of an input image2. Program for calculation and equalisation of the histogram3. Take your own photograph in dark area. Improve its appearance using histogram equalization

technique.

Version: 1.0 Page 10

Page 12: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

7 Geometric Transformation• Translation: Translation is movement of image to new position.• Scaling: Scaling means enlarging or shrinking. Mathematically scaling can be represented by:• Rotation: Image can be rotated by an angle , in matrix form it can be represented as:• Zooming : zooming of image can be done by process called pixel replication or interpolation.

Linear interpolation or some non-linear interpolation like cubic interpolation can be performedfor better result.

Matlab functions:• To rotate given image using standard Matlab function imrotate()• To transform image using standard Matlab function imtransform()

7.1 Exercise1. In above program, modify matrix for geometric transformation and use imtransform() function

for modified matrix. Show the results and your conclusions.2. Write and execute program for geometric transformation of image

(a) Translation(b) Scaling(c) Rotation(d) Shrinking(e) Zooming

Version: 1.0 Page 11

Page 13: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

8 Image RestorationIntroduction: Image restoration is the process of removing or minimizing known degradations in thegiven image. No imaging system gives perfect quality of recorded images due to various reasons.

Image restoration is used to improve quality of image by various methods in which it will try todecrease degradations noise. Degradation of images can occur due to many reasons. Some of themare as under:• Poor Image sensors• Defects of optical lenses in camera• Non-linearity of the electro-optical sensor;• Graininess of the film material which is utilised to store the image• Relative motion between an object and camera• Wrong focus of camera• Atmospheric turbulence in remote sensing or astronomy• Degradation due to temperature sensitive sensors like CCD• Poor light levels

Degradation of images causes:• Radiometric degradations;• Geometric distortions;• Spatial degradations.

Model of Image Degradation/restoration Process is shown in the following figure.• Spatial domain: g(x, y) = h(x, y) ∗ f(x, y) + (x, y)• Frequency domain: G(u, v) = H(u, v)F (u, v) +N(u, v)

G(x,y) is spatial domain representation of degraded image and G(u,v) is frequency domain represen-tation of degraded image. Image restoration applies different restoration filters to reconstruct image toremove or minimize degradations.

8.1 Excercise1. To add noise in the image and apply image restoration technique using Wiener filter and median

filter2. Explain algorithm used in Median filter with3. Write mathematical expression for arithmetic mean filter, geometric mean filter, harmonic mean

filter and contra-harmonic mean filter4. What is the basic idea behind adaptive filters?5. To understand various image noise models write programs for image restoration

(a) Remove Salt and Pepper Noise(b) Minimize Gaussian noise(c) Median filter and Weiner filter

6. Write and execute programs to remove noise using spatial filters(a) Understand 1-D and 2-D convolution process(b) Use 3x3 Mask for low pass filter and high pass filter

7. Write a program to image restoration using the parametric wiener filter

Version: 1.0 Page 12

Page 14: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

9 spatial filtersIntroduction: Spatial Filtering is sometimes also known as neighborhood processing. Neighborhoodprocessing is an appropriate name because you define a center point and perform an operation (or ap-ply a filter) to only those pixels in predetermined neighborhood of that center point. The result of theoperation is one value, which becomes the value at the center point’s location in the modified image.Each point in the image is processed with its neighbors. The general idea is shown below as a ”slidingfilter” that moves throughout the image to calculate the value at the center location.

In spatial filtering, we perform convolution of data with filter coefficients. In image processing, weperform convolution of 3x3 filter coefficients with 2-D image data. In signal processing, we performconvolution of 1-D data with set of filter coefficients.

9.1 Exercise1. Program for 1D convolution (Useful for 1-D Signal Processing):2. Program for 2D convolution:3. Spatial filtering using standard MATLAB function To apply spatial filters on given image4. Write mathematical expression of spatial filtering of image f(x,y) of size MN using mask W of

size ab.5. What is need for padding? What is zero padding? Why it is required?6. What is the effect of increasing size of mask?7. Write a program for zooming and shrinking image by Pix replication.8. Write a program for zooming and shrinking image by Bilinear Interpolation9. Write a program to perform a special filtering of an image by taking different size of mask.

Version: 1.0 Page 13

Page 15: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

10 Frequency Domain FilteringIntroduction: In spatial domain, we perform convolution of filter mask with image data. In frequencydomain we perform multiplication of Fourier transform of image data with filter transfer function.

Basic steps for filtering in frequency domain:1. Pre-processing: Multiply input image f(x,y) by (-1)x+y to center the transform2. Computer Discrete Fourier Transform F(u,v) of input image f(x,y)3. Multiply F(u,v) by filter function H(u,v) Result: H(u,v)F(u,v)4. Computer inverse DFT of the result5. Obtain real part of the result6. -Processing: Multiply the result by (−1)x+ y

10.1 Exercise1. Write and execute programs for image frequency domain filtering

(a) Apply FFT on given image(b) Perform low pass and high pass filtering in frequency domain(c) Apply IFFT to reconstruct image

To write and execute program for wavelet transform on given image and perform inverse wavelettransform to reconstruct image.

Version: 1.0 Page 14

Page 16: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

11 morphological operationsMorphology is a branch of biology that deals with form and structure of animal and plant. In im-age processing, we use mathematical morphology to extract image components which are useful inrepresentation and description of region shape such as Boundaries, Skeletons, Convex hull, Thinning,Pruning etc.

Two Fundamental morphological operations are: Erosion and dilation• Dilation adds pixels to the boundaries of objects in an image, while erosion removes pixels on

object boundaries.• Erosion and dilation are two fundamental image morphological operations. Dilation adds pixels

to the boundaries of objects in an image, while erosion removes pixels on object boundaries.Dilation operation: The value of the output pixel is the maximum value of all the pixels in the

input pixel’s neighborhood. In a binary image, if any of the pixels is set to the value 1, the output pixelis set to 1.

Erosion operation: The value of the output pixel is the minimum value of all the pixels in theinput pixel’s neighborhood. In a binary image, if any of the pixels is set to 0, the output pixel is set to0.

Opening and closing operations can be done by combination of erosion and dilation in differentsequence.

11.1 Exercise1. Program to demonstrate Erosion and Dilation2. Write a program in C and MATLAB/SCILAB for edge detection using different edge detection

mask3. Write and execute program for image morphological operations erosion and dilation.4. Implement Morphological smoothing using opening and closing

Version: 1.0 Page 15

Page 17: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

12 wavelet transformWavelet transform is relatively recent signal and image processing tool which has many applications.Basis functions of Fourier transform is sinusoids while basis functions of wavelet transform is wavelets.• Wavelets are oscillatory functions vanishing outside the small interval hence, they are called

wavelets. wave-let (small fraction of wave).• Wavelets are building blocks of the signal.• Wavelets are the functions which are well suited to the expansion of real time non-stationary

signals.• Wavelets can be used to de-correlate the correlations present in real time signal such as speech/audio,

video, biomedical, seismic etc.Following standard matlab functions are used in this experiment.• wavedec2 : Function for multi-level decomposition of 2D data using wavelet transform.[C,S] = WAVEDEC2(X,N,’wname’) returns the wavelet decomposition of the matrix Xat level N, using the wavelet named in string ’wname’ (wavelet name can be Daubechies waveletdb1, db2, db3 or any other wavelet).Outputs are the decomposition vector C and the corresponding bookkeeping matrix S. N is levelof decomposition which must be positive integer.• appcoef2: This function utilize tree developed by wavelet decomposition function and constructs

approximate coefficients for 2D data.A = APPCOEF2(C,S,’wname’,N) computes the approximation coefficients at level N us-ing the wavelet decomposition structure [C,S] which is generated by function wavedec2.• detcoef2: This function utilize tree develet by wavelet decomposition function and generates

detail coefficients for 2D data. D = DETCOEF2(O,C,S,N) extracts from the wavelet de-composition structure [C,S], the horizontal, vertical or diagonal detail coefficients for O = ’h’ or’v’ or ’d’, for horizontal, vertical and diagonal detail coefficients respectively.• waverec2: Multilevel wavelet 2D reconstruction (Inverse wavelet transform), WAVEREC2 per-

forms a multilevel 2-D wavelet reconstruction using wavelet named in string ’wname’ (waveletname can be Daubechies wavelet db1, db2, db3 or any other wavelet).X = WAVEREC2(C,S,’wname’) reconstructs the matrix X based on the multilevel waveletdecomposition structure [C,S] which is generated by wavedec2

12.1 Exercise1. Write analysis low pass and high pass wavelet filter coefficients for Daubechies-2,4 and 8 wavelets.

(Hint: use matlab function wfilters() to find filter coefficients)2. Write a program to image segmentation based on region growing approach

Version: 1.0 Page 16

Page 18: Dip lab manual

Faculty: Bhaskar Mondal, Email:[email protected] Digital Image Processing Lab. Manual

You May Meet Me:Every day 5:00pm.You may mail me at [email protected]; (always mention your Roll Number followed by Subject atthe subject field.)

Version: 1.0 Page 17