Fundamentals of Image Processing Lab Manual 2014.pdf

April 2, 2018 | Author: Retheesh Raj | Category: Matrix (Mathematics), Matlab, Control Flow, Wavelet, Image Processing


Comments



Description

Fundamentals ofImage Processing Laboratory Manual Enrollment No. _______________ Name of the student:_________________________________ Government Engineering College, Rajkot GOVERNMENT ENGINEERING COLLEGE, RAJKOT CERTIFICATE This is to certify that Mr/Miss ____________________________________Enrollment No. _____________ of B.E. (E.C.) SEM-VIII has satisfactorily completed the term work of the subject Fundamentals of Image Processing prescribed by Gujarat Technological University during the academic term January-2014 to April-2014. Date: Signature of the faculty SET 1 completed on ________________ SET 2 completed on _________________ Lab Manual of Fundamentals of Image Processing Page 2 List of Experiments Sr. No. 1. 2. Name of Experiment Write program to read and display digital image using MATLAB or SCILAB  Become familiar with SCILAB/MATLAB Basic commands  Read and display image in SCILAB/MATLAB  Resize given image  Convert given color image into gray-scale image  Convert given color/gray-scale image into black & white image  Draw image profile  Seprate color image in three R G & B planes  Create color image using R, G and B three separate planes  Flow control and LOOP in SCILAB  Write given 2-D data in image file To write and execute image processing programs using point processing method     3. To write and execute programs for image arithmetic operations     4. AND operation between two images OR operation between two images Calculate intersection of two images Water Marking using EX-OR operation NOT operation (Negative image) To write a program for histogram calculation and equalization     6. Addition of two images Subtract one image from other image Calculate mean value of image Different Brightness by changing mean value To write and execute programs for image logical operations      5. Obtain Negative image Obtain Flip image Thresholding Contrast stretching Standard MATLAB function Program without using standard MATLAB functions C Program Use Simulink to plot histogram of colour image To write and execute program for geometric transformation of image      Translation Scaling Rotation Shrinking Zooming E.C. Department, Government Engineering College, Rajkot Page 3 write answers and execute it  Write and execute all programs either in MATLAB or SCILAB. To understand various image noise models and to write programs for image restoration    8. Remove Salt and Pepper Noise Minimize Gaussian noise Median filter and Weiner filter Apply FFT on given image Perform low pass and high pass filtering in frequency domain Apply IFFT to reconstruct image Write a program in C and MATLAB/SCILAB for edge detection using different edge detection mask Write and execute program for image morphological operations erosion and dilation. Prepare your folder in your laptop/computer. You can cut and paste results of image processing in soft copy of this lab manual. Students must complete first SET of seven experiments before 15th March 2014 and get signature of faculties in all six experiments. SET 1 having seven experiments.  There are two SET of experiments. Show your programs when faculty asks for it. 12. Write all the programs in separate folder.  Do not use standard MATLAB functions whenever specified. Understand 1-D and 2-D convolution process Use 3x3 Mask for low pass filter and high pass filter Write and execute programs for image frequency domain filtering    10. Instructions to the students:  Solve exercise given at the end of each practical. Students should complete SET2 before 30 th April 2014. Write and execute programs to remove noise using spatial filters   9.7. SET 2 having another 5 experiments. 11. Write program yourself without using standard functions  Get signature of staff regularly after completion of practical and exercise regularly. Lab Manual of Fundamentals of Image Processing Page 4 . To write and execute program for wavelet transform on given image and perform inverse wavelet transform to reconstruct image. 142. It has one thousand four hundred in-built functions and it is growing day by day. MATLAB is commercial software while SCILAB is open source software. 7 8 9] The above SCILAB command declares following matrix:  1 2 3 A =  4 5 6 7 8 9 Keep following things in mind while declaring variables/matrices:  No spaces  Don’t start with a number  Variable names are case sensitive E. A = [1 2 3. 1 AIM: Write program to read and display digital image using MATLAB or SCILAB Introduction of SCILAB: SciLab is a programming language for mathematical operations It provides development environment for mathematical programming.sce file to see the execution of the program. Saving and Loading Programs in SCILAB: SCILAB can be used as a prototyping environment in which we try things out. Video Processing) Toolbox. For large number of commands. Image and Video processing toolbox will be useful for this subject. Image. examine the results and then adjust our programs to give better performance.C. Government Engineering College. Department. there is no need to declare variables. We can give SCILAB commands on command prompt. 4 5 6.EXPERIMENT NO.in You can also create your log in on the e-Prayog website: http://59. We can write sequence of commands in SCILAB editor and then save as . For image processing experiments you need to download SIVP (Speech. new variables are simply introduced as they are required.sce files. Some commands and programs in SCILAB: [1] Declaring matrices: In SciLab.scilab. We can execute . It is similar to MATLAB. we can use SCILAB editor.181.81 and get scilab link from there. It is very much useful for matrix manipulation hence it is good choice for signal processing and image processing applications. Rajkot Page 5 . Students can download free SCILAB software from following website: http://www. After giving above command image data is available in myImage variable. The supported file formats include ‘bmp’.bmp and if it is in /home/chv folder above commands can be written as: myImage=imread(‘/home/chv/test. Syntax: imshow(<variable name>) Example: imshow(myImage). The current directory can be changed from the main SciLab interface window or by cd (change directory command). Lab Manual of Fundamentals of Image Processing Page 6 . [4] Displaying image After reading image data using above function. cols=3 [3] Reading Image file We can use following command to read image file: myImage=imread(‘File name with path’) If name of the image file is test.[2] Populating matrix elements with zeros: SciLab also provides a number of functions which can be used to populate a new matrix with particular values. ‘gif’.3) 0 0 0 B = 0 0 0 0 0 0 [2] Knowing size of matrix: Syntax: [rows. we can display images in SciLab using imshow function. cols] = size(A). ‘jpg’ and ‘png’. n) which creates an m*n matrix of zeros as follows: B = zeros(3. You can use any variable name. This function simply takes the array storing the image values as its only parameter. This command gives size of matrix Above command gives result: rows=3.bmp’) The image filename can be given as a full file path or as a file path relative to the SciLab current directory. For example to make a matrix full of zeroes we can use the function zeros(m. we can read each plane separately as follows: E. Rajkot Page 7 . Cols] = size(myImage) [6] Image resizing Image resizing can be done by following command: imresize(Image.G and B planes.[200.G.’nearest’). For example: Consider that we read the image in variable myImage using imread function than we can resize the image stored in this variable by following command imresize(myImage. Department. If given image is chess-board pattern. Example: myGrayImage=rgb2gray(myImage) [8]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 [9] Intensity profile along line given by two points on image Drawing of intensity profile along single line on given image (Scan one line along the image and draw intensity values (1-D signal)) can be done by function improfile() Example: improfile(myImage.B planes If we read given color image using imread() function.150].[0.256]. [10] Separate color image into three separate R.150]).{Parameters}). profile graph would be squarewave. [7]Converting Color image into Grayscale image: Color image can be converted into Grayscale image by matlab/scilab function rgb2gray. This command will convert image of any size into image of 256x256 using nearest neighbor technique.[256.[5] Knowing size of image in pixels: Size of the image in pixels can be found out by following command: [Rows. Government Engineering College. we get 3-D matrix. To separate out R.C. end [13] Loops in SCILAB: There is for loop and while loop in SCILAB. c) = 0. we can use concatenate function: Example: newImage=cat(3.bmp’).3).1). The while loop in SciLab uses the following syntax: while <condition> <perform some work repeatedly…> end For loop in SCILAB is very popular for image processing because it is particularly useful for iterating through the members of a matrix.:. GREEN=myImage(:. [11] Combine three separate R.:. c) > threshold then ThresholdedImage(r.G and B planes separately and if we want to create color image from it.BLUE. BLUE=myImage(:.G. RED=myImage(:.Example: myImage=imread(‘RGBBar. c) = 255.B planes to create color image If we have three R.RED.2). The SCILAB for loop uses the following syntax: Lab Manual of Fundamentals of Image Processing Page 8 . While loop While loop repeat a piece of work as long as a condition holds true.:.GREEN) [12] Flow control in SCILAB If statements are simply used to make decisions in SciLab Syntax: if <condition> then <do some work> else <do some other work> end If we wish to perform thresholding of an image we could use following statements in SCILAB Program: if ImageData(r. else ThresholdedImage(r. bmp”. end end average=total/(Rows*Cols) [14] Saving two dimensional matrix in Image file We read image.01:1 y=sin(2*%pi*10) plot(y) _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ E. myImage=imread(‘/home/chv/test. 'bmp').bmp’) [Rows. It also supports ‘gif’. Government Engineering College. for rowIndex = 1:Rows for colIndex = 1:Cols total = total + ImageData(rowIndex. To save image data in image file. finds average pixel value which represents average brightness of the scene.bmp'. following command is used.C. Department. Cols] = size(myImage) total = 0. imwrite(ImageData. ' Testout. ‘jpg’ and ‘png’ file formats. colIndex). :: WORKSHEET :: [1] Give following commands in SCILAB. image data is available in two dimensional matrix. After processing. We process the matrix. does summation of pixel values. Rajkot Page 9 . observe output and write explanation of each command t = 0:0. This command writes ImageData in file “Testout. we need to save the processed data in form of image.for index = <start>:<finish> <Perform some work…> end Example: Following SCILAB code iterates through each pixel of image. Cols]=size(imgData).j)=0. imshow(imgData). Lab Manual of Fundamentals of Image Processing Page 10 . imshow(imgData). Write comments on the result : imgData=imread('black.bmp” Read and display image using SCILAB/MATLAB commands _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ [3] Execute following program for the image created in exercise[2] and observe the result. [Rows. 256 gray-level using paint or any other relevant software and save it file name “black. for i=1:Rows for j=1:Cols if(i>Rows/4 && i<3*Rows/4) if(j>Cols/4 && j<3*Cols/4) imgData(i.bmp'). end end end end figure._____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ [2] Create image of size 512x512 black square using monochrome. Rajkot Page 11 .Write your comments on the result after executing the program: _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ [4] Write MATLAB command for the following  Read color image ‘RGBBar. convert it into Grey-scale image _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________  Read color image ‘RGBBar. Find size of the image. Government Engineering College. Resize it to 256x256 _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ E. Department.C.bmp’ given in working directory.bmp’ given in working directory. If we consider image having gray levels r and if grey levels in output image is s than.y) is original image.y)=T(f(x.y) is transformed image s = gray level of transformed image r = gray level of original image Threshold operation: In threshold operation. 2 AIM: To write and execute image processing programs using point processing methods  Obtain Negative image  Obtain Flip image  Threshold operation (Thresholding)  Contrast stretching Introduction: Image enhancement can be done in two domain: [1] Spatial Domain and [2] Transform domain.y))  s=T(r) Where.EXPERIMENT NO. In Spatial domain Image processing. Grey level transformation can be given by following equation  g(x. g(x. Pixel value greater than threshold value is made white and pixel value less than threshold value is made black. f(x. s=0 if r ≤ m s = 255 if r > m Where m = threshold Lab Manual of Fundamentals of Image Processing Page 12 . there are two ways:  Point processing (Single pixel is processed at a time)  Neighborhood processing (Mask processing) Convolution of 3x3 or 5x5 or other size of mask with image In point processing. 's'). 2 Thresholding (Extreme contrast stretching) % Scan any document and use this method to make it clean % Example: scan your own signature and make it clean with thresholding filename=input('Enter file name: '. y=imread(filename). end end end figure. Government Engineering College. imshow(y).n]=size(y).cols] = size(imagedata). Rajkot Page 13 . if(ndims(imagedata)==3) imagedata=rgb2gray(imagedata).C. for i=1:m for j=1:n if(y(i. imshow(y). Run above program for different threshold values and find out optimum threshold value for which you are getting better result.j)>T) y(i. if(ndims(y)==3) y=rgb2gray(y). Department. %Generate the flipped image for r = 1:rows for c = 1:cols FlippedImageData(r. end end %Display the original image and flipped image E. imagedata = imread(filename). else y(i. end [m.j)=0. Horizontal flipping: % Experiment 2: Flip given image horizontally % Read in an image filename=input('Enter file name: '.cols).'s').j)=255. end %Determine the size of the image [rows. %Declare a new matrix to store the newly created flipped image FlippedImageData = zeros(rows.cols+1-c) = imagedata(r.MATLAB Program for Thresholding: % Experiment No.c). T=input('Enter threshold value between 0 to 255: '). 2). imshow(FlippedImageData.'FlipTest.jpg'. 2 % To obtain Negative Image % Image Processing Lab. close. neg_img=zeros(rows.namefile)). subplot(2.jpg.tif.*.*. imshow(imagedata) . GEC Rajkot clc. subplot(2.*.c) = 255-img(r.'Choose GrayScale Image').gif'. Lab Manual of Fundamentals of Image Processing %Calculate negative image Page 14 .cols]=size(img).[]).jpg. %Write flipped image to a file imwrite(mat2gray(FlippedImageData).bmp.99). img=imread(strcat(pathname.c).1. 255 s = 255-r s r 255 MATLAB Program to obtain Negative Image: % Experiment No.tif.*. %Original Image [namefile.1).'quality'. imshow(neg_img.'IMAG E Files (*. for r = 1:rows for c = 1:cols neg_img(r.bmp.pathname]=uigetfile({'*. imshow(img).*. end end %Display original and negative images subplot(2.cols). end [rows.*.1.1.2). if(size(img.[]).subplot(2. Negative Image: Negative Image can be obtained by subtracting each pixel value from 255.gif)'}.1.1).3)==3) img=rgb2gray(img). j)>b) newimg(i.j)<=a) newimg(i.*.jpeg.tif.gif'.bmp.jpg.*.j)<=b) newimg(i.pathname]=uigetfile({'*.'IMAGE Files (*. clear all. end end end subplot(2.2).y and z are different slopes a b RED line shows piecewise approximation MATLAB Program for contrast stretching: % Experiment No.*. end if (img(i.'Chose GrayScale Image'). Department.bmp.3)==3) img=rgb2gray(img). Government Engineering College.j). 2 Contrast stretching using three slopes % and two threshold values a & b clc.tiff. imshow(uint8(newimg)).j).*.Contrast Stretching: Contrast Stretching means Darkening level below threshold value m and whitening level above threshold value m.j)=img(i. a=input('Enter threshold value a: '). [namefile. Practically contrast stretching is done by piecewise linear approximation of graph shown in left by following equations: s = x.r s = z. col]=size(img).*.r s = y.*. end if(img(i. for i=1:row for j=1:col if(img(i. newimg=zeros(row.r 0 ≤ r<a a ≤ r<b b ≤ r<255 Where x. E.j)=2*img(i. b=input('Enter threshold value b: ').*.1).jpg.tiff. This technique will enhance contrast of given image.*.j)>a && img(i.tif. imshow(uint8(img)).1. if(size(img.col).gif)'}. Thresholding is example of extreme constrast stretching. img=imread(strcat(pathname. Rajkot Page 15 .*. end [row.namefile)). subplot(2.1.j)=img(i.j).C.*.jpe g. Execute it for some image. Apply it on some image _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ [1] In contrast stretching program take threshold values 50 and 100. slope 2 for gray levels between 50 to 100 and slope 1 for rest gray levels. Modify and write program again. Use slope 3 for gray levels between 0 to 50.:: WORKSHEET :: [1] Modify program of horizontal flipping for getting vertical flipping. _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ Lab Manual of Fundamentals of Image Processing Page 16 . _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ Copy and Paste original and contrast stretched images here: E.C. Government Engineering College. Department. Rajkot Page 17 . C. Multiplication operation can be used to mask the image for obtaining region of interest. we can subtract constant value.tif'). When it exceeds value 255. we can add some constant value depending on brightness required. It can also used to detect change in image. 3 Image Arithmetic Operations %Image Processing Lab. Execute following MATLAB program: %Experiment No. so image resize %function is used to make size of both image same. In example program.png'). Image addition is pixel to pixel. Lab Manual of Fundamentals of Image Processing Page 18 . it should be clipped to 255. x and y are coordinates of image. GEC Rajkot %Image addition is done between two similar size of image. Multiplication operation can also be used to increase brightness of the image Division operation results into floating point numbers. Division can be used to decrease the brightness of the image.y) + I2(x.EXPERIMENT NO. Care should be taken that pixel value should not less than 0 (minus value). To increase overall brightness of the image. In example program we will add value 50 to the image and compare brightness of original and modified image. subtraction. 3 AIM: To write and execute programs for image arithmetic operations Introduction: Arithmetic operations like image addition. Value of pixel should not cross maximum allowed value that is 255 for 8 bit grey scale image. E.y) Where I(x.y) is resultant image due to addition of two images. Black and white mask (binary image) containing 1s and 0s is multiplied with image to get resultant image.e. multiplication and division is possible. 255 for 8 bit greyscale image.y) = I1(x. value 100 is subtracted for every pixel. I2 = imread('rice. Subtract operation can be used to obtain complement (negative) image in which every pixel is subtracted from maximum value i. If there is two images I1 and I2 then addition of image can be given by: I(x. To decrease brightness of image. It can be converted into integer data type while storing the image. So data type required is floating point numbers. Department. %I=I1+I2 clc close all I1 = imread('cameraman. To obtain binary image function im2bw() can be used. Government Engineering College. subplot(2. 2. Rajkot Page 19 . I=I1-100.imshow(I).imshow(I1).title('Original image I2'). %Type casting before multiplication subplot(2.title('Bright Image I').subplot(2.imshow(I).imshow(I).*uint8(M). I=I1-I2. I=I1+50. 3). Result after execution of program: Original image I1 Original image I2 Addition of image I1+I2 Subtraction of image I1-I2 E. figure. 1).title('Original image I1'). 2). 2).title('Addition of image I1+I2'). 3). 2. subplot(2. I=I1+I2. M=im2bw(M) % Converts into binary image having 0s and 1s I=uint8(I1).title('Original image I1'). M=imread('Mask.C.title('Dark Image I'). 2. 2. 1). 2.imshow(I). subplot(2.title('Masked Image I').title('Subtraction of image I1-I2'). 2. Department. 2.tif'). % Addition of two images subplot(2.imshow(I).imshow(I1). 4). 2. subplot(2. 4). %Subtraction of two images subplot(2.imshow(I2). j)-100.'Choose Image File'}).j)=myimage(i. k=1.gif'.j)=myimage(i. clear all. end if k==2 newimage(i. Cols] = size(myimage) newimage=zeros(Rows.jpg. end if k==3 newimage(i. end if k==4 newimage(i.j)+50. Lab Manual of Fundamentals of Image Processing Page 20 .j)-50.*.3)==3) myimage =rgb2gray(myimage).j)=myimage(i. if(size(myimage.*. end [Rows. while k<5. for i = 1:Rows for j = 1:Cols if k==1 newimage(i.bmp.j)+50. myimage=imread(filename).pathname]=uigetfile({'*. [filename.j)=myimage(i.Cols).Original image I1 Bright Image I Dark Image I Masked Image I Display image with different brightness: close all. imshow(newimage.C.2. end end average=total/(Rows*Cols) E. Rajkot Page 21 .end end end subplot(2. total = 0. for i = 1:Rows for j = 1:Cols total = total + myimage(i.j). Cols] = size(myimage) newimage=zeros(Rows.Cols). Government Engineering College. end Result: Calculate mean value: Mean value can be calculated by MATLAB function mean() Alternately following code can be used to calculate mean value: [Rows. k=k+1. Department.[]).k). Use imcomplement() function to get complement of image.:: WORKSHEET :: [1] In above program. resize it to 256x256. 128 256 _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ Lab Manual of Fundamentals of Image Processing Page 22 . Write program again using these functions in following space. Apply square mask shown in following figure so that only middle part of the image is visible. imsubtract() for subtraction immultiply() for multiplication operations. _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ [2] Write Program to read any image. use functions imadd() functions to addition. Rajkot Page 23 .C. Department._____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ [3] Write your own matlab function addbrightness() and use it to increase brightness of given image. _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ E. Government Engineering College. 3) cimageA= ~myimageA . myimageB=imread('pentagon. % Display the Original Image B subplot(3. Lab Manual of Fundamentals of Image Processing Page 24 . imshow(cimageA). E. myimageB=rgb2gray(myimageB).EXPERIMENT NO.2) imshow(myimageB).1) imshow(myimageA). % Take a Ex-OR of Image A and Image B and Display it subplot(3. title('Complement of Image A').jpg'). % Take a complement of Image A and Display it subplot(3. myimageA=rgb2gray(myimageA). Department.4) xorimage= xor(myimageA.2.jpg'). title('Image A XOR Image B'). 4 Image Logical Operations %Image Processing Lab.myimageB).C. 4 AIM: To write and execute programs for image logical operations Introduction: Bitwise logical operations can be performed between pixels of one or more than one image.2. subplot(3.title('Image B'). GEC Rajkot %Logical operations between two image circle and pentagon is shown clc close all clc close all myimageA=imread('circle.2. 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 images XOR/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 Program: Experiment No.2.title('Image A '). imshow(xorimage). watermark image is visible on original image in E. Department.2.5) orimage= myimageA | myimageB. title('Image A AND Image B ').6) andimage= myimageA & myimageB. image or video data. image and video two techniques are used: encryption and watermarking. Watermarking can be applied to audio. % Take AND of Image A and Image B and Display it subplot(3. title('Image A OR Image B '). Once data received at receiver. For visible watermarking technique. imshow(orimage). Watermarking technique used for can be visible or non-visible. Government Engineering College. Watermarking techniques can compliment encryption by embedding secret key into original data.% Take OR of Image A and Image B and Display it subplot(3. Rajkot Page 25 . Result after execution of program: Image A Image B Complement of Image A Image A XOR Image B Image A OR Image B Image A AND Image B Watermarking using EX-OR operation: To provide copy protection of digital audio.2. imshow(andimage). Encryption techniques normally used to protect data during transmission from sender to receiver. it is decrypted and data is same as original which is not protected.C. 'Chose GrayScale Image').jpeg.*. EX-OR operation is performed again between original image and watermarking image.jpg.tif. imshow(img) title('Original Image').2). title('Water marking key'). if(size(img. subplot(2.bmp'). In non-visible watermarking technique.gif'.*.*.*. subplot(2.title('Watermarked image').2. watermark image is hidden inside original image. [p q] = size(img).light form. w_img=bitxor(uint8(img). GEC Rajkot clc.uint8(img)). message GEC RAJKOT is watermarked in the digital image in invisible form.tiff.bmp.jpeg.*. close.*. imshow(w_img). 4 EX-OR operation to show watermarking application % Image Processing Lab.gif)'}.2.tif. In digital watermarking. end subplot(2.bmp. Result: Lab Manual of Fundamentals of Image Processing Page 26 .'IMAGE Files (*. title('Extracted Key').2. %Original Image [namefile.[p q]). Watermarking using EX-OR operation is simplest technique. extracted_key=bitxor(uint8(w_img).3). subplot(2.*. imshow(double(extracted_key)).*.pathname]=uigetfile({'*. To extract watermarking image.namefile)).tiff.*.jpg. In this message.2. key = imresize(key. watermarking key bits are scattered in the image and cannot be identified.4).*. In following program.3)==3) img=rgb2gray(img).uint8(key)). imshow(key). Ex-OR operation is performed between original image data and watermarking key. key = imread('KEY_GEC_RAJKOT. There are so many techniques being developed for secure and robust watermarking. img=imread(strcat(pathname. Program: % Experiment No.1). Department. Save it in JPEG format 256 gray levels. Rajkot Page 27 . Write program and paste your results. NAND operations between two images. Government Engineering College.C. Perform logical NOR.Original Image Water marking key Watermarked image Extracted Key :: WORKSHEET :: [1] Prepare any two images of size 256x256 in paint. _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ E. Result after execution of program: (Copy and paste original and processed image here) Lab Manual of Fundamentals of Image Processing Page 28 . End loop Area of image = rows*cols Dm=Number of gray levels in the output image Loop over ROWS Loop over COLS k = data(i. Government Engineering College.j) Calculate sum of the hist: Loop over gray levels i = 0 to no. 5 AIM: To write a program for histogram calculation and equalization     Standard MATLAB function Program without using standard MATLAB functions C Program Use Simulink to plot histogram of colour image Introduction:  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 pixel having that grey level  Histogram can tell us whether image was scanned properly or not.j) data(i.C. of gray levels sum=sum+hist(i).j) = (Dm/area)*sum_of_hist(k) End COLS oop End ROWS Loop E.  Histogram equalization can be applied to improve appearance of the image  Histogram also tells us about objects in the image. Rajkot Page 29 . Pseudo code: Calculate histogram: Loop over ROWS of the image Loop over COLS of then image Pixel value hist(k)=hist(k)+1 End COLS loop End ROWS loop i = 1 to rows j = 1 to cols k=data(i. Object in an image have similar gray levels so histogram helps us to select threshold value for object detection.  Histogram can be used for image segmentation. sum_of_hist(i)=sum.EXPERIMENT NO. It gives us idea about tonal distribution in the image. Department. imshow(myimage).1). end imhist(myimage). myimage=imread(filename). [1] histeq function It computes histogram and equalize it.2. EC Department. newimage= histeq(myimage). subplot(2.*. if(size(myimage. Sample program using standard functions: close all. figure.2. newimage= histeq(myimage).Standard MATLAB function for histogram and histogram equalization: [1] imhist function It computes histogram of given image and plot Example: myimage=imread(‘tier.'Choose Poorly scanned Image'}).pathname]=uigetfile({'*.jpg.*.gif'.bmp. clear all. if(size(data. [filename.gif'.jpg’) imhist(myimage).2). [filename.3)==3) myimage =rgb2gray(myimage). subplot(2. GEC Rajkot close all. end Lab Manual of Fundamentals of Image Processing Page 30 . clear all.*.'Choose Poorly scanned Image'}). title('Histogram equalized mage').bmp.bmp’).pathname]=uigetfile({'*.*.jpg. Example: myimage = imread(‘rice. Sample Program in MATLAB (without using standard function): % Experiment No. data=imread(filename).imshow(newimage). 5 %Program for calculation and equalisation of the histogram % Image Processing Lab.3)==3) data=rgb2gray(data). title('Original image'). [rows cols]=size(data) myhist=zeros(1. Dm=256. end end subplot(2.2. sum_of_hist(i+1)=sum. Government Engineering College. subplot(2. Rajkot Page 31 . myhist(m+1)=myhist(m+1)+1.C. title('Histogram of original image'). %Dm=input('Enter no.2). title('Original image').2.bar(myhist). sum=0.4).2. E.j)).title('Equalised Histogram').j)=sum_of_hist(n+1)*Dm/area. Department. data(i.j)).2. myhist(m+1)=myhist(m+1)+1. title('Image after histogram equalisation').bar(myhist).imshow(data). end end subplot(2. % Calculation of histogram for i=1:rows for j=1:cols m=double(data(i.256). of gray levels in output image: ').1). end area=rows*cols. for i=1:rows for j=1:cols n=double(data(i.3).imshow(data).subplot(2. end end %Calculation of histogram for equalised image for i=1:rows for j=1:cols m=double(data(i. %Cumulative values for i=0:255 sum=sum+myhist(i+1).j)). FILE *f1. for(i=1.k.sizeof(int).f1). i<gray_levels.i++) { hist[i]=0. int k=rows*cols. for(i=0. } fread(data.m.i++) { Lab Manual of Fundamentals of Image Processing Page 32 . f1=fopen(filename.  Implement this member function in implementation program  You can use 1010 sample image to observe results void image::histogram(char filename[]) { int i. i<rows.j."rb"). int sum_of_hist[100].Program output: Original image Histogram of original image 1500 1000 500 0 Equalised Histogram 0 100 200 300 Image after histogram equalisation 3000 2000 1000 0 0 100 200 300 Sample Program in C language: Requirements:  Add member function histogram() in Image class for histogram calculation and equalisation  Add member function print_histogram() in Image class to display histogram of an image. printf("\n").i++) { for(j=0. getch().i<rows. /* Histogram Equalisation*/ int sum=0. data[i][j]=sum_of_hist[n]*Dm/area. j<cols. Department. hist[m]=hist[m]+1. i<16. } } printf("Equalised histogram:\n"). sum_of_hist[i]=sum. int Dm. j++) { m=data[i][j]. Rajkot Page 33 .j++) { int n=data[i][j]. printf(" Occurence of gray levels ---->\n"). printf(" "). i++) { sum=sum+hist[i]. Government Engineering College.i<=25.j.i<rows. print_histogram(). print_histogram(). } void image::print_histogram() { int i.i++) { for(j=0. i++) { E. scanf("%d".C. i<gray_levels. hist[n]=hist[n]+1. &Dm).i++)printf("_").j<cols. of gray levels in output image:").j<cols. } int area=k. getch(). } } for(i=0. for(i=0.for(j=1. for(i=0. for(i=0.j++) { int n=data[i][j]. printf("Enter no. for(i=0. } } fclose(f1). printf("\n\n"). R Video Viewer G B Video Vi ewer Histogram R Teddy.j++) printf("*").  We will use following blocks in this experiment …. for(j=1.jpg G B 2 Histogram1 Image From Fi le M atrix Concatenate User Vector Scope Histogram2 Lab Manual of Fundamentals of Image Processing Page 34 . printf("\n").i).printf("%2d |". go through all the options one by one.  Type simulink command on the command prompt  Click on Computer Vision System toolbox  There are various options available in this tool box. } Using Simulink to plot histogram of image: Simulink is very much user friendly if you are convergent with image processing operations. } printf("\n\n"). j<=hist[i]. [1] Computer Vision System Toolbox > Sources>Image from file [2] Computer Vision System Toolbox > Sinks>Video Viewer [3] Simulink > Math Operations > Matrix Concatenate [4] Computer Vision System Toolbox > Statistics>Histogram [5] DSP System Toolbox > Signal Processing Sinks > Vector Scope Arrange all blocks as per following diagram and connect them. clear the Frame number check box  Display Properties pane. Set following parameters in image block:     Sample time = inf Image signal = Separate color signals Output port labels: = R|G|B Output data type: = double Set following parameters in histogram block:  Lower limit of histogram: 0  Upper limit of histogram: 1  Number of bins: = 256 Set following parameters in matrix concatenate block:  Number of input parameters: 3 Set following parameters in Vector scope  Scope Properties pane. Government Engineering College. E. Solver = Discrete (no continuous states) Run simulation and see result. Stop time = 0  Solver pane. select the Channel legend check box  Display Properties pane. Set the parameters as follows:  Solver pane. Maximum Y-limit = 1  Axis Properties pane.|s|d  Line Properties pane. Line markers = .C. select the Compact display check box  Axis Properties pane. Rajkot Page 35 . clear the Inherit sample increment from input check box. Input domain = User-defined  Display Properties pane. Y-axis label = Count  Line Properties pane. Type = Fixed-step  Solver pane.  Axis Properties pane. Department. Line colors = [1 0 0]|[0 1 0]|[0 0 1] Open the Configuration dialog box by selecting Configuration Parameters from the Simulation menu.Select Image file by clicking on image block. Minimum Y-limit = 0  Axis Properties pane. Change file and do experiment again. :: WORKSHEET :: [1] Take your own photograph in dark area. (Copy and paste your original image. its histogram. equalized image and its histogram) Lab Manual of Fundamentals of Image Processing Page 36 . Improve its appearance using histogram equalization technique. Rajkot Page 37 . in matrix form it can be represented as: x’ = xcos . this matrix rotates the image in clockwise direction. Shearing can be represented as: x’ = shx × y y’ = y In matrix form rotation is represented by: E.ysin and y’ = xsin + ycos In matrix form rotation is represented by: x'  cos  y ' 1 =  sin   0  sin  cos  0 0 0  1   x  y    1  If  is substituted with -. Mathematically translation is represented as: x’ = x +x and y’ = y + y In matrix form translation is represented by: x' 1 y ' 1 =  0  0 x   y  1  0 1 0  x  y    1  Scaling: Scaling means enlarging or shrinking.C. 6 AIM: To write and execute program for geometric transformation of image Introduction: We will perform following geometric transformations on the image in this experiment Translation: Translation is movement of image to new position. Department. Government Engineering College. Shearing: Image can be distorted (sheared) either in x direction or y direction. Mathematically scaling can be represented by: x’ = x × Sx and y’ = y × Sy In matrix form scaling is represented by: x' S x y ' 1 =  0  0 0 Sy 0 0 0  1   x  y    1  Rotation: Image can be rotated by an angle .EXPERIMENT NO. 'bilinear'. title('Orignial Image').'crop'). imshow(y). GEC Rajkot %To rotate given image using standard Matlab function imrotate() %To transform image using standard Matlab function imtransform() % using shearing matrix. tform = maketform('affine'.3).90. subplot(2. y=imrotate(x. y=imrotate(x. 0 1 0. 4 Image Geometric transformations %Image Processing Lab. 0.5 0. title('Image rotated by 90 degree'). tform = maketform('affine'.4). tform = maketform('affine'. x=rgb2gray(x). imshow(y). . y=imrotate(x. E. subplot(2.2).2. clc close all filename=input('Enter File Name :'.tif'). subplot(2.1). Lab Manual of Fundamentals of Image Processing Page 38 . imshow(y).'s'). 0 0 1]).2.5 1 0.5 0. title('Image rotated by -45 degree'). 1 Xshear=  sh x  0 0 1 0 0 0  1   x  y    1  Shearing in Y direction can be given by: x’ = x y’ = y × shy 1 Yshear=  0  0 sh y 1 0 0 0  1   x  y    1  Zooming : zooming of image can be done by process called pixel replication or interpolation. subplot(2.2.45. title('Orignial Image').tform). Department.5 1 0.C.'bilinear'.[1 0 0.tform). imshow(y). Program: %Experiment No. subplot(2. 0 0 1]). x=imread(filename).2. subplot(2.[1 0. imshow(x). Linear interpolation or some non-linear interpolation like cubic interpolation can be performed for better result. 0 0 1]). title('Shear in Y direction'). x = imread('cameraman. figure.2).2.'bilinear'.1). y = imtransform(x.'crop'). subplot(2. title('Image rotated by 45 degree').2.'crop'). title('Shear in X direction'). imshow(y). y = imtransform(x.[1 0.3).2. imshow(x).-45. C. title('Shear in X-Y direction'). subplot(2.y = imtransform(x. Department.tform). imshow(y).4). Rajkot Page 39 . Government Engineering College. Result after execution of program: Orignial Image Image rotated by 45 degree Image rotated by 90 degree Image rotated by -45 degree Result after execution of program: Orignial Image Shear in Y direction Shear in X direction Shear in X-Y direction E.2. Program: _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ Result after execution of program: Conclusion: Lab Manual of Fundamentals of Image Processing Page 40 .Exercise: [1] In above program. Show the results and your conclusions. modify matrix for geometric transformation and use imtransform() function for modified matrix. 7 AIM: To understand various image noise models and to write programs for image restoration Introduction: Image restoration is the process of removing or minimizing known degradations in the given image. Rajkot Page 41 .  Spatial degradations. E.v)+N(u.y) + (x. Image restoration is used to improve quality of image by various methods in which it will try to decrease degradations & noise.y)=h(x.y) Frequency domain: G(u.C.v) G(x.  Geometric distortions.  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. Government Engineering College. Model of Image Degradation/restoration Process is shown in the following figure. Image restoration applies different restoration filters to reconstruct image to remove or minimize degradations. Degradation of images can occur due to many reasons. Spatial domain: g(x.y)*f(x.EXPERIMENT NO.v)=H(u. No imaging system gives perfect quality of recorded images due to various reasons. Department.v) is frequency domain representation of degraded image.v)F(u.y) is spatial domain representation of degraded image and G(u. Some of them are as under:  Poor Image sensors  Defects of optical lenses in camera  Non-linearity of the electro-optical sensor. 2. subplot(2.*. imshow(uint8(L)).jpg. A= imread(cat(2.tif.title('Remove Gaussian noise by Wiener filter').*.4). if(size(A.'salt & pepper'.title('Image with salt & pepper noise'). subplot(2. figure. imshow(uint8(K)).pathname]=uigetfile({'*. % Add gaussian noise M = imnoise(A. end subplot(2.3).1).2). title('Remove salt & pepper noise by median filter').[5 5]).2.*.filename)).2.tiff. title('Image with gaussian noise').*.bmp.005).jpeg. imshow(M).[5 5]). % Remove Salt & pepper noise by median filters K = medfilt2(B).2. title('Remove salt & pepper noise by Wiener filter'). % Add salt & pepper noise B = imnoise(A.*.title('Original image').0. GEC Rajkot clear all. % Remove Gaussian noise by Wiener filter L = wiener2(M. imshow(A).'gaussian'.jpg.gif'. subplot(2. imshow(A).pathname. subplot(2.*. imshow(uint8(K)). imshow(B). subplot(2. close all.0.tiff.2.'Chose Image File'). Which filter is better to remove salt and pepper noise ? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ Lab Manual of Fundamentals of Image Processing Page 42 . Exercise: [1] Draw conclusion from two figures in this experiment. title('Remove Gaussian noise by median filter').jpeg.'IMAGE Files (*.4).Program: % Experiment No. [filename. K = medfilt2(M). % Remove salt & pepper noise by Wiener filter L = wiener2(B.1). 7 % To add noise in the image and apply image restoration % technique using Wiener filter and median filter % EC Department.*.tif.2.2.gif)'}.2). 0. subplot(2.3)==3) A=rgb2gray(A).*. subplot(2.title('Original image').3). imshow(uint8(L)).*.*.2.02).bmp. [2] Explain algorithm used in Median filter with example _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ [3] Write mathematical expression for arithmetic mean filter. Government Engineering College. geometric mean filter.C. Rajkot Page 43 . Department. harmonic mean filter and contra-harmonic mean filter _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ [3] What is the basic idea behind adaptive filters? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ E. Neighborhood processing is an appropriate name because you define a center point and perform an operation (or apply a filter) to only those pixels in predetermined neighborhood of that center point. end for i=1:n+k-1 s(i)=0 for j=1:i s(i)=(x(j)*y(i-j+1))+s(i) end end subplot(3.1) plot2d3(x) Lab Manual of Fundamentals of Image Processing Page 44 . Program for 1D convolution (Useful for 1-D Signal Processing): clear.EXPERIMENT NO. we perform convolution of data with filter coefficients. we perform convolution of 1-D data with set of filter coefficients. we perform convolution of 3x3 filter coefficients with 2-D image data. clc. The general idea is shown below as a "sliding filter" that moves throughout the image to calculate the value at the center location. which becomes the value at the center point's location in the modified image. 8 AIM: Write and execute programs to remove noise using spatial filters  Understand 1-D and 2-D convolution process  Use 3x3 Mask for low pass filter and high pass filter Introduction: Spatial Filtering is sometimes also known as neighborhood processing. end for u=k+1:n+k-1 y(u)=0. x=input("Enter value of x: ") y=input("Enter value of y: ") n=length(x) k=length(y) for z=n+1:n+k-1 x(z)=0. In spatial filtering. In image processing. Each point in the image is processed with its neighbors. In signal processing.1. The result of the operation is one value. 2) plot2d3(y) subplot(3.b+1). Government Engineering College.ycols]=size(y). Department. x=input("Enter value of x in matrix form: ") y=input("Enter value of y in matrix form: ") [xrows.c+b)*y(a+1. end end E. for a=0:yrows for b=0:ycols sum=sum+x(r+a.xcols+ycols) for r = 1:xrows-1 for c = 1:xcols-1 sum=0.1. result=zeros(xrows+yrows. [yrows. clc.3) plot2d3(s) Take value of x: [ 1 2 3 4 5 6 7 8 9 0 10 11 12 13 14 15] Y: [-1 1] Observe result of convolution and write your comments: _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ Program for 2D convolution: clear.subplot(3.xcols]=size(x).C.1. Rajkot Page 45 . c)=sum. end end Enter following 2D matrix for x: 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 Enter following 2D matrix for y: 1 1 1 0 0 0 1 1 1 Observe output values and write your comments _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ Lab Manual of Fundamentals of Image Processing Page 46 .result(r. *.*.1).double(L3)).-1 -1 -1]. subplot(3.*. Government Engineering College. title('Filtered image with mask H1'). title('Filtered image with mask L3').2. H3=[1 -2 1.C.0 1 0].*. if(size(myimage.bmp.1 -2 1].5). subplot(3. %Define spatial filter masks L1=[1 1 1. L3 = L3/sum(L3).*.tif. close all.-1 9 -1. L3=[1 2 1.3). H2=[0 -1 0. imshow(filt_image.-1 5 -1.4). myimage = imread(cat(2. end subplot(3.jpeg.1 1 1].2 4 2.2.2.'Chose Image File').[]).pathname]=uigetfile({'*. title('Filtered image with mask L1').gif)'}. imshow(myimage). E.'IMAGE Files (*.*. L2=[0 1 0.-2 5 -2.[]).2). GEC Rajkot clc.double(L2)). subplot(3.2.2. L2 = L2/sum(L2).1 2 1].*. clear all. filt_image= conv2(double(myimage). H1=[-1 -1 -1.double(L1)).3)==3) myimage=rgb2gray(myimage). title('Filtered image with mask L2'). imshow(filt_image. Department. 8 Spatial filtering using standard MATLAB function % To apply spatial filters on given image % EC Department.*. filt_image= conv2(double(myimage).[]).pathname.jpeg. subplot(3.1 1 1. filt_image= conv2(double(myimage).gif'. filt_image= conv2(double(myimage).jpg.*. imshow(filt_image. imshow(filt_image.tif.-0 -1 0].jpg.[]).tiff.Program: % Experiment No. % Read the test image and display it [filename. L1 = L1/sum(L1).filename)).*.1 2 1.bmp. Rajkot Page 47 .tiff. title('Original Image').H1). 1 1 1 1 1 1 1. subplot(3. imshow(filtimg.H2). title('Average filter with conv2()').2. subplot(2. imshow(filt_image.title('Output of Gaussian filter 3 X 3').2. 1 1 1 1 1 1 1.2).2.6). imshow(convimage.2. avgfiltmask = avgfilt/sum(avgfilt).3).H3).3).[]).[]).1). convimage= conv2(double(myimage). 1 1 1 1 1 1 1. title('Filtered image with mask H1'). filtimg = imfilter(myimage.[]). imshow(filt_image.6). imshow(myimage).filt_image= conv2(double(myimage). 1 1 1 1 1 1 1].[]). subplot(2. figure. 1 1 1 1 1 1 1. 1 1 1 1 1 1 1. Lab Manual of Fundamentals of Image Processing Page 48 . subplot(3.double(avgfiltmask)). % The command fspecial() is used to create mask % The command imfilter() is used to apply the gaussian filter mask to the image % Create a Gaussian low pass filter of size 3 gaussmask = fspecial('gaussian'. title('Filtered image with mask H3').gaussmask). subplot(2. title('Original Image'). % Generate a lowpass filter of size 7 X 7 % The command conv2 is used the apply the filter % This is another way of using the filter avgfilt = [ 1 1 1 1 1 1 1. filt_image= conv2(double(myimage).2. Rajkot Page 49 .y) of size MN using mask W of size ab. Department. Government Engineering College.C. _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ [2] What is need for padding? What is zero padding? Why it is required? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ [3] What is the effect of increasing size of mask? _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ E.:: WORKSHEET :: [1] Write mathematical expression of spatial filtering of image f(x. we perform convolution of filter mask with image data.v) of input image f(x.y) of size MxN can be given by: Where.1.1. x = 0.v) Result: H(u.y) Multiply F(u.v)F(u. M-1 and v = 0.2 ……. In frequency domain we perform multiplication of Fourier transform of image data with filter transfer function.1.2 ……. M-1 and y = 0.2……N-1 Basic steps for filtering in frequency domain:       Pre-processing: Multiply input image f(x.y) by (-1)x+y to center the transform Computer Discrete Fourier Transform F(u.1.EXPERIMENT NO.v) Computer inverse DFT of the result Obtain real part of the result Post-Processing: Multiply the result by (-1)x+y Lab Manual of Fundamentals of Image Processing Page 50 . u = 0. 9 AIM: Write and execute programs for image frequency domain filtering Introduction: In spatial domain.2……N-1 Inverse Fourier transform is given by: Where. Fourier transform of image f(x.v) by filter function H(u. tif. if(size(myimg. %Define Filter Mask mylowpassmask = ones(M. E.y)=myimg(x.jpeg. Rajkot Page 51 . if tmp > low mylowpassmask(u. imshow(myimg.N). subplot(2. mybandpassmask = ones(M.*.y)*((-1)^(x+y)). myimg=imread(cat(2.1).jpeg. Department. title('FFT Image').Program: % Experiment 9 Program for frequency domain filtering % EC Department. close all.title('Original Image').'IMAGE Files (*.*.tiff.3)==3) myimg=rgb2gray(myimg).tiff.'Chose Image File').C. end if tmp > band2 || tmp < band1.bmp. % Define cut off frequency low = 30. end myimg = imresize(myimg.*. band2 = 50.gif)'}.2. clear all. GEC Rajkot clc. resize it to 256 x 256 % Convert it to grey image and display it [filename.[]). subplot(2.2).jpg.gif'.*. band1 = 20.*.*.[256 256]).*.pathname]=uigetfile({'*.2.N] = size(myimg).N). [M. myimg=double(myimg). mybandpassmask(u.*.5.filename)).pathname. % Find size %Preprocessing of the image for x=1:M for y=1:N myimg1(x.jpg. % Read the image.v) = 0. end end % Find FFT of the image myfftimage = fft2(myimg1). % Generate values for ifilter pass mask for u = 1:M for v = 1:N tmp = ((u-(M/2))^2 +(v-(N/2))^2)^0.bmp.[]). imshow(myfftimage.v) = 0.tif.*. Government Engineering College.*. imshow(r3.1.imshow(mybandpassmask). resimage3 = myfftimage. Conclusion: _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ Lab Manual of Fundamentals of Image Processing Page 52 . subplot(2.[]). subplot(2. See changes in the result and write conclusion. % Display the band pass filtered image r3 = abs(ifft2(resimage3)).1. subplot(2. myfftimage=fftshift(myfftimage).4). %Preprocessing of the image for x=1:M for y=1:N myimg1(x. imshow(r1.title('Band Pass filtered image').[]).3).title('Low Pass filtered image').y)=myimg(x.2.end end end % Apply the filter H to the FFT of the Image resimage1 = myfftimage. % Apply the Inverse FFT to the filtered image % Display the low pass filtered image r1 = abs(ifft2(resimage1)).y)*((-1)^(x+y)).*mylowpassmask.2).1). end end Remove above step and use following commands.imshow(mylowpassmask). :: WORKSHEET :: [1] Instead of following pre-processing step in above program use fftshift function to shift FFT in the center. subplot(2. myfftimage = fft2(myimg). figure.2.*mybandpassmask. C. Department. Rajkot Page 53 . Government Engineering College._____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ [2] Write a routine for high pass filter mask _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ [2] Write a routine for high pass filter mask _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ E. EXPERIMENT NO. 10 AIM: Write a program in C and MATLAB/SCILAB for edge detection using different edge detection mask. Introduction: Image segmentation is to subdivide an image into its component regions or objects. Segmentation should stop when the objects of interest in an application have been isolated. Basic purpose of segmentation is to partition an image into meaningful regions for particular application The segmentation is based on measurements taken from the image and might be grey level, colour, texture, depth or motion. There are basically two types of image segmentation approaches: [1] Discontinuity based: Identification of isolated points, lines or edges [2] Similarity based: Group pixels which has similar characteristics by thresholding, region growing, region splitting and merging Edge detection is discontinuity based image segmentation approach. Edges play a very important role in many image processing applications. It provides outline of an object. In physical plane, edges are corresponding to changes in material properties, intensity variations, discontinuity in depth. Pixels on the edges are called edge points. Edge detection techniques basically try to find out grey level transitions. Edge detection can be done by first order derivative and second order derivative operators. First order line detection 3x3 mask are: Lab Manual of Fundamentals of Image Processing Page 54 Popular edge detection masks:  Sobel operator performs well for image with noise compared to Prewitt operator because Sobel operator performs averaging along with edge detection.  Because Sobel operator gives smoothing effect, spurious edges will not be detected by it. Second derivative operators are sensitive to the noise present in the image so it is not directly used to detect edge but it can be used to extract secondary information like …  Used to find whether point is on darker side or white side depending on sign of the result  Zero crossing can be used to identify exact location of edge whenever there is gradual transitions in the image MATLAB Code using standard function: % Experiment 10 % Program for edge detection using standard masks % Image Processing Lab, EC Department, GEC Rajkot clear all; [filename,pathname]=uigetfile({'*.bmp;*.tif;*.tiff;*.jpg;*.jpeg;*.gif','IMAGE Files (*.bmp,*.tif,*.tiff,*.jpg,*.jpeg,*.gif)'},'Choose Image'); A=imread(filename); if(size(A,3)==3) A=rgb2gray(A); end imshow(A); figure; BW = edge(A,'prewitt'); subplot(3,2,1); imshow(BW);title('Edge detection with prewitt mask'); BW = edge(A,'canny'); subplot(3,2,2); imshow(BW);;title('Edge detection with canny mask'); BW = edge(A,'sobel'); subplot(3,2,3); imshow(BW);;title('Edge detection with sobel mask'); BW = edge(A,'roberts'); subplot(3,2,4); imshow(BW);;title('Edge detection with roberts mask'); E.C. Department, Government Engineering College, Rajkot Page 55 BW = edge(A,'log'); subplot(3,2,5); imshow(BW);;title('Edge detection with log '); BW = edge(A,'zerocross'); subplot(3,2,6); imshow(BW);;title('Edge detection with zerocorss'); MATLAB Code for edge detection using convolution in spatial domain % EC Department, GEC Rajkot % Experiment 9 % Program to demonstrate various point and edge detection mask % Image Processing Lab, EC Department, GEC Rajkot clear all; clc; while 1 K = menu('Choose mask','Select Image File','Point Detect','Horizontal line detect','Vertical line detect','+45 Detect','-45 Detect','ractangle Detect','exit') M=[-1 0 -1; 0 4 0; -1 0 -1;] % Default mask switch K case 1, [namefile,pathname]=uigetfile({'*.bmp;*.tif;*.tiff;*.jpg;*.jpeg;*.gif','IMAGE Files (*.bmp,*.tif,*.tiff,*.jpg,*.jpeg,*.gif)'},'Chose GrayScale Image'); data=imread(strcat(pathname,namefile)); %data=rgb2gray(data); imshow(data); case 2, M=[-1 -1 -1;-1 8 -1;-1 -1 -1]; % Mask for point detection case 3, M=[-1 -1 -1; 2 2 2; -1 -1 -1]; % Mask for horizontal edges case 4, M=[-1 2 -1; -1 2 -1; -1 2 -1]; % Mask for vertical edges case 5, M=[-1 -1 2; -1 2 -1; 2 -1 -1]; % Mask for 45 degree diagonal line case 6, M=[2 -1 -1;-1 2 -1; -1 -1 2]; % Mask for -45 degree diagonal line case 7, M=[-1 -1 -1;-1 8 -1;-1 -1 -1]; case 8, break; otherwise, msgbox('Select proper mask'); end outimage=conv2(double(data),double(M)); figure; imshow(outimage); end close all %Write an image to a file Lab Manual of Fundamentals of Image Processing Page 56 Government Engineering College. Department.C.99).imwrite(mat2gray(outimage). Rajkot Page 57 .jpg'. “Canny”. “Sobel” from the literature and write MATLAB/SCILAB program for edge detection using 2D convolution _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ E.'outimage.'quality'. :: WORKSHEET :: [1] Get mask for “Prewitt”. h> # define rows 10 # define cols 10 class image { private: int data[10][10]. int k=rows*cols. j<cols. int i.j.h> # include <conio. j++) { Lab Manual of Fundamentals of Image Processing Page 58 . void edge_detect(char[]). }.h> # include <string. i<rows.cpp //file image. Image class and member function are written in Image.h> # include <stdio. for(i=0._____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ [2] Understand following C++ program written for edge detection. Different member functions are written for image class. void read_image(char[]).h # include <iostream.i++) { for(j=0. void image::write_image(char filename[]) { FILE *f1.h header file and used in main program in file image. f1=fopen(filename. public: void write_image(char[])."wb"). j++) { cout<<data[i][j]<<" ". for(a=-1. } void image::read_image(char filename[]) { FILE *f1. E.f1).cin>>data[i][j].b<2. outimage[i][j]=sum. long m. f1=fopen(filename. fclose(f1). } } cout<<"\nEdge detection using Quick mask:"<<endl.sizeof(int). outimage[i][j]). short QM[3][3]={{-1.b. i<rows.diff.j. } } fwrite(data. int k=rows*cols."rb").f1).sum. } fclose(f1). } cout<<endl.{0.k.0. for(i=0. j<cols-1.outimage[rows][cols]. i<rows-1. int k=rows*cols. } fclose(f1).-1}. Government Engineering College. for(i=0. Rajkot Page 59 .C.a. a++) { for(b=-1. for(i=1.i++) { for(j=0.0.maxdiff.{-1. cout<<endl. j++) { sum=0. a<2.0}.sizeof(int).k. } void image::edge_detect(char *filename) { int i.i++) { for(j=1.i++) { for(j=0.j. min=0. for(i=0. fread(data. int i.b++) sum=sum+data[i+a][j+b]*QM[a+1][b+1]."rb").max=15. i<rows. Department. int threshold=8.4.sizeof(int). j<cols.f1). j++) outimage[i][j]=0. j<cols.i++) { for(j=0.-1}}. if(sum>16) sum=15. j++) printf("%02d ". f1=fopen(filename.k. FILE *f1. i<rows. j<cols. } if(sum<0) sum=0. } fread(data. printf("\n\t\t hist : display histogram of image\n"). printf("\t\t\timage <operation> <filename>\n").} else if(!strcmp(argv[1]. printf("\n\t\t edge : Edge detection\n").} } void help() { printf("\n\t\t Image Processing Tutorial !"). } else { strcpy(file_name.file_name).} //file Image. printf("\n\t\t read: read image\n").} else if(!strcmp(argv[1]. printf("\t\t\tUsage :\n").cpp # include "d:\image\image. printf("\t\t\tFor example :\n "). } Lab Manual of Fundamentals of Image Processing Page 60 ."hist")) { } else {help(). void main(int argc.h" void help().argv[2])."edge")) { I.write_image(file_name)."read")) {I. char* argv[]) { image I. scanf("%s". } else if(!strcmp(argv[1]. if(argv[1]) { if(!argv[2]) { printf("Enter file name: "). char file_name[30].edge_detect(file_name)."write")) {I.} } else {help(). } if(!strcmp(argv[1].read_image(file_name). printf("\n\t\t\tOther Operations:\n"). clrscr(). printf("\t\t\timage write data : To write image in \"data\" file\n"). Government Engineering College. Department.C. prewitt & sobel mask [2] Add member function LPF() to image class for spatial filtering of given image Hint: Use following low pass convolution mask for low pass filtering 1/6 * 0 1 0 1 2 1 0 1 0 E. Rajkot Page 61 .Output: Original Image of size 1010: Edge detection after applying quick mask: 1111111111 00 00 00 00 00 00 00 00 00 00 1111111111 00 00 00 00 00 00 00 00 00 00 1111111111 00 00 00 00 00 00 00 00 00 00 1119999111 1119999111 00 00 00 15 16 16 15 00 00 00 1119999111 00 00 00 16 00 00 16 00 00 00 1119999111 00 00 00 16 00 00 16 00 00 00 1111111111 1111111111 1111111111 Exercise: [1] Modify above program for edge detection using kirsch.  Dilation adds pixels to the boundaries of objects in an image. EC Department.'Opening'. Program: % Program to demonstrate Erosion and Dilation % Image Processing Lab. while erosion removes pixels on object boundaries. Lab Manual of Fundamentals of Image Processing Page 62 .'EXIT') %B=[1 1 1.  Opening and closing operations can be done by combination of erosion and dilation in different sequence. 11 AIM: Write and execute program for image morphological operations: erosion and dilation Introduction:  Morphology is a branch of biology that deals with form and structure of animal and plant  In image processing.'Dilation'. Erosion and dilation are two fundamental image morphological operations.'Choose Image'. Thinning.EXPERIMENT NO. while erosion removes pixels on object boundaries. while 1 K = menu('Erosion and dilation demo'.'Choose 5x5 Mask'. the output pixel is set to 1.1 1 1.]. Skeletons.'Choose Structure Image'. clc.1 1 1. In a binary image. 'Closing'. we use mathematical morphology to extract image components which are useful in representation and description of region shape such as … Boundaries.  Two Fundamental morphological operations are: Erosion and dilation  Dilation adds pixels to the boundaries of objects in an image.'Choose 3x3 Mask'. GEC Rajkot clear all. if any of the pixels is set to 0. Pruning etc. In a binary image.'Erosion'. the output pixel is set to 0.  Dilation operation: The value of the output pixel is the maximum value of all the pixels in the input pixel’s neighborhood. if any of the pixels is set to the value 1.  Erosion operation: The value of the output pixel is the minimum value of all the pixels in the input pixel’s neighborhood. Convex hull. bmp. C=imerode(A. [namefile.B). imshow(A).tif. Department.'Chose GrayScale Image').1 1 1 1 1.1 1 1.B).*. C=imerode(A.bmp. imshow(D) case 9. imshow(C). switch K case 1.jpg.*.bmp. [namefile.bmp. figure.gif)'}.1 1 1.*.*.namefile)).*.pathname]=uigetfile({'*. case 6. break.tiff.1 1 1 1 1. figure. case 3.gif'.'IMAGE Files (*.B = strel('disk'.*.*. B=imread(strcat(pathname. case 4.B).1 1 1 1 1.jpeg. *.tiff.gif)'}.jpeg.namefile)). *. imshow(C) case 7.B).*.'IMAGE Files (*. otherwise.jpeg.tif.B). E.jpg. B=[1 1 1 1 1. %data=rgb2gray(data).tif.jpg. Rajkot Page 63 . figure.*. case 2.*.tiff. *. imshow(B).gif'.C. Government Engineering College. 5).B). imshow(D) case 8.*.pathname]=uigetfile({'*. %B = strel('disk'.]. C=imdilate(A. C=imdilate(A.jpg. D=imdilate(C.*. 9). case 5.1 1 1 1 1. *.*. figure.].tiff.jpeg. figure. D=imerode(C.*.*.tif. B=[1 1 1.*.'Chose GrayScale Image'). %data=rgb2gray(data). A=imread(strcat(pathname. 99). WORKSHEET :: [1] What is cryptography? ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------[2] What is sateganography? ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------[3] How watermarking differs from cryptography and sateganography? ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Execute above program given in this experiment on suitable image. Lab Manual of Fundamentals of Image Processing Page 64 .msgbox('Select proper mask').jpg'. end end close all %Write an image to a file imwrite(mat2gray(outimage).'quality'.'outimage. cut and paste resultant images on separate page and write your conclusion. Rajkot Page 65 . seismic etc.  Wavelets are oscillatory functions vanishing outside the small interval hence. video. Government Engineering College. Basis functions of Fourier transform is sinusoids while basis functions of wavelet transform is wavelets.C.EXPERIMENT NO. 12 AIM: To write and execute program for wavelet transform on given image and perform inverse wavelet transform to reconstruct image. biomedical.  Wavelets are building blocks of the signal. Introduction: Wavelet transform is relatively recent signal and image processing tool which has many applications. Department.  Wavelets can be used to de-correlate the correlations present in real time signal such as speech/audio.  Wavelets are the functions which are well suited to the expansion of real time non-stationary signals. General block diagram of two dimensional wavelet transform: E. they are called wavelets. wave-let (small fraction of wave). db2. db2.S. Outputs are the decomposition vector C and the corresponding bookkeeping matrix S. X = WAVEREC2(C. [3] detcoef2: This function utilize tree develet by wavelet decomposition function and generates detail coefficients for 2D data. [2] appcoef2: This function utilize tree developed by wavelet decomposition function and constructs approximate coefficients for 2D data. db3 or any other wavelet).'wname') reconstructs the matrix X based on the multilevel wavelet decomposition structure [C. [4] waverec2: Multilevel wavelet 2D reconstruction (Inverse wavelet transform) WAVEREC2 performs a multilevel 2-D wavelet reconstruction using wavelet named in string 'wname' (wavelet name can be Daubechies wavelet db1. vertical and diagonal detail coefficients respectively. A = APPCOEF2(C.'wname'.N. [C. D = DETCOEF2(O.'wname') returns the wavelet decomposition of the matrix X at level N.Following standard matlab functions are used in this experiment. N is level of decomposition which must be positive integer. vertical or diagonal detail coefficients for O = 'h' or 'v' or 'd'.N) extracts from the wavelet decomposition structure [C.S] which is generated by function wavedec2.S] = WAVEDEC2(X.N) computes the approximation coefficients at level N using the wavelet decomposition structure [C. for horizontal. using the wavelet named in string 'wname' (wavelet name can be Daubechies wavelet db1.S.S. [1] wavedec2 : Function for multi-level decomposition of 2D data using wavelet transform. db3 or any other wavelet). the horizontal.S] which is generated by wavedec2 Lab Manual of Fundamentals of Image Processing Page 66 .C.S]. s.*. end imshow(X). ch2 = detcoef2('h'.s.s.*. ca2 = appcoef2(c.1).jpg.'db1').2.2.[]).2).title('Second level diagonal detail').2.c.title('First level vertical detail'). figure. subplot(2.imshow(cd1. subplot(2. Department.'db1').tiff. subplot(2. Rajkot Page 67 .s. title('Wavelet decomposition data generated by wavedec2'). cv1 = detcoef2('v'.3)==3) X=rgb2gray(X). Execute program given in this experiment on suitable image.'db1'.*.gif)'}. subplot(2.jpg.'Chose GrayScale Image').imshow(ca1. % Perform wavelet decomposition at level 2.1).*.2.2).s.c. a0 = waverec2(c.imshow(cv1. and detail components ca1 = appcoef2(c.'IMAGE Files (*.gif'.title('Second level approx').title('Second level horizontal detail').C. subplot(2.s] = wavedec2(X.[]). Government Engineering College. imshow(a0.[]).title('First level horixontal detail').tiff.*.*.Program: clc.s.title('First level diagonal detail').title('Second level vertical detail'). and detail components figure.2.[]).2. imshow(c.[]).c.title('First level approx').s. X=imread(strcat(pathname.bmp. subplot(2. ch1 = detcoef2('h'.1). [namefile.pathname]=uigetfile({'*. figure. [c.imshow(ca2.2).namefile)).2.jpeg.[]).[]).title('Reconstructed image using inverse wavelet transform').imshow(cd2.c.imshow(ch2.bmp. cd1 = detcoef2('d'.s. subplot(2.2).s.4). subplot(2.tif. cd2 = detcoef2('d'.1).c.*.[]). if(size(X.*.1).3). %Calculate second level approx.imshow(cv2.3).2.[]).2.tif. cv2 = detcoef2('v'.c. figure.*.*. E.4).'db1'.1).imshow(ch1. cut and paste resultant images on separate page and write your conclusion.jpeg.[]).2).2). %Calculate first level approx. close. (Hint: use matlab function wfilters() to find filter coefficients) ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Lab Manual of Fundamentals of Image Processing Page 68 .:: WORKSHEET :: [1] What is wavelet ? ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------[2] How wavelet transform used to remove noise from the image? ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------[3] Write analysis low pass and high pass wavelet filter coefficients for Daubechies-2.4 and 8 wavelets.
Copyright © 2024 DOKUMEN.SITE Inc.