diff options
Diffstat (limited to '3176/CH4')
29 files changed, 1279 insertions, 0 deletions
diff --git a/3176/CH4/EX4.1/Ex4_1.sce b/3176/CH4/EX4.1/Ex4_1.sce new file mode 100644 index 000000000..91e00f427 --- /dev/null +++ b/3176/CH4/EX4.1/Ex4_1.sce @@ -0,0 +1,47 @@ +//Ex4_1
+// Obtaining the Fourier Transform of a Simple Function
+//Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+
+clc; //to clear command window.
+clear; //to kill previously defined variables.
+xdel(winsid());//to close all currently open figure(s).
+
+f=-5:0.01:5;
+[nr nc]=size(f);
+signal=ones(nr,nc);
+A=1;
+W=length(f);
+for i=1:W
+ if(f(i)==0)
+ mag(i)=A;
+ else
+ mag(i)=A*W*(sin(%pi*f(i)*W)/((%pi*f(i)*W)+%eps));
+ end
+
+end
+
+figure,mtlb_axis([-6 6 0 2]);
+bar(f,signal,0.1);
+xlabel('Time Index','color','blue','fontsize',2);
+ylabel('Amplitude','color','blue','fontsize',2);
+title('Rectangle Function','color','blue','fontsize',4);
+
+
+figure,//mtlb_axis([-15 15 0 2]);
+plot(f,mag);
+xlabel('Frequency','color','blue','fontsize',2);
+ylabel('Amplitude','color','blue','fontsize',2);
+title('Frequency Spectrum Plot','color','blue','fontsize',4);
+
+
+figure,//mtlb_axis([-15 15 0 2]);
+plot(f,abs(mag));
+xlabel('Frequency','color','blue','fontsize',2);
+ylabel('Amplitude','color','blue','fontsize',2);
+title('Frequency Spectrum Plot','color','blue','fontsize',4);
diff --git a/3176/CH4/EX4.13/Ex4_13.sce b/3176/CH4/EX4.13/Ex4_13.sce new file mode 100644 index 000000000..dbc2fc153 --- /dev/null +++ b/3176/CH4/EX4.13/Ex4_13.sce @@ -0,0 +1,79 @@ +//Ex4_13
+//The 2-D Fourier Spectrum of a Simple Function
+// Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+a=imread("Ex4_13_1.tif");
+a=imresize(a,0.5);
+//gray=rgb2gray(a);
+gray=im2double(a);
+
+figure,ShowImage(gray,'Gray Image');
+title('Original Image','color','blue','fontsize',4);
+[M,N]=size(gray);
+
+h1=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
+figure,ShowImage(mat2gray(abs(h1)),'Frequency spectrum');
+title('Frequency spectrum','color','blue','fontsize',4);
+
+in=fftshift(h1);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
+figure,ShowImage(mat2gray(abs(in)),'Frequency spectrum');
+title('Centred Frequency spectrum','color','blue','fontsize',4);
+
+i=log(1+abs(in));
+inm=mat2gray(i)
+figure,ShowImage(inm,'Frequency Spectrum');//ShowColorImage() is used to show color image, figure is command to view images in separate window.
+title('Frequency Spectrum','color','blue','fontsize',4);//title() is used for providing a title to an image.
+
+/////////////////////////// Effect of Translation //////////////////////////////
+a=imread("Ex4_13_2.png");
+gray=rgb2gray(a);
+gray=im2double(gray);
+figure,ShowImage(gray,'Gray Image');
+title('Original Image','color','blue','fontsize',4);
+[M,N]=size(gray);
+h2=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
+i=log(1+abs(h2));
+in=fftshift(i);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
+inm=mat2gray(in)
+figure,ShowImage(inm,'Frequency Spectrum');//ShowColorImage() is used to show color image, figure is command to view images in separate window.
+title('Frequency Spectrum','color','blue','fontsize',4);//title() is used for providing a title to an image.
+
+/////////////////////////// Effect of Rotation //////////////////////////////
+a=imread("Ex4_13_3.png");
+gray=rgb2gray(a);
+gray=im2double(gray);
+figure,ShowImage(gray,'Gray Image');
+title('Original Image','color','blue','fontsize',4);
+[M,N]=size(gray);
+h3=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
+i=log(1+abs(h3));
+in=fftshift(i);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
+inm=mat2gray(in)
+figure,ShowImage(inm,'Frequency Spectrum');//ShowColorImage() is used to show color image, figure is command to view images in separate window.
+title('Frequency Spectrum','color','blue','fontsize',4);//title() is used for providing a title to an image.
+
+
+/////////////////////////// Phase Spectrum //////////////////////////////
+phase=atand(imag(h1),real(h1));
+phase_1=mat2gray(phase);
+figure,ShowImage(phase_1,'phase Spectrum');
+title('phase Spectrum','color','blue','fontsize',4);
+
+phase=atand(imag(h2),real(h2));
+phase_1=mat2gray(phase);
+figure,ShowImage(phase_1,'phase Spectrum');
+title('phase Spectrum of Translated Object','color','blue','fontsize',4);
+
+phase=atand(imag(h3),real(h3));
+phase_1=mat2gray(phase);
+figure,ShowImage(phase_1,'phase Spectrum');
+title('phase Spectrum of Rotated Object','color','blue','fontsize',4);
diff --git a/3176/CH4/EX4.14/Ex4_14.sce b/3176/CH4/EX4.14/Ex4_14.sce new file mode 100644 index 000000000..cd115043a --- /dev/null +++ b/3176/CH4/EX4.14/Ex4_14.sce @@ -0,0 +1,63 @@ +//Ex4_14
+// Futher Illustration of a Properties of a Fourier Spectrum and Phase Angle
+// Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+a=imread("Ex4_14.tif");
+mask=imread("Ex4_14_2.tif");
+mask=im2double(imresize(mask,[512 512]));
+//gray=rgb2gray(a);
+gray=im2double(a);
+
+figure,ShowImage(gray,'Gray Image');
+title('Original Image','color','blue','fontsize',4);
+[M,N]=size(gray);
+
+h=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
+in=fftshift(h);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
+i=log(1+abs(in));
+
+inm=mat2gray(i);
+//figure,ShowImage(inm,'Center Frequency Spectrum');
+//title('Center Frequency Spectrum');
+
+phase=atand(imag(h),real(h));
+phase_1=mat2gray(phase);
+figure,ShowImage(phase_1,'phase Spectrum');
+title('phase Spectrum','color','blue','fontsize',4);
+
+phase_mask=atand(imag(fft2(mask)),real(fft2(mask)));
+phase_2=mat2gray(phase_mask);
+//figure,ShowImage(phase_2,'phase Spectrum');
+//title('phase Spectrum 2');
+
+Image_recoverd=real(ifft(phase));
+Image_recoverd=mat2gray(Image_recoverd)
+//figure,ShowImage(Image_recoverd,'recoverd Image');
+//title('recoverd Image by only Phase');
+
+
+Image_recoverd=fftshift(real(ifft(abs(h))));
+Image_recoverd=mat2gray(Image_recoverd)
+figure,ShowImage(Image_recoverd,'recoverd Image');
+title('recoverd Image by only Spectrum','color','blue','fontsize',4);
+
+
+Image_recoverd=real(ifft(fftshift((mask.*in)+phase)));
+Image_recoverd=(mat2gray(Image_recoverd));
+figure,ShowImage(Image_recoverd,'recoverd Image');
+title('recoverd Image by Magnitude in mask and Phase','color','blue','fontsize',4);
+
+
+Image_recoverd=real(ifft(fftshift(in)+abs(fft2(mask))));
+Image_recoverd=(mat2gray(Image_recoverd));
+figure,ShowImage(Image_recoverd,'recoverd Image');
+title('recoverd Image by phase in mask and magnitude','color','blue','fontsize',4);
diff --git a/3176/CH4/EX4.15/Ex4_15.sce b/3176/CH4/EX4.15/Ex4_15.sce new file mode 100644 index 000000000..32709a8a3 --- /dev/null +++ b/3176/CH4/EX4.15/Ex4_15.sce @@ -0,0 +1,68 @@ +//Ex4_15
+// Obtaining a Frequency domain Filter from a Small Spatial Mask
+// Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+
+function[H]=sobelfilter(mask_pad)//lowpassfilter is used to filter an image.
+ x=fft2(mask_pad);
+ [nr nc]=size(mask_pad);
+ x_real=real(x);
+ x_imag=imag(x);
+ z=zeros(nr,nc)+%i*x_imag
+ H=fftshift(z);
+ y=log(1+abs(H));
+ y=mat2gray(y)
+ figure,ShowImage(y,'Frequency Spectrum');
+ title('Frequency Spectrum','color','blue','fontsize',4);
+endfunction
+
+
+
+
+a=imread("Ex4_15.tif");
+gray=im2double(a);
+mask=[-1 0 1;-2 0 2;-1 0 1];
+figure,ShowImage(gray,'Gray Image');
+title('Original Image','color','blue','fontsize',4);
+[M,N]=size(gray);
+gray_pad=zeros(M+2,N+2); // Zero Padding
+mask_pad=zeros(M+2,N+2); // Zero Padding
+gray_pad(1:M,1:N)=gray(1:$,1:$);
+mask_pad(1:3,1:3)=mask(1:$,1:$);
+
+h=fft2(gray_pad);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
+
+in=fftshift(h);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
+i=log(1+abs(in));
+inm=mat2gray(i)
+figure,ShowImage(inm,'Frequency Spectrum');
+title('Frequency Spectrum','color','blue','fontsize',4);
+
+///////////////////////////// Filtering Domain Filtering ///////////////////////
+filt=sobelfilter(mask_pad); // Function which generate Filter Mask
+n=filt.*in;//Multiply the Original Spectrum with the Filter Mask.
+n=fftshift(n);
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image in Frequency Domain','color','blue','fontsize',4);
+
+///////////////////////////// Spatial Domain Filtering ///////////////////////
+
+imf = imfilter(a,mask);
+//imf=1*(imf.^1.2);
+[r c]=find(imf==0 | imf<=110);
+ for i=1:length(r)
+ imf(r(i),c(i)) = 125;
+ end
+figure,ShowImage(imf,'Filtered Image');
+title('Filtered Image in Spatial Domain','color','blue','fontsize',4);
diff --git a/3176/CH4/EX4.16/Ex4_16.sce b/3176/CH4/EX4.16/Ex4_16.sce new file mode 100644 index 000000000..500184108 --- /dev/null +++ b/3176/CH4/EX4.16/Ex4_16.sce @@ -0,0 +1,107 @@ +//Ex4_16
+//Image Smooting Using an ILPF
+// Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+
+function[H]=lowpassfilter(type1,M,N,D0,n)//lowpassfilter is used to filter an image .
+ u=0:(M-1);
+ v=0:(N-1);
+ idx=find(u>M/2);
+ u(idx)=u(idx)-M;
+ idy=find(v>N/2);
+ v(idy)=v(idy)-N;
+ [U,V]=meshgrid(v,u);
+ D=sqrt(U.^2+V.^2);
+ select type1
+
+ case'ideal'then
+ H=double(D<=D0);
+ else
+ disp('Unknownfiltertype.')
+ end
+endfunction
+
+
+/////////////////////////////////// Main Programm ////////////////////////////////
+a=imread("Ex4_16.tif");
+//gray=rgb2gray(a);
+gray=im2double(a);
+
+figure,ShowImage(gray,'Gray Image');
+title('Original Image');
+[M,N]=size(gray);
+
+h=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
+i=log(1+abs(h));
+in=fftshift(i);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
+inm=mat2gray(in)
+figure,ShowImage(inm,'Frequency Spectrum');
+title('Frequency Spectrum','color','blue','fontsize',4);
+
+/////////////////////////// Filtering With Cut-off Frequency 10 ///////////////////////
+filt=lowpassfilter('ideal',M,N,10); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 10','color','blue','fontsize',4);
+
+
+/////////////////////////// Filtering With Cut-off Frequency 30 ///////////////////////
+filt=lowpassfilter('ideal',M,N,30); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 30','color','blue','fontsize',4);
+
+
+/////////////////////////// Filtering With Cut-off Frequency 60 ///////////////////////
+filt=lowpassfilter('ideal',M,N,60); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 60','color','blue','fontsize',4);
+
+
+/////////////////////////// Filtering With Cut-off Frequency 160 ///////////////////////
+filt=lowpassfilter('ideal',M,N,160); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 160','color','blue','fontsize',4);
+
+
+/////////////////////////// Filtering With Cut-off Frequency 460 ///////////////////////
+filt=lowpassfilter('ideal',M,N,460); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 460','color','blue','fontsize',4);
diff --git a/3176/CH4/EX4.16/Ex_4_16_3.jpeg b/3176/CH4/EX4.16/Ex_4_16_3.jpeg Binary files differnew file mode 100644 index 000000000..ebecbda6b --- /dev/null +++ b/3176/CH4/EX4.16/Ex_4_16_3.jpeg diff --git a/3176/CH4/EX4.16/Ex_4_16_5.jpeg b/3176/CH4/EX4.16/Ex_4_16_5.jpeg Binary files differnew file mode 100644 index 000000000..da4e7a381 --- /dev/null +++ b/3176/CH4/EX4.16/Ex_4_16_5.jpeg diff --git a/3176/CH4/EX4.17/Ex4_17.sce b/3176/CH4/EX4.17/Ex4_17.sce new file mode 100644 index 000000000..2e5966dd5 --- /dev/null +++ b/3176/CH4/EX4.17/Ex4_17.sce @@ -0,0 +1,112 @@ +//Ex4_17
+// Image Smoothing with a Butterworth LowPass Filter
+// Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+
+function[H]=lowpassfilter(type1,M,N,D0,n)//lowpassfilter is used to filter an image .
+ u=0:(M-1);
+ v=0:(N-1);
+ idx=find(u>M/2);
+ u(idx)=u(idx)-M;
+ idy=find(v>N/2);
+ v(idy)=v(idy)-N;
+ [U,V]=meshgrid(v,u);
+ D=sqrt(U.^2+V.^2);
+ select type1
+
+ case'butterworth'then
+ if argn(2)==4 then
+ n=1;
+ end
+ H = ones(M,N)./(1+(D./D0).^(2*n));
+
+ else
+ disp('Unknownfiltertype.')
+ end
+endfunction
+
+
+
+/////////////////////////////////// Main Programm ////////////////////////////////
+a=imread("Ex4_17.tif");
+//gray=rgb2gray(a);
+gray=im2double(a);
+
+figure,ShowImage(gray,'Gray Image');
+title('Original Image','color','blue','fontsize',4);
+[M,N]=size(gray);
+
+h=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
+i=log(1+abs(h));
+in=fftshift(i);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
+inm=mat2gray(in)
+figure,ShowImage(inm,'Frequency Spectrum');
+title('Frequency Spectrum','color','blue','fontsize',4);
+
+/////////////////////////// Filtering With Cut-off Frequency 10 ///////////////////////
+filt=lowpassfilter('butterworth',M,N,10); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 10','color','blue','fontsize',4);
+
+
+/////////////////////////// Filtering With Cut-off Frequency 30 ///////////////////////
+filt=lowpassfilter('butterworth',M,N,30); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 30','color','blue','fontsize',4);
+
+
+/////////////////////////// Filtering With Cut-off Frequency 60 ///////////////////////
+filt=lowpassfilter('butterworth',M,N,60); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 60','color','blue','fontsize',4);
+
+
+/////////////////////////// Filtering With Cut-off Frequency 160 ///////////////////////
+filt=lowpassfilter('butterworth',M,N,160); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 160','color','blue','fontsize',4);
+
+
+/////////////////////////// Filtering With Cut-off Frequency 460 ///////////////////////
+filt=lowpassfilter('butterworth',M,N,460); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 460','color','blue','fontsize',4);
diff --git a/3176/CH4/EX4.17/Ex_4_17_2.jpeg b/3176/CH4/EX4.17/Ex_4_17_2.jpeg Binary files differnew file mode 100644 index 000000000..692c991cc --- /dev/null +++ b/3176/CH4/EX4.17/Ex_4_17_2.jpeg diff --git a/3176/CH4/EX4.17/Ex_4_17_4.jpeg b/3176/CH4/EX4.17/Ex_4_17_4.jpeg Binary files differnew file mode 100644 index 000000000..b40e63022 --- /dev/null +++ b/3176/CH4/EX4.17/Ex_4_17_4.jpeg diff --git a/3176/CH4/EX4.18/Ex4_18.sce b/3176/CH4/EX4.18/Ex4_18.sce new file mode 100644 index 000000000..8a3e54776 --- /dev/null +++ b/3176/CH4/EX4.18/Ex4_18.sce @@ -0,0 +1,108 @@ +//Ex4_18
+//Image Smoothing Using Gaussian Lowpass Filter.
+// Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+
+function[H]=lowpassfilter(type1,M,N,D0,n)//lowpassfilter is used to filter an image .
+ u=0:(M-1);
+ v=0:(N-1);
+ idx=find(u>M/2);
+ u(idx)=u(idx)-M;
+ idy=find(v>N/2);
+ v(idy)=v(idy)-N;
+ [U,V]=meshgrid(v,u);
+ D=sqrt(U.^2+V.^2);
+ select type1
+
+ case'gaussian'then
+ H=exp(-(D.^2)./(2*(D0^2)));
+ else
+ disp('Unknownfiltertype.')
+ end
+endfunction
+
+
+
+/////////////////////////////////// Main Programm ////////////////////////////////
+a=imread("Ex4_18.tif");
+//gray=rgb2gray(a);
+gray=im2double(a);
+
+figure,ShowImage(gray,'Gray Image');
+title('Original Image');
+[M,N]=size(gray);
+
+h=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
+i=log(1+abs(h));
+in=fftshift(i);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
+inm=mat2gray(in)
+figure,ShowImage(inm,'Frequency Spectrum');
+title('Frequency Spectrum','color','blue','fontsize',4);
+
+/////////////////////////// Filtering With Cut-off Frequency 10 ///////////////////////
+filt=lowpassfilter('gaussian',M,N,10); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 10','color','blue','fontsize',4);
+
+
+/////////////////////////// Filtering With Cut-off Frequency 30 ///////////////////////
+filt=lowpassfilter('gaussian',M,N,30); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 30','color','blue','fontsize',4);
+
+
+/////////////////////////// Filtering With Cut-off Frequency 60 ///////////////////////
+filt=lowpassfilter('gaussian',M,N,60); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 60','color','blue','fontsize',4);
+
+
+/////////////////////////// Filtering With Cut-off Frequency 160 ///////////////////////
+filt=lowpassfilter('gaussian',M,N,160); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 160','color','blue','fontsize',4);
+
+
+/////////////////////////// Filtering With Cut-off Frequency 460 ///////////////////////
+filt=lowpassfilter('gaussian',M,N,460); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 460','color','blue','fontsize',4);
diff --git a/3176/CH4/EX4.18/Ex_4_18_2.jpeg b/3176/CH4/EX4.18/Ex_4_18_2.jpeg Binary files differnew file mode 100644 index 000000000..a1ab1a125 --- /dev/null +++ b/3176/CH4/EX4.18/Ex_4_18_2.jpeg diff --git a/3176/CH4/EX4.18/Ex_4_18_4.jpeg b/3176/CH4/EX4.18/Ex_4_18_4.jpeg Binary files differnew file mode 100644 index 000000000..2ab6ae851 --- /dev/null +++ b/3176/CH4/EX4.18/Ex_4_18_4.jpeg diff --git a/3176/CH4/EX4.19/Ex4_19.sce b/3176/CH4/EX4.19/Ex4_19.sce new file mode 100644 index 000000000..6adcbaf41 --- /dev/null +++ b/3176/CH4/EX4.19/Ex4_19.sce @@ -0,0 +1,86 @@ +//Ex4_19
+//Using Highpass Filter and Thresholding for Image Enhancement
+// Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+
+function[H]=lowpassfilter(type1,M,N,D0,n)//lowpassfilter is used to filter an image .
+ u=0:(M-1);
+ v=0:(N-1);
+ idx=find(u>M/2);
+ u(idx)=u(idx)-M;
+ idy=find(v>N/2);
+ v(idy)=v(idy)-N;
+ [U,V]=meshgrid(v,u);
+ D=sqrt(U.^2+V.^2);
+ select type1
+
+ case'ideal'then
+ H=double(D<=D0);
+
+ case'Laplacian'then
+ H=1+(4*(%pi)^2*D^2);
+
+ case'butterworth'then
+ if argn(2)==4 then
+ n=1;
+ end
+ H = ones(M,N)./(1+(D./D0).^(2*n));
+
+ case'gaussian'then
+ H=exp(-(D.^2)./(2*(D0^2)));
+ else
+ disp('Unknownfiltertype.')
+ end
+endfunction
+
+
+
+/////////////////////////////////// Main Programm ////////////////////////////////
+a=imread("Ex4_19.tif");
+//gray=rgb2gray(a);
+gray=im2double(imresize(a,[540 540]));
+
+figure,ShowImage(gray,'Gray Image');
+title('Original Image','color','blue','fontsize',4);
+[M,N]=size(gray);
+
+h=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
+i=log(1+abs(h));
+in=fftshift(i);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
+inm=mat2gray(in)
+//figure,ShowImage(inm,'Frequency Spectrum');
+//title('Frequency Spectrum');
+
+filt=1-lowpassfilter('butterworth',M,N,50,4); // User Define Function which generate Filter Mask
+filt_shift=fftshift(filt);
+//figure,ShowImage(filt_shift,'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Specific Cut-Off Frequency','color','blue','fontsize',4);
+
+thr = maskthresh(Image_filter);
+
+Image_Enhance=im2bw(Image_filter,thr);
+figure,ShowImage(Image_Enhance,'Filtered Image');
+title('Enhance Image','color','blue','fontsize',4);
+
+
+
+
+
+
+
diff --git a/3176/CH4/EX4.19/Ex_4_19_2.jpeg b/3176/CH4/EX4.19/Ex_4_19_2.jpeg Binary files differnew file mode 100644 index 000000000..f512bf130 --- /dev/null +++ b/3176/CH4/EX4.19/Ex_4_19_2.jpeg diff --git a/3176/CH4/EX4.19/Ex_4_19_3.jpeg b/3176/CH4/EX4.19/Ex_4_19_3.jpeg Binary files differnew file mode 100644 index 000000000..1dea8d2bb --- /dev/null +++ b/3176/CH4/EX4.19/Ex_4_19_3.jpeg diff --git a/3176/CH4/EX4.20/Ex4_20.sce b/3176/CH4/EX4.20/Ex4_20.sce new file mode 100644 index 000000000..a193300fd --- /dev/null +++ b/3176/CH4/EX4.20/Ex4_20.sce @@ -0,0 +1,80 @@ +//Ex4_20
+// Image Sharping in Frequency Domain Using the Laplacian
+// Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+
+function[H]=lowpassfilter(type1,M,N,D0,n)//lowpassfilter is used to filter an image .
+ u=0:(M-1);
+ v=0:(N-1);
+ idx=find(u>M/2);
+ u(idx)=u(idx)-M;
+ idy=find(v>N/2);
+ v(idy)=v(idy)-N;
+ [U,V]=meshgrid(v,u);
+ D=sqrt(U.^2+V.^2);
+ select type1
+
+ case'ideal'then
+ H=double(D<=D0);
+
+ case'Laplacian'then
+ H_temp=double(D<=D0);
+ H=(4*(%pi)^2*D^2);
+ H=H.*H_temp;
+
+ case'butterworth'then
+ if argn(2)==4 then
+ n=1;
+ end
+ H = ones(M,N)./(1+(D./D0).^(2*n));
+ H_temp=ones(M,N)+(4*(%pi)^2*D^2);
+ H=H.*H_temp;
+
+ case'gaussian'then
+ H=exp(-(D.^2)./(2*(D0^2)));
+ else
+ disp('Unknownfiltertype.')
+ end
+endfunction
+
+
+
+/////////////////////////////////// Main Programm ////////////////////////////////
+a=imread("Ex4_20.tif");
+//gray=rgb2gray(a);
+gray=im2double(imresize(a,[540 540]));
+
+figure,ShowImage(gray,'Gray Image');
+title('Original Image','color','blue','fontsize',4);
+[M,N]=size(gray);
+
+h=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
+i=log(1+abs(h));
+in=fftshift(i);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
+inm=mat2gray(in);
+filt=lowpassfilter('Laplacian',M,N,55); // User Define Function which generate Filter Mask Corresponding to Low Frequency
+filt_shift=fftshift(filt);
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter);
+
+z=gray+Image_filter;
+figure,ShowImage(mat2gray(z),'Filtered Image');
+title('Filtered Image with Specific Cut-Off Frequency','color','blue','fontsize',4);
+
+
+
+
+
+
+
+
diff --git a/3176/CH4/EX4.21/Ex4_21.sce b/3176/CH4/EX4.21/Ex4_21.sce new file mode 100644 index 000000000..a0e4f18b6 --- /dev/null +++ b/3176/CH4/EX4.21/Ex4_21.sce @@ -0,0 +1,93 @@ +//Ex4_21
+//Image Enhancement using High frequency Emphasis Filtering
+// Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+
+function[H]=lowpassfilter(type1,M,N,D0,n)//lowpassfilter is used to filter an image .
+ u=0:(M-1);
+ v=0:(N-1);
+ idx=find(u>M/2);
+ u(idx)=u(idx)-M;
+ idy=find(v>N/2);
+ v(idy)=v(idy)-N;
+ [U,V]=meshgrid(v,u);
+ D=sqrt(U.^2+V.^2);
+ select type1
+
+ case'ideal'then
+ H=double(D<=D0);
+
+ case'Laplacian'then
+ H=1+(4*(%pi)^2*D^2);
+
+
+ case'butterworth'then
+ if argn(2)==4 then
+ n=1;
+ end
+ H = ones(M,N)./(1+(D./D0).^(2*n));
+
+ case'gaussian'then
+ H=exp(-(D.^2)./(2*(D0^2)));
+ else
+ disp('Unknownfiltertype.')
+ end
+endfunction
+
+
+
+/////////////////////////////////// Main Programm ////////////////////////////////
+a=imread("Ex4_21.tif");
+//gray=rgb2gray(a);
+gray=im2double(imresize(a,[540 540]));
+
+figure,ShowImage(gray,'Gray Image');
+title('Original Image','color','blue','fontsize',4);
+[M,N]=size(gray);
+
+h=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
+i=log(1+abs(h));
+in=fftshift(i);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
+inm=mat2gray(in)
+figure,ShowImage(inm,'Frequency Spectrum');
+title('Frequency Spectrum','color','blue','fontsize',4);
+
+////////////////////////////////// Filtering With Cut-off Frequency 10 ///////////////////////
+filt=1-lowpassfilter('gaussian',M,N,40); // User Define Function which generate Filter Mask
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+Image_filter=mat2gray(Image_filter)
+figure(1),ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image (High Pass) with Cut-Off Frequency 40','color','blue','fontsize',4);
+
+
+///////////////////// high boost filtering //////////////////////////////
+filt=0.5+(0.75.*(1-lowpassfilter('gaussian',M,N,40,4))); // User Define Function which generate Filter Mask
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Specific Cut-Off Frequency','color','blue','fontsize',4);
+
+
+Image_Enhance=bricontra(Image_filter,180,170,'m'); // Brightness Contrast agjustment (Intensity Transformation)
+figure,ShowImage(Image_Enhance,'Filtered Image');
+title('Enhance Image','color','blue','fontsize',4);
+
+
+
+
+
+
+
diff --git a/3176/CH4/EX4.21/Ex_4_21_3.jpeg b/3176/CH4/EX4.21/Ex_4_21_3.jpeg Binary files differnew file mode 100644 index 000000000..0a4660bc6 --- /dev/null +++ b/3176/CH4/EX4.21/Ex_4_21_3.jpeg diff --git a/3176/CH4/EX4.21/Ex_4_21_4.jpeg b/3176/CH4/EX4.21/Ex_4_21_4.jpeg Binary files differnew file mode 100644 index 000000000..e51ce3984 --- /dev/null +++ b/3176/CH4/EX4.21/Ex_4_21_4.jpeg diff --git a/3176/CH4/EX4.22/Ex4_22.sce b/3176/CH4/EX4.22/Ex4_22.sce new file mode 100644 index 000000000..1c4ce8727 --- /dev/null +++ b/3176/CH4/EX4.22/Ex4_22.sce @@ -0,0 +1,67 @@ +//Ex4_22
+// Image Enhancement using Homomorphic Filtering
+// Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+
+function[H]=filter(type1,M,N,D0,low,high,c)//lowpassfilter is used to filter an image .
+ u=0:(M-1);
+ v=0:(N-1);
+ idx=find(u>M/2);
+ u(idx)=u(idx)-M;
+ idy=find(v>N/2);
+ v(idy)=v(idy)-N;
+ [U,V]=meshgrid(v,u); // Generate 2-d matrix from 1-d matrix
+ D=sqrt(U.^2+V.^2); // distnace calculation
+ select type1
+ case'Homomorphic'then
+ H=((high-low).*(1-(exp(-c*(D.^2)./(D0^2)))))+low;
+ else
+ disp('Unknownfiltertype.')
+ end
+endfunction
+
+
+/////////////////////////////////// Main Programm ////////////////////////////////
+
+a=imread("Ex4_22.tif");
+//gray=rgb2gray(a);
+gray=im2double(imresize(a,[540 540]));
+
+figure,ShowImage(gray,'Gray Image');
+title('Original Image','color','blue','fontsize',4);
+[M,N]=size(gray);
+
+h=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
+i=log(1+abs(h));
+in=fftshift(i);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
+inm=mat2gray(in);
+low=0.25;
+high=2;
+c=1;
+D0=80;
+filt=filter('Homomorphic',M,N,D0,low,high,c); // User Define Function which generate Filter Mask
+
+n=filt.*h;//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(n));
+//Image_Enhance = hiseq(a);
+
+Image_filter=mat2gray(Image_filter);
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Specific Cut-Off Frequency','color','blue','fontsize',4);
+
+
+
+
+
+
+
+
diff --git a/3176/CH4/EX4.23/Ex4_23.sce b/3176/CH4/EX4.23/Ex4_23.sce new file mode 100644 index 000000000..3e62f4732 --- /dev/null +++ b/3176/CH4/EX4.23/Ex4_23.sce @@ -0,0 +1,117 @@ +//Ex4_23
+// Reduction of Moire Pattern Using Notch Filtering
+// Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+
+function[H]=notchfilter(type1,M,N,D0,n)//notchfilter is used to filter an image .
+ u=0:(M-1);
+ v=0:(N-1);
+ idx=find(u>M/2);
+ u(idx)=u(idx)-M;
+ idy=find(v>N/2);
+ v(idy)=v(idy)-N;
+ [U,V]=meshgrid(v,u);
+ D=sqrt(U.^2+V.^2);
+ x=[41 45 82 86 162 166 203 207];
+ y=[112 55 112 56 114 58 115 58];
+ select type1
+ case'ideal'then
+ //H=double(D<=D0);
+H=ones(M,N);
+for a=1:M
+ for b=1:N
+ for i=1:length(x)
+ d=sqrt((a-x(i))*(a-x(i))+(b-y(i))*(b-y(i)));
+ if (d<D0)
+ //H(a,b)=1-(1/(1+(d/D0)^(2*n)));
+ H(a,b)=0
+ end
+ end
+ end
+end
+
+ case'butterworth'then
+ if argn(2)==4 then
+ n=1;
+ end
+ //H = ones(M,N)./(1+(D./D0).^(2*n));
+ H=ones(M,N);
+ for a=1:M
+ for b=1:N
+ for i=1:length(x)
+ d=sqrt((a-x(i))*(a-x(i))+(b-y(i))*(b-y(i)));
+ if (d<D0)
+ H(a,b)=1-(1/(1+(d/D0)^(2*n)));
+ //H(a,b)=0
+ end
+ end
+ end
+end
+
+ case'gaussian'then
+ //H=exp(-(D.^2)./(2*(D0^2)));
+ H=ones(M,N);
+ for a=1:M
+ for b=1:N
+ for i=1:length(x)
+ d=sqrt((a-x(i))*(a-x(i))+(b-y(i))*(b-y(i)));
+ if (d<D0)
+ //H(a,b)=1-(1/(1+(d/D0)^(2*n)));
+ H(a,b)=1-(exp(-(d.^2)./(2*(D0^2))));
+ //H(a,b)=0
+ end
+ end
+ end
+end
+ else
+ disp('Unknownfiltertype.')
+ end
+
+endfunction
+
+
+/////////////////////////////////// Main Programm ////////////////////////////////
+
+a=imread("Ex4_23.tif");
+//gray=rgb2gray(a);
+gray=im2double(a);
+
+figure,ShowImage(gray,'Gray Image');
+title('Original Image','color','blue','fontsize',4);
+[M,N]=size(gray);
+
+h=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
+i=log(1+abs(h));
+in=fftshift(i);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
+inm=mat2gray(in)
+figure,ShowImage(inm,'Frequency Spectrum');
+title('Frequency Spectrum','color','blue','fontsize',4);
+
+filt=notchfilter('gaussian',M,N,9,2); // User Define Function which generate Filter Mask Corresponding to Low Frequency
+
+//filt_shift=fftshift(filt);
+n=filt.*fftshift(h);//Multiply the Original Spectrum with the Filter Mask.
+figure,ShowImage(abs(n),'Frequency Spectrum');
+title('Spectrum After Filtering','color','blue','fontsize',4);
+Image_filter=real(ifft(fftshift(n)));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Specific Cut-Off Frequency','color','blue','fontsize',4);
+
+
+
+
+
+
+
+
+
diff --git a/3176/CH4/EX4.23/Ex_4_23_3.jpeg b/3176/CH4/EX4.23/Ex_4_23_3.jpeg Binary files differnew file mode 100644 index 000000000..77648d06c --- /dev/null +++ b/3176/CH4/EX4.23/Ex_4_23_3.jpeg diff --git a/3176/CH4/EX4.23/Ex_4_23_4.jpeg b/3176/CH4/EX4.23/Ex_4_23_4.jpeg Binary files differnew file mode 100644 index 000000000..29a25d60e --- /dev/null +++ b/3176/CH4/EX4.23/Ex_4_23_4.jpeg diff --git a/3176/CH4/EX4.24/Ex4_24.sce b/3176/CH4/EX4.24/Ex4_24.sce new file mode 100644 index 000000000..1e50e6749 --- /dev/null +++ b/3176/CH4/EX4.24/Ex4_24.sce @@ -0,0 +1,66 @@ +//Ex4_24
+// Enhancement of Corrupted Cassini Saturn Image by Notch Filtering
+// Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+
+function[H]=notchfilter(M,N,W)//notchfilter is used to filter an image .
+ H=ones(M,N);
+ H(1:ceil(M/2-5),ceil(N/2-W/2):ceil(N/2+W/2))=0;
+ H(ceil(M/2+5):M,ceil(N/2-W/2):ceil(N/2+W/2))=0;
+
+endfunction
+
+
+
+/////////////////////////////////// Main Programm ////////////////////////////////
+a=imread("Ex4_24.tif");
+//gray=rgb2gray(a);
+gray=im2double(a);
+
+figure,ShowImage(gray,'Gray Image');
+title('Original Image','color','blue','fontsize',4);
+[M,N]=size(gray);
+
+h=fft2(gray);//fft2() is used to find 2-Dimensional Fast Fourier Transform of an matrix
+i=log(1+abs(h));
+in=fftshift(i);//fftshift() is used to rearrange the fft output, moving the zero frequency to the center of the spectrum.
+inm=mat2gray(in)
+figure,ShowImage(inm,'Frequency Spectrum');
+title('Frequency Spectrum','color','blue','fontsize',4);
+
+filt=notchfilter(M,N,7); // User Define Function which generate Filter Mask Corresponding to Low Frequency
+filt_pass=1-filt;
+//filt_shift=fftshift(filt);
+figure,ShowImage(filt,'Filter Mask');
+title('Filter Mask (Band stop) to Specific Cut-Off Frequency','color','blue','fontsize',4);
+
+n=filt.*fftshift(h);//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(fftshift(n)));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Specific Cut-Off Frequency','color','blue','fontsize',4);
+
+
+figure,ShowImage(filt_pass,'Filter Mask');
+title('Filter Mask (Band Pass) to Specific Cut-Off Frequency','color','blue','fontsize',4);
+
+n=filt_pass.*fftshift(h);//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=real(ifft(fftshift(n)));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image (Noise Pattern) with Specific Cut-Off Frequency','color','blue','fontsize',4);
+
+
+
+
+
+
diff --git a/3176/CH4/EX4.4/Ex4_4.sce b/3176/CH4/EX4.4/Ex4_4.sce new file mode 100644 index 000000000..352069137 --- /dev/null +++ b/3176/CH4/EX4.4/Ex4_4.sce @@ -0,0 +1,36 @@ +//Ex4_4
+// The Mechanics of Computing the DFT
+//Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+a=[1 2 4 4];
+//b=fft2(a);
+disp('Original Signal:')
+disp(a);
+M=length(a);
+for i=1:M
+ b(i)=0;
+ for j=1:M
+ b(i)=b(i)+(a(j)*exp((-%i*2*%pi*(i-1)*(j-1)/M)));
+ end
+end
+disp('DFT of Signal:')
+disp(b);
+
+for i=1:M
+ d(i)=0;
+ for j=1:M
+ d(i)=d(i)+((b(j)*exp((%i*2*%pi*(i-1)*(j-1)/M)))/M);
+ end
+end
+disp('IDFT:')
+disp(abs(d));
+
diff --git a/3176/CH4/EX4.7/Ex4_7.sce b/3176/CH4/EX4.7/Ex4_7.sce new file mode 100644 index 000000000..53ca67984 --- /dev/null +++ b/3176/CH4/EX4.7/Ex4_7.sce @@ -0,0 +1,54 @@ +//Ex4_7
+// Illustration of Aliasing in Resampled Images
+//Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+a=imread("Ex4_7.tif");
+figure,ShowImage(a,'Gray Image');
+title('Original Image [1025 1025]');
+//[M,N]=size(a);
+b=imresize(a,0.5,'nearest');
+[M,N]=size(b);
+d=[];
+f=[]
+for i=1:N
+ temp=b(:,i);
+ d=[d temp temp];
+end
+for i=1:M
+ temp=d(i,:);
+ f=[f;temp;temp];
+end
+figure,ShowImage(f,'Gray Image');
+title('Resize Image with Pixels Replication','color','blue','fontsize',4);
+
+
+/////////////////////////// Averaging Approach to Reduce Jaggies Effect ////////////////
+filt=fspecial('average',3);
+a_filter=imfilter(a,filt);
+b=imresize(a_filter,0.5,'nearest');
+//figure,ShowImage(b,'Gray Image');
+//title('Resize Image with nearest Interpolation');
+[M,N]=size(b);
+d=[];
+f=[]
+for i=1:N
+ temp=b(:,i);
+ d=[d temp temp];
+end
+for i=1:M
+ temp=d(i,:);
+ f=[f;temp;temp];
+end
+figure,ShowImage(f,'Gray Image');
+title('Resize Image with Pixels Replication After Averaging','color','blue','fontsize',4);
+
diff --git a/3176/CH4/EX4.8/Ex4_8.sce b/3176/CH4/EX4.8/Ex4_8.sce new file mode 100644 index 000000000..f1a4c96cd --- /dev/null +++ b/3176/CH4/EX4.8/Ex4_8.sce @@ -0,0 +1,56 @@ +//Ex4_8
+// Illustration of Jaggies in Image Shrinking
+//Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+a=imread("Ex4_8.tif");
+figure,ShowImage(a,'Gray Image');
+title('Original Image [1024 1024]','color','blue','fontsize',4);
+//[M,N]=size(a);
+b=imresize(a,[256 256],'bicubic');
+//figure,ShowImage(b,'Gray Image');
+//title('Resize Image [256 256] with Bicubic Interpolation');
+[M,N]=size(b);
+d=[];
+f=[]
+for i=1:N
+ temp=b(:,i);
+ d=[d temp temp temp temp];
+end
+for i=1:M
+ temp=d(i,:);
+ f=[f;temp;temp;temp;temp];
+end
+figure,ShowImage(f,'Gray Image');
+title('Resize Image [1024 1024] with Pixels Replication','color','blue','fontsize',4);
+
+
+/////////////////////////// Averaging Approach to Reduce Jaggies Effect ////////////////
+filt=fspecial('average',5);
+a_filter=imfilter(a,filt);
+b=imresize(a_filter,[256 256],'bicubic');
+//figure,ShowImage(b,'Gray Image');
+//title('Resize Image [256 256] with Bicubic Interpolation');
+[M,N]=size(b);
+d=[];
+f=[]
+for i=1:N
+ temp=b(:,i);
+ d=[d temp temp temp temp];
+end
+for i=1:M
+ temp=d(i,:);
+ f=[f;temp;temp;temp;temp];
+end
+figure,ShowImage(f,'Gray Image');
+title('Resize Image [1024 1024] with Pixels Replication After Averaging','color','blue','fontsize',4);
+
diff --git a/3176/CH4/EX4.9/Ex4_9.sce b/3176/CH4/EX4.9/Ex4_9.sce new file mode 100644 index 000000000..2bd33a5ec --- /dev/null +++ b/3176/CH4/EX4.9/Ex4_9.sce @@ -0,0 +1,40 @@ +//Ex4_9
+// Illustration of Jaggies in Image Zooming
+//Version : Scilab 5.4.1
+// Operating System : Window-xp, Window-7
+//Toolbox: Image Processing Design 8.3.1-1
+//Toolbox: SIVP 0.5.3.1-2
+//Reference book name : Digital Image Processing
+//book author: Rafael C. Gonzalez and Richard E. Woods
+
+
+clc;
+close;
+clear;
+xdel(winsid())//to close all currently open figure(s).
+a=imread("Ex4_9.tif");
+a=imcrop(a,[323 377 256 256]);
+//figure,ShowImage(a,'Gray Image');
+//title('Original Image [1025 1025]');
+b=imresize(a,[256 256],'bicubic');
+[M,N]=size(b);
+d=[];
+f=[]
+for i=1:N
+ temp=b(:,i);
+ d=[d temp temp temp temp];
+end
+for i=1:M
+ temp=d(i,:);
+ f=[f;temp;temp;temp;temp];
+end
+figure,ShowImage(f,'Gray Image');
+title('Resize Image [1024 1024] with Pixels Replication','color','blue','fontsize',4);
+
+
+///////////////////////////// Bi-linear Interpolation ////////////////
+
+f=imresize(a,[1024 1024],'bilinear');
+figure,ShowImage(f,'Gray Image');
+title('Resize Image [1024 1024] with Bi-linear Interpolation','color','blue','fontsize',4);
+
|