Beruflich Dokumente
Kultur Dokumente
Date: 11/02/2013
CGPIT
Page 1
CGPIT
Page 2
Work Space:
CGPIT
Page 3
Conclusion: From this Experiment we have concluded that we can change parameters of any
images with only one simple function using MATLAB
CGPIT
Page 4
Date: 18/02/2013
Program:
clc; clear all; close all; t=imread('peppers.png'); subplot(1,3,1);imshow(t);title('colour'); r=t(:,:,1); g=t(:,:,2); b=t(:,:,3); Y=0.2989 * r + 0.5870 * g + 0.1140 * b; subplot(1,3,2);imshow(Y);title('gray'); [m,n]=size(Y); z=zeros(m,n); for i=1:m for j=1:n if Y(i,j)<128 z(i,j)=0; else z(i,j)=1; end end end subplot(1,3,3);imshow(z);title('binary'); %%
CGPIT
Page 5
Fundamental of Image Processing %%spatial resolution B1 = imresize(t,[192,256]); B2 = imresize(t,[90,128]); B3 = imresize(t,[45,64]); figure; subplot(2,2,1);imshow(t); subplot(2,2,2);imshow(B1); subplot(2,2,3);imshow(B2); subplot(2,2,4);imshow(B3);
%%intensity resolution figure; t1=imread('C:\Program Files\MATLAB\R2010a\toolbox\images\imdemos\html\ctskull.tif'); for i=1:8 J=t1/(2^i); subplot(2,4,i);imshow(J,[]); end
CGPIT
Page 6
CGPIT
Page 7
Conclusion:
In part(A), we have converted the Original Color image into Graylevel image by adding the different planes of original color image. In part (B), we have converted Graylevel image into binary image by converting 8 bit image into 2-bit image. In part (C), we have complemented the binary image to get the negative of binary image. In part(D), Spatial Resolution is done by resizing the Original image, whereas Intensity Resolution represents the image having decreased Intensity levels.
CGPIT
Page 8
Date: 25/02/2013
A. Intensity transformation using Negative, Log and Gamma (power law) transformation of Gray Scale Image. Comment on results. B. Take 4 types of images: dark, light, high contrast, low contrast and compare their histogram. Comment on results. C. Enhance contrast of an intensity image using histogram equalization of Part (b). Display and compare the histogram of the original and processed image.
Program:
clc; clear all; close all;
%% To find Negative Image I=imread('tire.tif'); figure(); subplot(121); imshow(I); title('original image'); J=imcomplement(I); subplot(122); imshow(J); title('negative image');
a=imread('tire.tif'); A=double(a); [m n]=size(A); L=zeros(256,1); for i=1:m; for j=1:n; for k=1:256; if (A(i,j)==k) L(k)=L(k)+1; end end end CGPIT
%% it can store large number of variable %% for finding number of rows and columns
Page 9
subplot(121); stem(L); %% for ploting the histogram title('calculated histrogram'); subplot(122); imhist(a); %% for ploting the histogram title('direct histrogram');
%% To find Log Transform I=imread('tire.tif'); I1=im2double(I); M1=1*log(1+I1); M2=2*log(1+I1); M3=5*log(1+I1); figure(); subplot(221); imshow(I); title('Original Image'); subplot(222); imshow(M1) title('Image with c=1'); subplot(223); imshow(M2) title('Image with c=2'); subplot(224); imshow(M3) title('Image with c=3');
%% s=c*log(1+r)
Fundamental of Image Processing J2=imadjust(I,[],[],3); J3=imadjust(I,[],[],0.4); figure(); subplot(131); imshow(J1); title('image with gamma =1'); subplot(132); imshow(J2); title('image with gamma =3'); subplot(133); imshow(J3); title('image with gamma =0.4');
%% To Perform Histogram Equilization I = imread('tire.tif'); figure,imshow(I); J = histeq(I); %% Histogram Equalization subplot(2,2,1); imshow(I); title('Original Image'); subplot(2,2,2); imshow(J); title('Processed Image');
%% Processed image
subplot(2,2,3); imhist(I,64); title('Histogram of Original Image'); %% Histogram of the original image. subplot(2,2,4); imhist(J,64); title('Histogram of Processed Image'); %% Histogram of the processed image
CGPIT
Page 11
CGPIT
Page 12
CGPIT
Page 13
Fundamental of Image Processing Part (B) & (C) histogram and equalized histogram 4 different images
Conclusion: In part (A) we have converted Gray level image into negative image by
complementing the intensity values. When we apply Log Transform to the original image, darker portion of image is scaled in brighter portion. In Gamma Transformation, if gamma<1, it will gives the brighter image while gamma>1 gives darker image than original one. In part (B)we have read the 4- types of images and plotted the histogram and we can see that intensity levels are in random nature. In part (C) we have performed the Histogram equalization of image and observe that intensity levels are well distributed overall
CGPIT
Page 14
Practical No: 4
Date: 04/03/2013
Aim: To perform bit plane slicing of an 8 bit image and reconstruct it again. Program:
clc; close all; clear all; I=imread('C:\Program Files\MATLAB\R2010a\toolbox\images\imdemos\cameraman.tif'); imshow(I); [row,col]=size(I); bit_slicing=zeros(row,col); % bit_slicing(:,:)=255; % n=input('enter the value of bit:');
figure, for n = 1:8 for x=1:1:row for y=1:1:col bit_slicing(x,y,n)= bitand(I(x,y),2^(n)); end end subplot(3,3,n); imshow(uint8(bit_slicing(:,:,n)),[]); end %Image reconstruction by combining 8 bit planes A=imread(':\Program Files\MATLAB\R2010a\toolbox\images\imdemos\cameraman.tif'); B=zeros(size(A)); B=bitset(B,8,bitget(A,8)); B=bitset(B,7,bitget(A,7)); B=bitset(B,6,bitget(A,6)); B=bitset(B,5,bitget(A,5)); B=bitset(B,5,bitget(A,4)); B=bitset(B,5,bitget(A,3)); B=bitset(B,5,bitget(A,2)); B=bitset(B,5,bitget(A,1)); B=uint8(B); figure,imshow(B);
Page 15
CGPIT
CGPIT
Page 16
Conclusion: From this Experiment we have done bit plane slicing of 8 bit Gray Scale image &
reconstruct it from these 8 bit slices of 8 bit images using bitset & bitget functions.
CGPIT
Page 17
Date: 11/03/2013
- Read an image and then corrupt it by salt and pepper, Gaussian, speckle noise then apply A. AVERAGING filter with 3x3 mask and 5X5 mask. B. MEDIAN filter with 3x3 and 5x5 mask. C. Max, Min, Midpoint filter with 3x3 and 5x5 mask. - Comment on the result
Program:
clc; clear all; close all;
I = imread('cameraman.tif'); B=imnoise(I,'salt & pepper'); C=imnoise(I,'gaussian'); D=imnoise(I,'speckle'); % Salt & Pepper Noise subplot(121);imshow(I),title('Original Image'); subplot(122);imshow(B),title('Salt & Pepper Noise'); h = fspecial('average',[3 3]); I2 = filter2(h,B)/255; figure();subplot(121); imshow(I2),title('Averaging Filter 3*3'); h1 = fspecial('average',[5 5]); I3 = filter2(h1,B)/255; subplot(122);imshow(I3);title('Averaging Filter 5*5'); h2 = medfilt2(B,[3 3]); h3 = medfilt2(B,[5 5]); figure,subplot(121); imshow(h2),title('Median Filter 3*3'); subplot(122);imshow(h3),title('Median Filter 5*5'); figure(); f = ordfilt2(B, 1, ones(3, 3)); f1 = ordfilt2(B, 9, ones(3, 3)); f2 = 0.5 * (f + f1); subplot(131);imshow(f);title('MIN FILTER 3*3'); subplot(132);imshow(f1);title('MAX FILTER 3*3'); subplot(133);imshow(f2);title('MIDPOINT FILTER 3*3');
CGPIT
Page 18
Fundamental of Image Processing figure(); f5 = ordfilt2(B, 1, ones(5, 5)); f15 = ordfilt2(B, 9, ones(5, 5)); f25 = 0.5 * (f5 + f15); subplot(131);imshow(f5);title('MIN FILTER 5*5'); subplot(132);imshow(f15);title('MAX FILTER 5*5'); subplot(133);imshow(f25);title('MIDPOINT FILTER 5*5');
% Gaussian Noise subplot(121);imshow(I),title('Original Image'); subplot(122);imshow(C),title('Gaussian Noise'); g = fspecial('average',[3 3]); I1G = filter2(g,C)/255; figure();subplot(121); imshow(I1G),title('Averaging Filter 3*3'); h1G = fspecial('average',[5 5]); I3G = filter2(h1G,C)/255; subplot(122);imshow(I3G);title('Averaging Filter 5*5'); h2G = medfilt2(C,[3 3]); h3G = medfilt2(C,[5 5]); figure,subplot(121); imshow(h2G),title('Median Filter 3*3'); subplot(122);imshow(h3G),title('Median Filter 5*5'); figure(); fG = ordfilt2(C, 1, ones(3, 3)); f1G = ordfilt2(C, 9, ones(3, 3)); f2G = 0.5 * (fG + f1G); subplot(131);imshow(fG);title('MIN FILTER 3*3'); subplot(132);imshow(f1G);title('MAX FILTER 3*3'); subplot(133);imshow(f2G);title('MIDPOINT FILTER 3*3'); figure(); f5G = ordfilt2(C, 1, ones(5, 5)); f15G = ordfilt2(C, 9, ones(5, 5)); f25G = 0.5 * (f5G + f15G); subplot(131);imshow(f5G);title('MIN FILTER 5*5'); subplot(132);imshow(f15G);title('MAX FILTER 5*5'); subplot(133);imshow(f25G);title('MIDPOINT FILTER 5*5');
CGPIT
Page 19
Fundamental of Image Processing % Speckle Noise subplot(121);imshow(I),title('Original Image'); subplot(122);imshow(D),title('Speckle Noise'); hs = fspecial('average',[3 3]); I2s = filter2(hs,D)/255; figure();subplot(121); imshow(I2s),title('Averaging Filter 3*3'); h1s = fspecial('average',[5 5]); I3s = filter2(h1s,D)/255; subplot(122);imshow(I3s);title('Averaging Filter 5*5'); h2s = medfilt2(D,[3 3]); h3s = medfilt2(D,[5 5]); figure,subplot(121); imshow(h2s),title('Median Filter 3*3'); subplot(122);imshow(h3s),title('Median Filter 5*5'); figure(); fs = ordfilt2(D, 1, ones(3, 3)); f1s = ordfilt2(D, 9, ones(3, 3)); f2s = 0.5 * (fs + f1s); subplot(131);imshow(fs);title('MIN FILTER 3*3'); subplot(132);imshow(f1s);title('MAX FILTER 3*3'); subplot(133);imshow(f2s);title('MIDPOINT FILTER 3*3'); figure(); f5s = ordfilt2(D, 1, ones(5, 5)); f15s = ordfilt2(D, 9, ones(5, 5)); f25s = 0.5 * (f15s + f5s); subplot(131);imshow(f5s);title('MIN FILTER 5*5'); subplot(132);imshow(f15s);title('MAX FILTER 5*5'); subplot(133);imshow(f25s);title('MIDPOINT FILTER 5*5');
CGPIT
Page 20
CGPIT
Page 21
Fundamental of Image Processing Median Filter on Salt & Pepper Noise Image:
CGPIT
Page 22
Fundamental of Image Processing Minimum,Maximum & Midpoint(5*5) Filter on Salt & Pepper Noise Image:
CGPIT
Page 23
CGPIT
Page 24
Fundamental of Image Processing Minimum,Maximum & Midpoint(3*3) Filter on Gaussian Noise Image:
CGPIT
Page 25
CGPIT
Page 26
CGPIT
Page 27
Fundamental of Image Processing Minimum,Maximum & Midpoint(5*5) Filter on Speckle Noise Image:
Conclusion:
We observe that smoothing makes the image blurred. When we apply average filtering the image is more blurred and it also removes the noise. When we apply the non linear filters like median, max and min filters then image is less blurred but it is more effective on the noise compare to averaging
CGPIT
Page 28
Date: 18/03/2013
A. To read an image and apply : Laplacian Second order filters B. To read an image and apply : Unsharp masking and High Boost filtering C. To read an image and apply : Gradient first order filters (Sobel and Prewitt Operator)
Program:
clc;clear all;close all; s=imread('cameraman.tif'); imshow(s);title('Original Image','FontSize',13); figure(); % % Laplacian Transform of Image lf1=fspecial('laplacian',0.5); lf=imfilter(s,lf1); imshow(lf);title('Image after laplacian Filter','FontSize',13); figure(); lf2=s-lf; imshow(lf2);title('Enhanced Image after laplacian','FontSize',13); figure(); % % Unsharp Masking of Image % uf1=fspecial('unsharp'); uf1=[-1 -1 -1;-1 8 -1;-1 -1 -1]; uf=imfilter(s,uf1); uf_image=s-uf; subplot(231); imshow(s); title('Original Image','FontSize',13); subplot(232); imshow(uf);title('Unsharp Masking of Image','FontSize',13); subplot(233); imshow(uf_image);title('Image after Unsharp Masking','FontSize',13); % % High Boost Filtering of Image hb1=[-1 -1 -1;-1 10 -1;-1 -1 -1]; hb=imfilter(s,hb1); hb_image=s-hb; subplot(234); imshow(s); title('Original Image','FontSize',13); subplot(235); imshow(hb_image); title('HighBoost Masking','FontSize',13); subplot(236); imshow(hb); title('Image After HighBost Filtering','FontSize',13); figure(); subplot(231); CGPIT Department of Electronics & Communication Engineering
Page 29
Fundamental of Image Processing imshow(s);title('Origanal image','FontSize',13); % %Horizontal Sobel Filter sb=fspecial('sobel'); sh=imfilter(s,sb); subplot(232); imshow(sh);title('Horizontal Sobel','FontSize',13); % % Vertical Sobel (vs=hs') Filter sb=sb'; sv=imfilter(s,sb); subplot(233); imshow(sv);title('Vertical Sobel','FontSize',13); % % Prewitt Horizontal Filter p=fspecial('prewitt'); ph=imfilter(s,p); subplot(234); imshow(ph);title('Horizontal Prewitt','FontSize',13); % % Vertical Prewitt (vp=hp') Filter p=p'; pv=imfilter(s,p); subplot(235) imshow(pv);title('Vertical Prewitt','FontSize',13);
CGPIT
Page 30
CGPIT
Page 31
Part: B
CGPIT
Page 32
Part: C
Conclusion:
After completion of this practical, we analyze that sharpening enhances the sweep changes in the intensity in the image and such changes becomes clearer in image. So, here details like edges of objects and lines enhanced
CGPIT
Page 33
Date: 25/03/2013
A. To read an image and apply: Low pass Ideal, Butterworth and Gaussian filter B. To read an image and apply: High pass Ideal, Butterworth and Gaussian filter Use cut-off frequency 5,10,15,80 and 230 for all above filters.
Program:
clc;clear all;close all; i=imread('cameraman.tif'); i1=fftshift(fft2(i)); s=input('Enter Order of Filter: '); [m n]=size(i1); D=0;H_5=0;H_15=0;H_30=0;H_80=0;H_230=0; for u=1:m for v=1:n; D(u,v)=sqrt((u-(m/2))^2+(v-(n/2))^2); % %Low pass Butterworth Filter LHB_5(u,v)=(1/(1+(D(u,v)/5)^2*s)); LHB_50(u,v)=(1/(1+(D(u,v)/50)^2*s)); LHB_200(u,v)=(1/(1+(D(u,v)/200)^2*s)); % %Low pass Gausian Filter LHG_5(u,v)=exp(-(D(u,v)^2/(2*(5)^2))); LHG_50(u,v)=exp(-(D(u,v)^2/(2*(50)^2))); LHG_200(u,v)=exp(-(D(u,v)^2/(2*(200)^2))); % %Ideal Low pass Filter if D(u,v)<=5; LH_5(u,v)=1; else LH_5(u,v)=0; end if D(u,v)<=50; LH_50(u,v)=1; else LH_50(u,v)=0; end if D(u,v)<=200; LH_200(u,v)=1; else LH_200(u,v)=0; end end end CGPIT Department of Electronics & Communication Engineering
Page 34
Fundamental of Image Processing % %Ideal Low pass Filter subplot(321); imshow(LH_5,[]); title('Ideal LP with D0=5','FontSize',13); i2=i1.*LH_5; i3=ifft2(ifftshift(i2)); subplot(322); imshow(uint8(i3),[]); title('Image of Ideal LP with D0=5','FontSize',13); subplot(323); imshow(LH_50,[]); title('Ideal LP with D0=50','FontSize',13); i2=i1.*LH_50; i3=ifft2(ifftshift(i2)); subplot(324); imshow(uint8(i3),[]); title('Image of Ideal LP with D0==50','FontSize',13); subplot(325); imshow(LH_200,[]); title('Ideal LP with D0=30','FontSize',13); i2=i1.*LH_200; i3=ifft2(ifftshift(i2)); subplot(326); imshow(uint8(i3),[]); title('Image of Ideal LP with D0=200','FontSize',13); figure();
% %Low pass Butterworth Filter subplot(321); imshow(LHB_5,[]); title('LP Butterworth with D0=5','FontSize',13); i2=i1.*LHB_5; i3=ifft2(ifftshift(i2)); subplot(322); imshow(uint8(i3),[]); title('Image of LP Butterworth with D0=5','FontSize',13); subplot(323); imshow(LHB_50,[]); title('LP Butterworth with D0=50','FontSize',13); i2=i1.*LHB_50; i3=ifft2(ifftshift(i2)); subplot(324); imshow(uint8(i3),[]); title('Image of LP Butterworth with D0=50','FontSize',13); subplot(325); imshow(LHB_200,[]); title('LP Butterworth with D0=200','FontSize',13); i2=i1.*LHB_200; i3=ifft2(ifftshift(i2)); subplot(326); imshow(uint8(i3),[]); title('Image of LP Butterworth with D0=200','FontSize',13); figure();
CGPIT
Page 35
Fundamental of Image Processing % %Low pass Gausian Filter subplot(321); imshow(LHG_5,[]); title('LP Gausian with D0=5','FontSize',13); i2=i1.*LHG_5; i3=ifft2(ifftshift(i2)); subplot(322); imshow(uint8(i3),[]); title('Image of LP Gausian with D0=5','FontSize',13); subplot(323); imshow(LHG_50,[]); title('LP Gausian with D0=50','FontSize',13); i2=i1.*LHG_50; i3=ifft2(ifftshift(i2)); subplot(324); imshow(uint8(i3),[]); title('Image of LP Gausian with D0=50','FontSize',13); subplot(325); imshow(LHG_200,[]); title('LP Gausian with D0=200','FontSize',13); i2=i1.*LHG_200; i3=ifft2(fftshift(i2)); subplot(326); imshow(uint8(i3),[]); title('Image of LP Gausian with D0=200','FontSize',13); figure(); % %Ideal high pass Filter subplot(321); HH_5=1.-LH_5; imshow(HH_5,[]); title('Ideal HP with D0=5','FontSize',13); i2=i1.*HH_5; i3=ifft2(ifftshift(i2)); subplot(322); imshow(uint8(i3),[]); title('Image of Ideal HP with D0=5','FontSize',13); HH_50=1.-LH_50; subplot(323); imshow(HH_50,[]); title('Ideal HP with D0=50','FontSize',13); i2=i1.*HH_50; i3=ifft2(ifftshift(i2)); subplot(324); imshow(uint8(i3),[]); title('Image of Ideal HP with D0=50','FontSize',13); subplot(325); HH_200=1.-LH_200; imshow(HH_200,[]); title('Ideal HP with D0=200','FontSize',13); i2=i1.*HH_200; i3=ifft2(ifftshift(i2)); subplot(326); imshow(uint8(i3),[]); title('Image of Ideal HP with D0=200','FontSize',13); figure();
CGPIT
Page 36
% %High Pass Butterworth Filter subplot(321); HHB_5=1.-LHB_5; imshow(HHB_5,[]); title('HP Butterworth with D0=5','FontSize',13); i2=i1.*HHB_5; i3=ifft2(ifftshift(i2)); subplot(322); imshow(uint8(i3),[]); title('Image of HP Butterworth with D0=5','FontSize',13); HHB_50=1.-LHB_50; subplot(323); imshow(HHB_50,[]); title('HP Butterworth with D0=50','FontSize',13); i2=i1.*HHB_50; i3=ifft2(ifftshift(i2)); subplot(324); imshow(uint8(i3),[]); title('Image of HP Butterworth with D0=50','FontSize',13); subplot(325); HHB_200=1.-LHB_200; imshow(HHB_200,[]); title('HP Butterworth with D0=200','FontSize',13); i2=i1.*HHB_200; i3=ifft2(ifftshift(i2)); subplot(326); imshow(uint8(i3),[]); title('Image of HP Butterworth with D0=200','FontSize',13); figure(); % %High pass Gaussian Filter subplot(321); HHG_5=1.-LHG_5; imshow(HHG_5,[]); title('HP Gausian with D0=5','FontSize',13); i2=i1.*HHG_5; i3=ifft2(ifftshift(i2)); subplot(322); imshow(uint8(i3),[]); title('Image of HP Gausian with D0=5','FontSize',13); subplot(323); HHG_50=1.-LHG_50; imshow(HHG_50,[]); title('HP Gausian with D0=50','FontSize',13); i2=i1.*HHG_50; i3=ifft2(ifftshift(i2)); subplot(324); imshow(uint8(i3),[]); title('Image of HP Gausian with D0=50','FontSize',13); subplot(325); HHG_200=1.-LHG_200; imshow(HHG_200,[]); title('HP Gausian with D0=200','FontSize',13); i2=i1.*HHG_200; i3=ifft2(fftshift(i2)); subplot(326); imshow(uint8(i3),[]); title('Image of HP Gausian with D0=200','FontSize',13); CGPIT Department of Electronics & Communication Engineering
Page 37
CGPIT
Page 38
CGPIT
Page 39
CGPIT
Page 40
Conclusion:
Hence, we apply the different filtering in frequency domain and observe the result of each on images and we also check results of first and second order filtering.
CGPIT
Page 41
Practical No: 8
A. Cyan, Magenta and Yellow B. Hue, Saturation and Intensity C. Luminance(Y),Hue(I) and Saturation(Q) (NTSC format) D. Y, Cb and Cr
Date: 25/03/2013
Aim: Read a full color image and obtain the following color space components;
Program:
clc; clear all; close all; t=imread('C:\Users\Public\Pictures\Sample Pictures\Hydrangeas.jpg'); imshow(t);title('Colour Image'); r=t(:,:,1); g=t(:,:,2); b=t(:,:,3); % %RGB to CMY C = 255-r; M = 255-g; Y = 255-b; figure(); subplot(1,3,1);imshow(C);title('CYAN'); subplot(1,3,2);imshow(M);title('Magenta'); subplot(1,3,3);imshow(Y);title('YELLOW'); figure(); I3=imcomplement(t); subplot(1,2,1);imshow(I3);title('Function CMY'); CMY_Img(:,:,1) = C; CMY_Img(:,:,2) = M; CMY_Img(:,:,3) = Y; subplot(1,2,2);imshow(CMY_Img);title('Equation CMY'); %%RGB to HSV figure(); H=rgb2hsv(t); imshow(H);title('HSV Image');
CGPIT
Page 42
Fundamental of Image Processing % %RGB to NTSC Y=0.2989 * r + 0.5870 * g + 0.1140 * b; I=0.596*r-0.274*g-0.322*b; Q=0.211*r-0.523*g+0.312*b; figure(); subplot(1,3,1);imshow(Y);title('Luminance'); subplot(1,3,2);imshow(I);title('HUE'); subplot(1,3,3);imshow(Q);title('Intensity'); figure(); I2=rgb2ntsc(t); subplot(1,2,1);imshow(I2);title('Using Function NTSC'); NTSC_Img(:,:,1) = Y; NTSC_Img(:,:,2) = I; NTSC_Img(:,:,3) = Q; subplot(1,2,2); imshow(NTSC_Img);title('Using Equation NTSC'); %RGB to YCbCr R=im2double(r); G=im2double(g); B=im2double(b); Y = 16 + (65.481*R+128.553*G+24.966*B); Cb = 128 + (-37.797*R-74.203*G+112*B); Cr = 128 + (112*R-93.786*G-18.214*B); figure(); subplot(1,3,1);imshow(uint8(Y));title('Y'); subplot(1,3,2);imshow(uint8(Cb));title('Cb'); subplot(1,3,3);imshow(uint8(Cr));title('Cr'); figure(); I4=rgb2ycbcr(t); subplot(1,2,1);imshow(I4);title('Function YCbCr'); YCbCr_Img(:,:,1) = Y; YCbCr_Img(:,:,2) = Cb; YCbCr_Img(:,:,3) = Cr; subplot(1,2,2);imshow(uint8(YCbCr_Img));title('Equation YCbCr');
CGPIT
Page 43
CGPIT
Page 44
Fundamental of Image Processing Part: A Cyan, Magenta & Cyan Components of Image:
CMY Images:
CGPIT
Page 45
CGPIT
Page 46
CGPIT
Page 47
Conclusion:
Hence, we learn to get the different detail from the colour image and observe the different operation on colour image.
CGPIT
Page 48
Date: 01/04/2013
A. Apply 2 level DWT on image. And Reconstruct image using IDWT B. Apply 1 level DWT and reconstruct image with consider following impact Replace Diagonal Plane element with all zero Replace Horizontal Plane element with all zero Replace Vertical Plane element with all zero Replace Low frequency Plane element with all zero
Find the similarity factor (normalized correlation) for all above case.
Program:
clc;clear all;close all; i=imread('C:\Users\PRADEEP\Desktop\woman.gif'); nbcol = size(i,1); [ll,lh,hl,hh]=dwt2(i,'db10'); subplot(221);imshow(i);title('Original Image'); subplot(222); % % 1-level DWT image representation cod_i = wcodemat(i,nbcol); cod_ll = wcodemat(ll,nbcol); cod_lh = wcodemat(lh,nbcol); cod_hl = wcodemat(hl,nbcol); cod_hh = wcodemat(hh,nbcol); d_1 = [... cod_ll, cod_hl; ... cod_lh, cod_hh ... ]; imshow(d_1,[]); title('1 Level Image','FontSize',13); % % 2-level DWT image representation [llll,lllh,llhl,llhh]=dwt2(ll,'db10'); nbcol = size(ll,2); subplot(223); cod_llll = wcodemat(llll,nbcol); cod_lllh = wcodemat(lllh,nbcol); cod_llhl = wcodemat(llhl,nbcol); CGPIT Department of Electronics & Communication Engineering
Page 49
Fundamental of Image Processing cod_llhh = wcodemat(llhh,nbcol); d1= [... cod_llll, cod_llhl; ... cod_lllh, cod_llhh ... ]; d_resized=imresize(d1,[137 137]); cod_d_resized = wcodemat(d_resized,nbcol); d2 = [... cod_d_resized, cod_hl; ... cod_lh, cod_hh ... ]; imshow(d2,[]); title('2 Level Image','FontSize',13); figure(); % % 2-level IDWT image representation rec_2=idwt2(llll,lllh,llhl,llhh,'db10'); subplot(131); imshow(i);title('Oriignal Image'); subplot(132); imshow(d1,[]); title('2 Level Image','FontSize',13); subplot(133); imshow(rec_2,[]); title('Reconstructed Image from 2level DWT','FontSize',13); figure(); % % 1-level IDWT image representation with hh=0 hh_0=zeros(137,137); rec_1=idwt2(ll,lh,hl,hh_0,'db10'); subplot(131); imshow(i);title('Oriignal Image'); subplot(132); imshow(d1,[]); title('1 Level Image','FontSize',13); subplot(133); imshow(rec_1,[]); title('Reconstructed Image with hh=0','FontSize',13); figure(); % % 1-level IDWT image representation with lh=0 lh_0=zeros(137,137); rec_1=idwt2(ll,lh_0,hl,hh,'db10'); subplot(131); imshow(i);title('Oriignal Image'); subplot(132); imshow(d1,[]); title('1 Level Image','FontSize',13); subplot(133); imshow(rec_1,[]); title('Reconstructed Image with lh=0','FontSize',13); figure(); % % 1-level IDWT image representation with hl=0 hl_0=zeros(137,137); rec_1=idwt2(ll,lh,hl_0,hh,'db10'); CGPIT Department of Electronics & Communication Engineering
Page 50
Fundamental of Image Processing subplot(131); imshow(i);title('Oriignal Image'); subplot(132); imshow(d1,[]); title('1 Level Image','FontSize',13); subplot(133); imshow(rec_1,[]); title('Reconstructed Image with hl=0','FontSize',13); figure(); % % 1-level IDWT image representation with ll=0 ll_0=zeros(137,137); rec_1=idwt2(ll_0,lh,hl,hh,'db10'); subplot(131); imshow(i);title('Oriignal Image'); subplot(132); imshow(d1,[]); title('1 Level Image','FontSize',13); subplot(133); imshow(rec_1,[]); title('Reconstructed Image with ll=0','FontSize',13);
CGPIT
Page 51
Fundamental of Image Processing 2 level DWT image & reconstucted image from it:
Part: B
CGPIT
Page 52
Fundamental of Image Processing 1 level DWT & reconstucted image with LH=0:
CGPIT
Page 53
Fundamental of Image Processing 1 level DWT & reconstucted image with LL=0:
Conclusion:
After completion of this practical we observe that in DWT the LL part contain almost all information of the original image, LH part contain horizontal and HL contain vertical information, HH part contain diagonal information. Now, if we remove the HH, LH or HL part from the DWT image almost all information is present in the image but if we remove LL part, very less detail of image remains.
CGPIT
Page 54
Practical No: 10 Aim: Read a gray scale image. Convert it into 4 gray level (2-bit) image.
Find out the probability of gray level (0,1,2,3) Find out Arithmetic code for the input sequence: 20131.
Date: 08/04/2014
Program:
clc;clear all;close all; i=imread('cameraman.tif'); subplot(131) imshow(i);title('Original Image'); subplot(132); i=double(i); i1=floor(i./64); [m,n]=size(i1); p=zeros(4,1); for j=1:m for k=1:n; for l=1:4 if i1(j,k)==l-1; p(l,1)=p(l,1)+1; end end end end imshow(i1,[]);title('2 Bit Image'); subplot(133); s=p/(m*n); bar(s);title('Histogram'); s1=sort(s); % % CDF for 1st step r11=s1(1,:); r12=r11+s1(2,:); r13=r12+s1(3,:); r14=r13+s1(4,:); r1=[r11 r12 r13 r14]' % % CDF for 2nd step for '2' r_21=r12; dif=r13-r12; r_22=r12+(dif*r12); r_23=r12+(dif*r13); r_24=r12+(dif*r14); CGPIT Department of Electronics & Communication Engineering
Page 55
Fundamental of Image Processing r_2=[r_21 r_22 r_23 r_24]' % % CDF for 3rd step for '0' r_01=r_21; dif=r_22-r_21; r_02=r_21+(dif*r12); r_03=r_21+(dif*r13); r_04=r_21+(dif*r14); r_0=[r_01 r_02 r_03 r_04]' % % CDF for 4th step for '1' r_11=0; dif=r_01-0; r_12=(dif*r12); r_13=(dif*r13); r_14=(dif*r14); r_1=[r_11 r_12 r_13 r_14]'
% % CDF for 5th step for '3' r_31=r_13; dif=r_14-r_13; r_32=r_13+(dif*r12); r_33=r_13+(dif*r13); r_34=r_13+(dif*r14); r_3=[r_31 r_32 r_33 r_34]' % % CDF for final step for '1' r_1_1=r_31; dif=r_32-r_31; r_1_2=r_31+(dif*r12); r_1_3=r_31+(dif*r13); r_1_4=r_31+(dif*r14); r_11=[r_1_1 r_1_2 r_1_3 r_1_4]'
CGPIT
Page 56
Output on Command Window: r1 = 0.0179 0.1773 0.4219 1.0000 r_2 = 0.1773 0.2206 0.2805 0.4219 CGPIT Department of Electronics & Communication Engineering
Page 57
Fundamental of Image Processing r_0 = 0.1773 0.1850 0.1956 0.2206 r_1 = 0 0.0314 0.0748 0.1773 r_3 = 0.0748 0.0930 0.1180 0.1773 r_11 = 0.0748 0.0780 0.0825 0.0930
Conclusion:
Hence, we convert the gray scale image in to 2-bit image using the thresholding and observe the result and we conclude that this image contain almost all the information of real image but contain less memory space. We also calculated the probability of that image and generate the arithmetic code for given sequence.
CGPIT
Page 58