1 / 15

Digital Image Processing

Digital Image Processing. With. Matlab. Prof. Muhammad Saeed. Contents. Fundamentals. Introduction to Image:. Image as matrix Image Type Image Class Image Size Image Resolution. Filename: [1x64 char] FileModDate : '24-Oct-2011 16:51:40' FileSize : 48613 Format: 'jpg'

olwen
Download Presentation

Digital Image Processing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Digital Image Processing With Matlab Prof. Muhammad Saeed

  2. Contents MS Image Processing

  3. Fundamentals Introduction to Image: Image as matrix Image Type Image Class Image Size Image Resolution Filename: [1x64 char] FileModDate: '24-Oct-2011 16:51:40' FileSize: 48613 Format: 'jpg' FormatVersion: ‘' Width: 344 Height: 401 BitDepth: 24 ColorType: 'truecolor' FormatSignature: '' NumberOfSamples: 3 CodingMethod: 'Huffman' CodingProcess: 'Sequential' Comment: {} ImageDescription: 'OLYMPUS DIGITAL CAMERA’ Make: 'OLYMPUS OPTICAL CO.,LTD' Model: 'C4040Z' Orientation: 1 Software: 'v552u-A80' DateTime: '2001:01:02 06:01:42' YCbCrPositioning: 'Co-sited' DigitalCamera: [1x1 struct] UnknownTags: [3x1 struct] Read: kid=imread('kid02.jpg'); Image Info: info=imfinfo('kid02.jpg'); or whos kid; [r c]=size(kid); Display: figure; imshow(kid); imshow(kid, [low high]); MS Image Processing

  4. Write on Disk: imwrite(kid,'kid02gray.png'); imwrite(kid,'kid02gray.jpg’,’quality’,75); % (0:100) imwrite(kid,'kid02gray.tif’,’compression’,’none’,‘resolution’,[m n]); % (packbits, ccitt), (dpi) Conversion of Class and Type: B=logical(A); C=im2bw(T); D=mat2gray(P,[Pmin Pmax]); F=Im2double(g); G=im2uint8(H); Image Arithmatic: C=imadd(A,B); C=imsubtract(A,B); C=immultiply(A,B); C=imdivide(A,B); C=imabsdiff(A,B); C=imcomplement(A); C=imlincomb(A,B); MS Image Processing

  5. Image Flipping and Sizing: C=F(end:-1:1,:); C=F(:, end:-1:1); C=F(1:2:end,1:2:end); Image Cropping: C=F(50:end-20, 50:end-40); Pixel Information Direct: impixelinfo; imdistline; Color Image to Gray: C=rgb2gray(F); MS Image Processing

  6. Spatial Domain Processing Intensity Transformation: • S=imadjust(A,[inLinH],[outLoutH],gamma); • S=imadjust(A,[0 1],[1 0]); %image complement • S=imadjust(A,[],[],2); • Logarithmic and Contrast Stretching Transform i) ii) • Histograms H=imhist(A,nbins); H=imhist(A,nbins)/numel(A); % normalized histogram H=histeq(A,nbins); % histogram equalization MS Image Processing

  7. Linear Spatial Filtering: C=imfilter(A, w, ‘mode’, ‘boundary opts’, ‘size opts’); % w is the filter % modes= corr, conv % boundary options=p, replicate, symmetric, circular % size options=full, same w=fspecial(‘type’, parameters); typeparameters default average [r, c] 3x3 disk R (radius, square of 2R+1) 5 gaussian [r, c],sig(STD) 3x3, 0.5 laplacian(3x3) alpha(0-1) 0.5 log(laplacian [r, c],sig(STD) 5x5, 0.5 of a gaussian) motion len(pixel), theta(degrees)CCW 9, 0 prewitt(3x3, verticle gradient, transpose for horizontal) sobel(3x3, verticle gradient, transpose for horizontal) unsharp(3x3) alpha(0-1) 0.2 MS Image Processing

  8. Mathematical Form of Filters: Sobel: I, and II, Prewitt: and II, I, Gaussian Filter: Laplacian Filter: Unsharp Filter: MS Image Processing

  9. Linear Spatial Filters in action: 1. kid=imread('kid02.jpg'); w=[1 1 1;1 -8 1;1 1 1]; C=imfilter(kid, w,'corr', 'replicate', 'same'); subplot(1,2,1);imshow(kid);title('Original','FontSize',20); subplot(1,2,2);imshow(4*C);title(mat2str(w),'FontSize',20); 2. chboard=(checkerboard(90)>0.1); w=[0 1 0;1 -4 1;0 1 0]; C=imfilter(chboard, w,'conv','replicate', 'full'); subplot(1,2,1);imshow(chboard);title('Original','FontSize',20); subplot(1,2,2);imshow(4*C);title(mat2str(w),'FontSize',20); 3. kid=imread('kid02.jpg'); w=fspecial('average',[10 10]); C=imfilter(kid, w,'conv','replicate','same'); subplot(1,2,1);imshow(kid);title('Original','FontSize',20); subplot(1,2,2);imshow(C);title('Average','FontSize',20); average MS Image Processing

  10. 4. kid=imread('kid02.jpg'); w=fspecial('disk', 6); C=imfilter(kid, w); subplot(1,2,1);imshow(kid);title('Original','FontSize',20); subplot(1,2,2);imshow(C);title('Disk','FontSize',20); disk 5. kid=imread('kid02.jpg'); w=fspecial('gaussian',10, 0.8); C=imfilter(kid, w); subplot(1,2,1);imshow(kid);title('Original','FontSize',20); subplot(1,2,2);imshow(C);title('Gaussian','FontSize',20); gaussian 6. kid=imread('kid02.jpg'); w=fspecial('laplacian', 0.6); C=imfilter(kid, w,'conv','replicate','same'); subplot(1,2,1);imshow(kid);title('Original','FontSize',20); subplot(1,2,2);imshow(6*C);title('Laplacian','FontSize',20); laplacian MS Image Processing

  11. 7. kid=imread('kid02.jpg'); w=fspecial('log',5,0.2); C=imfilter(kid, w,'conv','replicate','same'); subplot(1,2,1);imshow(kid);title('Original','FontSize',20); subplot(1,2,2);imshow(4*C);title('Log','FontSize',20); log 8. kid=imread('kid02.jpg'); w=fspecial('motion',20,10); C=imfilter(kid, w); subplot(1,2,1);imshow(kid);title('Original','FontSize',20); subplot(1,2,2);imshow(C);title('Motion','FontSize',20); motion 9. kid=imread('kid02.jpg'); w=fspecial('prewitt'); C=imfilter(kid, w); subplot(1,2,1);imshow(kid);title('Original','FontSize',20); subplot(1,2,2);imshow(C);title('Prewitt','FontSize',20); prewitt MS Image Processing

  12. 10. kid = imread('kid02.jpg'); w = fspecial('sobel'); C=imfilter(kid, w); subplot(1,2,1);imshow(kid);title('Original','FontSize',20); subplot(1,2,2);imshow(C);title('Sobel','FontSize',20); sobel 11. kid = imread('kid02.jpg'); w = fspecial('unsharp',0.5); C=imfilter(kid, w); subplot(1,2,1);imshow(kid),title('Original','FontSize',20); subplot(1,2,2);imshow(C),title('Unsharp','FontSize',20); unsharp 12. kid=imread('kid02Gray.jpg'); C=filter2('sobel',kid); subplot(1,2,1);imshow(kid);title('Original','FontSize',20); subplot(1,2,2);imshow(C,[]);title('Filtered Red','FontSize',20); filter2 MS Image Processing

  13. 13. kid=imread('kid02darkgray.jpg'); subplot(2,2,1); imshow(kid);title('Original','FontSize',20); subplot(2,2,2); imhist(kid,64);title('Histogram I','FontSize',20); subplot(2,2,3); heq=histeq(kid,64); imshow(heq,[]); title(‘Equalized','FontSize',20); subplot(2,2,4); imhist(heq,64); title('Eq. Histogram','FontSize',20); histeq MS Image Processing

  14. Nonlinear Spatial Filters: • ordfilt2 (f, order, domain) kid=imread('kid02darkgray.jpg'); kidfilt=ordfilt2(kid,25,true(7)); subplot(1,2,1);imshow(kid); title('Original','FontSize',20); subplot(1,2,2);imshow(kidfilt); title(‘Filtered','FontSize',20); 2) medfilt2 (f, ’symmetric’) kid=imread('kid02Gray.jpg'); kidnoise=imnoise(kid,'salt & pepper',0.2); kid2=medfilt2(kidnoise,[5 5],'symmetric'); %symmetric, zeros, indexed %kid2=medfilt2(kid2,'symmetric'); subplot(1,2,1);imshow(kidnoise);title('Original','FontSize',20); subplot(1,2,2);imshow(kid2);title('Filtered','FontSize',20); MS Image Processing

  15. END MS Image Processing

More Related