summaryrefslogtreecommitdiff
path: root/3176
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:38:01 +0530
committerprashantsinalkar2017-10-10 12:38:01 +0530
commitf35ea80659b6a49d1bb2ce1d7d002583f3f40947 (patch)
treeeb72842d800ac1233e9d890e020eac5fd41b0b1b /3176
parent7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (diff)
downloadScilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.tar.gz
Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.tar.bz2
Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.zip
updated the code
Diffstat (limited to '3176')
-rw-r--r--3176/CH10/EX10.4/Ex10_4.sce170
-rw-r--r--3176/CH4/EX4.18/Ex4_18.sce216
-rw-r--r--3176/CH4/EX4.19/Ex4_19.sce165
-rw-r--r--3176/CH4/EX4.20/Ex4_20.sce152
-rw-r--r--3176/CH4/EX4.21/Ex4_21.sce179
-rw-r--r--3176/CH4/EX4.22/Ex4_22.sce126
-rw-r--r--3176/CH4/EX4.23/Ex4_23.sce225
-rw-r--r--3176/CH4/EX4.24/Ex4_24.sce126
-rw-r--r--3176/CH5/EX5.1/Ex5_1.sce346
-rw-r--r--3176/CH5/EX5.11/Ex5_11.sce217
-rw-r--r--3176/CH5/EX5.12/Ex5_12.sce196
-rw-r--r--3176/CH5/EX5.3/Ex5_3.sce431
-rw-r--r--3176/CH5/EX5.4/Ex5_4.sce178
-rw-r--r--3176/CH9/EX9.10/Ex9_10.sce192
-rw-r--r--3176/CH9/EX9.9/Ex9_9.sce194
15 files changed, 1528 insertions, 1585 deletions
diff --git a/3176/CH10/EX10.4/Ex10_4.sce b/3176/CH10/EX10.4/Ex10_4.sce
index 360d2cf04..846afc48e 100644
--- a/3176/CH10/EX10.4/Ex10_4.sce
+++ b/3176/CH10/EX10.4/Ex10_4.sce
@@ -1,86 +1,84 @@
-//Ex10_4
-// Behavior of the First and Second Derivative of a Noisy Edge
-// 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("Ex10_4.tif");
-a1=im2double(a);
-figure,ShowImage(a,'Gray Image');
-title('Original Image','color','blue','fontsize',4);
-[M,N]=size(a);
-first_order=zeros(M,N);
-second_order=zeros(M,N);
-
-for i=2:M-1
- for j=2:N-1
- first_order(i,j)=a(i,j+1)-a(i,j);
- second_order(i,j)=double(a1(i,j+1)+a1(i,j-1)-(2*a1(i,j)));
- end
-end
-
-figure,ShowImage(double(first_order),'First Order Difference Image');
-title('First Order Difference Image','color','blue','fontsize',4);
-
-forward_count=0;
-reverse_count=0;
-for j= 2:N-1 // Finding First Zero Crossing Point
- if(second_order(5,j)==0 & second_order(5,j+1)>0) then
- forward_count=forward_count+1;
- if(forward_count==1)then
- ther1=second_order(5,j+1);
- break;
- end
- end
-end
-
-for j= N-1:-1:2 // Finding Last Zero Crossing Point
- if(second_order(5,j)==0 & second_order(5,j-1)<0) then
- reverse_count=reverse_count+1;
- if(reverse_count==1)then
- ther2=second_order(5,j-1);
- break;
- end
- end
-end
-
-for i=1:M // Removing unwanted Intensity range
- for j=1:N
- if(second_order(i,j)==ther1)
- second_order1(i,j)=255;
- else if(second_order(i,j)==ther2)
- second_order1(i,j)=-255;
- else
- second_order1(i,j)=128;
- end
- end
-end
-end
-
-figure,ShowImage(second_order1,'Second Order Difference Image');
-title('Second Order Difference Image','color','blue','fontsize',4);
-
-t=a(5,1:N);
-t1=first_order(5,1:N);
-t2=second_order1(5,1:N);
-figure;
-subplot(311);
-plot(1:length(t),t);//
-title('Intensity Profile','color','blue','fontsize',4);
-subplot(312);
-mtlb_axis([1,N,0,1.5]);
-plot(1:length(t1),t1);//
-title('Intensity Profile of First order Derivative','color','blue','fontsize',4);
-subplot(313);
-plot(1:length(t2),t2);//
-title('Intensity Profile of Second order Derivative','color','blue','fontsize',4);
-
-
+//Ex10_4
+// Behavior of the First and Second Derivative of a Noisy Edge
+// 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("Ex10_4.tif");
+a1=im2double(a);
+figure,ShowImage(a,'Gray Image');
+title('Original Image','color','blue','fontsize',4);
+[M,N]=size(a);
+first_order=zeros(M,N);
+second_order=zeros(M,N);
+
+for i=2:M-1
+ for j=2:N-1
+ first_order(i,j)=a(i,j+1)-a(i,j);
+ second_order(i,j)=double(a1(i,j+1)+a1(i,j-1)-(2*a1(i,j)));
+ end
+end
+
+figure,ShowImage(double(first_order),'First Order Difference Image');
+title('First Order Difference Image','color','blue','fontsize',4);
+
+forward_count=0;
+reverse_count=0;
+for j= 2:N-1 // Finding First Zero Crossing Point
+ if(second_order(5,j)==0 &amp; second_order(5,j+1)&gt;0)
+ forward_count=forward_count+1;
+ if(forward_count==1)
+ ther1=second_order(5,j+1);
+ break;
+ end
+ end
+end
+
+for j= N-1:-1:2 // Finding Last Zero Crossing Point
+ if(second_order(5,j)==0 &amp; second_order(5,j-1)&lt;0)
+ reverse_count=reverse_count+1;
+ if(reverse_count==1)
+ ther2=second_order(5,j-1);
+ break;
+ end
+ end
+end
+
+for i=1:M // Removing unwanted Intensity range
+ for j=1:N
+ if(second_order(i,j)==ther1)
+ second_order1(i,j)=255;
+ else if(second_order(i,j)==ther2)
+ second_order1(i,j)=-255;
+ else
+ second_order1(i,j)=128;
+ end
+ end
+end
+end
+
+figure,ShowImage(second_order1,'Second Order Difference Image');
+title('Second Order Difference Image','color','blue','fontsize',4);
+
+t=a(5,1:N);
+t1=first_order(5,1:N);
+t2=second_order1(5,1:N);
+figure;
+subplot(311);
+plot(1:length(t),t);//
+title('Intensity Profile','color','blue','fontsize',4);
+subplot(312);
+mtlb_axis([1,N,0,1.5]);
+plot(1:length(t1),t1);//
+title('Intensity Profile of First order Derivative','color','blue','fontsize',4);
+subplot(313);
+plot(1:length(t2),t2);//
+title('Intensity Profile of Second order Derivative','color','blue','fontsize',4); \ No newline at end of file
diff --git a/3176/CH4/EX4.18/Ex4_18.sce b/3176/CH4/EX4.18/Ex4_18.sce
index 8a3e54776..ec3586868 100644
--- a/3176/CH4/EX4.18/Ex4_18.sce
+++ b/3176/CH4/EX4.18/Ex4_18.sce
@@ -1,108 +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);
+//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&gt;M/2);
+ u(idx)=u(idx)-M;
+ idy=find(v&gt;N/2);
+ v(idy)=v(idy)-N;
+ [U,V]=meshgrid(v,u);
+ D=sqrt(U.^2+V.^2);
+ select type1
+
+ case'gaussian'
+ 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); \ No newline at end of file
diff --git a/3176/CH4/EX4.19/Ex4_19.sce b/3176/CH4/EX4.19/Ex4_19.sce
index 6adcbaf41..eec9ddb9a 100644
--- a/3176/CH4/EX4.19/Ex4_19.sce
+++ b/3176/CH4/EX4.19/Ex4_19.sce
@@ -1,86 +1,79 @@
-//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);
-
-
-
-
-
-
-
+//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&gt;M/2);
+ u(idx)=u(idx)-M;
+ idy=find(v&gt;N/2);
+ v(idy)=v(idy)-N;
+ [U,V]=meshgrid(v,u);
+ D=sqrt(U.^2+V.^2);
+ select type1
+
+ case'ideal'
+ H=double(D&lt;=D0);
+
+ case'Laplacian'
+ H=1+(4*(%pi)^2*D^2);
+
+ case'butterworth'
+ if argn(2)==4
+ n=1;
+ end
+ H = ones(M,N)./(1+(D./D0).^(2*n));
+
+ case'gaussian'
+ 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); \ No newline at end of file
diff --git a/3176/CH4/EX4.20/Ex4_20.sce b/3176/CH4/EX4.20/Ex4_20.sce
index a193300fd..41226efb3 100644
--- a/3176/CH4/EX4.20/Ex4_20.sce
+++ b/3176/CH4/EX4.20/Ex4_20.sce
@@ -1,80 +1,72 @@
-//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);
-
-
-
-
-
-
-
-
+//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&gt;M/2);
+ u(idx)=u(idx)-M;
+ idy=find(v&gt;N/2);
+ v(idy)=v(idy)-N;
+ [U,V]=meshgrid(v,u);
+ D=sqrt(U.^2+V.^2);
+ select type1
+
+ case'ideal'
+ H=double(D&lt;=D0);
+
+ case'Laplacian'
+ H_temp=double(D&lt;=D0);
+ H=(4*(%pi)^2*D^2);
+ H=H.*H_temp;
+
+ case'butterworth'
+ if argn(2)==4
+ 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'
+ 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); \ No newline at end of file
diff --git a/3176/CH4/EX4.21/Ex4_21.sce b/3176/CH4/EX4.21/Ex4_21.sce
index a0e4f18b6..25e6c570a 100644
--- a/3176/CH4/EX4.21/Ex4_21.sce
+++ b/3176/CH4/EX4.21/Ex4_21.sce
@@ -1,93 +1,86 @@
-//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);
-
-
-
-
-
-
-
+//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&gt;M/2);
+ u(idx)=u(idx)-M;
+ idy=find(v&gt;N/2);
+ v(idy)=v(idy)-N;
+ [U,V]=meshgrid(v,u);
+ D=sqrt(U.^2+V.^2);
+ select type1
+
+ case'ideal'
+ H=double(D&lt;=D0);
+
+ case'Laplacian'
+ H=1+(4*(%pi)^2*D^2);
+
+
+ case'butterworth'
+ if argn(2)==4
+ n=1;
+ end
+ H = ones(M,N)./(1+(D./D0).^(2*n));
+
+ case'gaussian'
+ 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); \ No newline at end of file
diff --git a/3176/CH4/EX4.22/Ex4_22.sce b/3176/CH4/EX4.22/Ex4_22.sce
index 1c4ce8727..299398dfa 100644
--- a/3176/CH4/EX4.22/Ex4_22.sce
+++ b/3176/CH4/EX4.22/Ex4_22.sce
@@ -1,67 +1,59 @@
-//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);
-
-
-
-
-
-
-
-
+//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&gt;M/2);
+ u(idx)=u(idx)-M;
+ idy=find(v&gt;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'
+ 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); \ No newline at end of file
diff --git a/3176/CH4/EX4.23/Ex4_23.sce b/3176/CH4/EX4.23/Ex4_23.sce
index 3e62f4732..c3288a5f3 100644
--- a/3176/CH4/EX4.23/Ex4_23.sce
+++ b/3176/CH4/EX4.23/Ex4_23.sce
@@ -1,117 +1,108 @@
-//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);
-
-
-
-
-
-
-
-
-
+//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'
+ //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'
+ if argn(2)==4
+ 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'
+ //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); \ No newline at end of file
diff --git a/3176/CH4/EX4.24/Ex4_24.sce b/3176/CH4/EX4.24/Ex4_24.sce
index 1e50e6749..aa4ec99fc 100644
--- a/3176/CH4/EX4.24/Ex4_24.sce
+++ b/3176/CH4/EX4.24/Ex4_24.sce
@@ -1,66 +1,60 @@
-//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);
-
-
-
-
-
-
+//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); \ No newline at end of file
diff --git a/3176/CH5/EX5.1/Ex5_1.sce b/3176/CH5/EX5.1/Ex5_1.sce
index bb5e70081..d20f4e6b0 100644
--- a/3176/CH5/EX5.1/Ex5_1.sce
+++ b/3176/CH5/EX5.1/Ex5_1.sce
@@ -1,176 +1,170 @@
-//Ex5_1
-// Noisy Images and their Histogram
-//To plot the PDF of different Noise Distribution and add the same to the gray scale image.
-//(I)Gaussian (II)Uniform (III)Salt & Pepper (IV)Log Normal (V)Rayleigh (VI)Erlang (VII)Exponetial
-// 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 R=imnoise2(type,M,N,a,b)
- if argn(2)==3 then
- a=0; b=1;
- end
-
- select type
-
- case'gaussian'then
- rand("normal")
- R=a+b*rand(M,N);
-
- case'uniform'then
- R=a+(b-a)*rand(M,N,"uniform");
-
- case'salt & pepper'then
- if argn(2)==3
- a = 0.15; b = 0.15;
- end
- if (a+b) > 1
- error('The sum Pa + Pb must not exceed 1.');
- end
- R(1:M,1:N) = 0.5;
- X = rand(M,N);
- [r c] = find(X<=a);
- for i=1:length(r)
- R(r(i),c(i)) = 0;
- end
- u = a + b;
- [r c] = find(X>a & X<=u);
- for i=1:length(r)
- R(r(i),c(i)) = 255;
- end
-
- case'lognormal'then
- if argn(2)==3
- a = 1; b = 0.25;
- end
- R = a*exp(b*mtlb_randn(M,N));
-
- case'rayleigh'then
- if argn(2)==3
- a = 1; b = 0.25;
- end
- R = a + ((-b)*(log(1-rand(M,N,"uniform")))).^0.5;
-
- case'exponential'then
- if argn(2)==3
- a = 1;
- end
- if a<=0
- error('Parameter a must be positive for exponential type.');
- end
- k = -1/a;
- R = k*log(1-rand(M,N,"uniform"));
-
- case'erlang'then
- if (b ~= round(b) | b <= 0)
- error('Param b must be positive for integer for Erlang.')
- end
- k = -1/a;
- R = zeros(M,N);
- for j=1:b
- R = R + k*log(1-rand(M,N,"uniform"));
- end
-
- else
- disp('Unknownfiltertype.')
- end
-
-endfunction
-
-
-
-/////////////////////////////////////// Main Programm /////////////////////////////
-gray=imread("Ex5_1.tif");
-//gray=rgb2gray(a);
-//gray=im2double(gray);
-figure,ShowImage(gray,'Gray Image');
-title('Original Image');
-[M,N]=size(gray);
-[count,cell]=imhist(gray);
-figure,bar(cell,count,0.2);
-mtlb_axis([0 255 0 35000]);
-title('Histogram of Original Image');
-
-/////////////////////////////////////// Gaussian Noise ////////////////////
-r1=imnoise2('gaussian',M,N,15,5); // Generate Gaussian Noise with Given Mean and Variance
-gray_noise_gaussian=gray+(r1);
-figure,ShowImage(gray_noise_gaussian,'Gray Image with Noise');
-title('Gray Image with Noise gaussian');
-[count,cell]=imhist(gray_noise_gaussian);
-figure;bar(cell,count,1.2);
-mtlb_axis([0 255 0 3000]);
-title('Gaussian');
-
-/////////////////////////////////////// Rayleigh Noise ////////////////////
-r2=imnoise2('rayleigh',M,N,0,55); // Generate rayleigh Noise
-gray_noise_rayleigh=gray+(r2);
-figure,ShowImage(gray_noise_rayleigh,'Gray Image with Noise');
-title('Gray Image with Noise rayleigh');
-[count,cell]=imhist(gray_noise_rayleigh);
-figure;bar(cell,count,1.2);
-mtlb_axis([0 255 0 4000]);
-title('Rayleigh');
-
-/////////////////////////////////////// Erlang (Gamma) Noise ////////////////////
-r3=imnoise2('erlang',M,N,2,15); // Generate erlang Noise
-gray_noise_erlang=gray+(r3);
-figure,ShowImage(gray_noise_erlang,'Gray Image with Noise');
-title('Gray Image with Noise erlang(Gamma)');
-[count,cell]=imhist(gray_noise_erlang);
-figure;bar(cell,count,1.2);
-mtlb_axis([0 255 0 9500]);
-title('Erlang (Gamma)');
-
-/////////////////////////////////////// Exponential Noise ////////////////////
-r4=imnoise2('exponential',M,N,0.15); //Generate exponential Noise
-gray_noise_exponential=gray+(r4);
-figure,ShowImage(gray_noise_exponential,'Gray Image with Noise');
-title('Gray Image with Noise exponential');
-[count,cell]=imhist(gray_noise_exponential);
-figure;bar(cell,count,1.2);
-mtlb_axis([0 255 0 4500]);
-title('Exponential');
-
-/////////////////////////////////////// Uniform Noise ////////////////////
-r5=imnoise2('uniform',M,N,0,20); // Generate uniform Noise
-gray_noise_uniform=gray+(r5);
-figure,ShowImage(gray_noise_uniform,'Gray Image with Noise');
-title('Gray Image with Noise uniform');
-[count,cell]=imhist(gray_noise_uniform);
-figure;bar(cell,count,1.2);
-mtlb_axis([0 255 0 2000]);
-title('Uniform');
-
-/////////////////////////////////////// Salt & pepper Noise ////////////////////
-r6=imnoise2('salt & pepper',M,N,0.15,0.15); // Generate salt & pepper Noise
-gray_noise_salt_pepper=gray+(r6);
-figure,ShowImage(gray_noise_salt_pepper,'Gray Image with Noise');
-title('Gray Image with Noise salt&pepper');
-[count,cell]=imhist(gray_noise_salt_pepper);
-figure;bar(cell,count,1.2);
-mtlb_axis([0 255 0 35000]);
-title('Salt & pepper');
-
-///////////////////////////////////////// lognormal Noise ////////////////////
-//r7=imnoise2('lognormal',M,N,5,0.65); // Generate lognormal Noise
-//gray_noise_lognormal=gray+(r7);
-//figure,ShowImage(gray_noise_lognormal,'Gray Image with Noise');
-//title('Gray Image with Noise lognormal');
-//[count,cell]=imhist(gray_noise_lognormal);
-//figure;bar(cell,count,1.2);
-//mtlb_axis([0 255 0 5500]);
-//title('lognormal');
-
-
-
-
-
-
+//Ex5_1
+// Noisy Images and their Histogram
+//To plot the PDF of different Noise Distribution and add the same to the gray scale image.
+//(I)Gaussian (II)Uniform (III)Salt &amp; Pepper (IV)Log Normal (V)Rayleigh (VI)Erlang (VII)Exponetial
+// 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 R=imnoise2(type,M,N,a,b)
+ if argn(2)==3
+ a=0; b=1;
+ end
+
+ select type
+
+ case'gaussian'
+ rand("normal")
+ R=a+b*rand(M,N);
+
+ case'uniform'
+ R=a+(b-a)*rand(M,N,"uniform");
+
+ case'salt &amp; pepper'
+ if argn(2)==3
+ a = 0.15; b = 0.15;
+ end
+ if (a+b) &gt; 1
+ error('The sum Pa + Pb must not exceed 1.');
+ end
+ R(1:M,1:N) = 0.5;
+ X = rand(M,N);
+ [r c] = find(X&lt;=a);
+ for i=1:length(r)
+ R(r(i),c(i)) = 0;
+ end
+ u = a + b;
+ [r c] = find(X&gt;a &amp; X&lt;=u);
+ for i=1:length(r)
+ R(r(i),c(i)) = 255;
+ end
+
+ case'lognormal'
+ if argn(2)==3
+ a = 1; b = 0.25;
+ end
+ R = a*exp(b*mtlb_randn(M,N));
+
+ case'rayleigh'
+ if argn(2)==3
+ a = 1; b = 0.25;
+ end
+ R = a + ((-b)*(log(1-rand(M,N,"uniform")))).^0.5;
+
+ case'exponential'
+ if argn(2)==3
+ a = 1;
+ end
+ if a&lt;=0
+ error('Parameter a must be positive for exponential type.');
+ end
+ k = -1/a;
+ R = k*log(1-rand(M,N,"uniform"));
+
+ case'erlang'
+ if (b ~= round(b) | b &lt;= 0)
+ error('Param b must be positive for integer for Erlang.')
+ end
+ k = -1/a;
+ R = zeros(M,N);
+ for j=1:b
+ R = R + k*log(1-rand(M,N,"uniform"));
+ end
+
+ else
+ disp('Unknownfiltertype.')
+ end
+
+endfunction
+
+
+
+/////////////////////////////////////// Main Programm /////////////////////////////
+gray=imread("Ex5_1.tif");
+//gray=rgb2gray(a);
+//gray=im2double(gray);
+figure,ShowImage(gray,'Gray Image');
+title('Original Image');
+[M,N]=size(gray);
+[count,cell]=imhist(gray);
+figure,bar(cell,count,0.2);
+mtlb_axis([0 255 0 35000]);
+title('Histogram of Original Image');
+
+/////////////////////////////////////// Gaussian Noise ////////////////////
+r1=imnoise2('gaussian',M,N,15,5); // Generate Gaussian Noise with Given Mean and Variance
+gray_noise_gaussian=gray+(r1);
+figure,ShowImage(gray_noise_gaussian,'Gray Image with Noise');
+title('Gray Image with Noise gaussian');
+[count,cell]=imhist(gray_noise_gaussian);
+figure;bar(cell,count,1.2);
+mtlb_axis([0 255 0 3000]);
+title('Gaussian');
+
+/////////////////////////////////////// Rayleigh Noise ////////////////////
+r2=imnoise2('rayleigh',M,N,0,55); // Generate rayleigh Noise
+gray_noise_rayleigh=gray+(r2);
+figure,ShowImage(gray_noise_rayleigh,'Gray Image with Noise');
+title('Gray Image with Noise rayleigh');
+[count,cell]=imhist(gray_noise_rayleigh);
+figure;bar(cell,count,1.2);
+mtlb_axis([0 255 0 4000]);
+title('Rayleigh');
+
+/////////////////////////////////////// Erlang (Gamma) Noise ////////////////////
+r3=imnoise2('erlang',M,N,2,15); // Generate erlang Noise
+gray_noise_erlang=gray+(r3);
+figure,ShowImage(gray_noise_erlang,'Gray Image with Noise');
+title('Gray Image with Noise erlang(Gamma)');
+[count,cell]=imhist(gray_noise_erlang);
+figure;bar(cell,count,1.2);
+mtlb_axis([0 255 0 9500]);
+title('Erlang (Gamma)');
+
+/////////////////////////////////////// Exponential Noise ////////////////////
+r4=imnoise2('exponential',M,N,0.15); //Generate exponential Noise
+gray_noise_exponential=gray+(r4);
+figure,ShowImage(gray_noise_exponential,'Gray Image with Noise');
+title('Gray Image with Noise exponential');
+[count,cell]=imhist(gray_noise_exponential);
+figure;bar(cell,count,1.2);
+mtlb_axis([0 255 0 4500]);
+title('Exponential');
+
+/////////////////////////////////////// Uniform Noise ////////////////////
+r5=imnoise2('uniform',M,N,0,20); // Generate uniform Noise
+gray_noise_uniform=gray+(r5);
+figure,ShowImage(gray_noise_uniform,'Gray Image with Noise');
+title('Gray Image with Noise uniform');
+[count,cell]=imhist(gray_noise_uniform);
+figure;bar(cell,count,1.2);
+mtlb_axis([0 255 0 2000]);
+title('Uniform');
+
+/////////////////////////////////////// Salt &amp; pepper Noise ////////////////////
+r6=imnoise2('salt &amp; pepper',M,N,0.15,0.15); // Generate salt &amp; pepper Noise
+gray_noise_salt_pepper=gray+(r6);
+figure,ShowImage(gray_noise_salt_pepper,'Gray Image with Noise');
+title('Gray Image with Noise salt&amp;pepper');
+[count,cell]=imhist(gray_noise_salt_pepper);
+figure;bar(cell,count,1.2);
+mtlb_axis([0 255 0 35000]);
+title('Salt &amp; pepper');
+
+///////////////////////////////////////// lognormal Noise ////////////////////
+//r7=imnoise2('lognormal',M,N,5,0.65); // Generate lognormal Noise
+//gray_noise_lognormal=gray+(r7);
+//figure,ShowImage(gray_noise_lognormal,'Gray Image with Noise');
+//title('Gray Image with Noise lognormal');
+//[count,cell]=imhist(gray_noise_lognormal);
+//figure;bar(cell,count,1.2);
+//mtlb_axis([0 255 0 5500]);
+//title('lognormal'); \ No newline at end of file
diff --git a/3176/CH5/EX5.11/Ex5_11.sce b/3176/CH5/EX5.11/Ex5_11.sce
index a6f1901cd..555076108 100644
--- a/3176/CH5/EX5.11/Ex5_11.sce
+++ b/3176/CH5/EX5.11/Ex5_11.sce
@@ -1,109 +1,108 @@
-//Ex5_11
-//Inverse 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,H1]=lowpassfilter(type1,M,N,D0,n,k)//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); //Distance Calculation
- D=fftshift(D);
- for i=1:M
- for j=1:N
- H(i,j)=exp(-k.*((i-(M/2))^2+(j-(N/2))^2).^(5/6)); //Atmospheric Degradation Function
- end
- end
-
- select type1
-
- case'inverse'then
- if argn(2)==4 then
- n=1;k=0.0025;
- end
- H=H;
- H1=H;
-
- case'butterworth'then
- if argn(2)==4 then
- n=1;
- end
-// H1 = (ones(M,N)./(1+(D./D0).^(2*n)));
- H1=double(D<=D0);
- H=H.*H1;
-
- else
- disp('Unknownfiltertype.')
- end
-endfunction
-
-/////////////////////////////////// Main Programm ////////////////////////////////
-gray=imread('Ex5_11.png');
-gray=im2double(rgb2gray(gray));
-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)
-
-////////////////////////// Filtering With Cut-off Frequency 480 ///////////////////////
-[filt,H1]=lowpassfilter('inverse',M,N,480,1,0.0025); // Function which generate Filter Mask Corresponding to Low Frequency
-//filt_shift=fftshift(filt);
-//figure,ShowImage(abs(filt),'Filter Mask');
-//title('Filter Mask to Specific Cut-Off Frequency');
-n=in./(filt+%eps);//Multiply the Original Spectrum with the Filter Mask.
-Image_filter=abs(ifft(fftshift(n)));
-Image_filter=mat2gray(Image_filter)
-figure,ShowImage(Image_filter,'Filtered Image');
-title('Filtered Image with Full Inverse Filter','color','blue','fontsize',4);
-
-////////////////////////// Filtering With Cut-off Frequency 40 ///////////////////////
-[filt,H1]=lowpassfilter('butterworth',M,N,40,10,0.0025); // Function which generate Filter Mask Corresponding to Low Frequency
-//filt_shift=fftshift(filt);
-//figure,ShowImage(abs(filt),'Filter Mask');
-//title('Filter Mask to Specific Cut-Off Frequency');
-n=(in.*H1)./(filt+%eps);//Multiply the Original Spectrum with the Filter Mask.
-Image_filter=abs(ifft(fftshift(n)));
-Image_filter=mat2gray(Image_filter)
-figure,ShowImage(Image_filter,'Filtered Image');
-title('Filtered Image with Cut-Off Frequency 40','color','blue','fontsize',4);
-
-////////////////////////// Filtering With Cut-off Frequency 70 ///////////////////////
-[filt,H1]=lowpassfilter('butterworth',M,N,70,10,0.0025); // Function which generate Filter Mask Corresponding to Low Frequency
-//filt_shift=fftshift(filt);
-//figure,ShowImage(abs(filt),'Filter Mask');
-//title('Filter Mask to Specific Cut-Off Frequency');
-n=(in.*H1)./(filt+%eps);//Multiply the Original Spectrum with the Filter Mask.
-Image_filter=abs(ifft(fftshift(n)));
-Image_filter=mat2gray(Image_filter)
-figure,ShowImage(Image_filter,'Filtered Image');
-title('Filtered Image with Cut-Off Frequency 70','color','blue','fontsize',4);
-
-////////////////////////// Filtering With Cut-off Frequency 100 ///////////////////////
-[filt,H1]=lowpassfilter('butterworth',M,N,100,10,0.0025); // Function which generate Filter Mask Corresponding to Low Frequency
-//filt_shift=fftshift(filt);
-//figure,ShowImage(abs(filt),'Filter Mask');
-//title('Filter Mask to Specific Cut-Off Frequency');
-n=(in.*H1)./(filt+%eps);//Multiply the Original Spectrum with the Filter Mask.
-Image_filter=abs(ifft(fftshift(n)));
-Image_filter=mat2gray(Image_filter)
-figure,ShowImage(Image_filter,'Filtered Image');
-title('Filtered Image with Cut-Off Frequency 100','color','blue','fontsize',4);
-
+//Ex5_11
+//Inverse 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,H1]=lowpassfilter(type1,M,N,D0,n,k)//lowpassfilter is used to filter an image .
+ u=0:(M-1);
+ v=0:(N-1);
+ idx=find(u&gt;M/2);
+ u(idx)=u(idx)-M;
+ idy=find(v&gt;N/2);
+ v(idy)=v(idy)-N;
+ [U,V]=meshgrid(v,u);
+ D=sqrt(U.^2+V.^2); //Distance Calculation
+ D=fftshift(D);
+ for i=1:M
+ for j=1:N
+ H(i,j)=exp(-k.*((i-(M/2))^2+(j-(N/2))^2).^(5/6)); //Atmospheric Degradation Function
+ end
+ end
+
+ select type1
+
+ case'inverse'
+ if argn(2)==4
+ n=1;k=0.0025;
+ end
+ H=H;
+ H1=H;
+
+ case'butterworth'
+ if argn(2)==4
+ n=1;
+ end
+// H1 = (ones(M,N)./(1+(D./D0).^(2*n)));
+ H1=double(D&lt;=D0);
+ H=H.*H1;
+
+ else
+ disp('Unknownfiltertype.')
+ end
+endfunction
+
+/////////////////////////////////// Main Programm ////////////////////////////////
+gray=imread('Ex5_11.png');
+gray=im2double(rgb2gray(gray));
+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)
+
+////////////////////////// Filtering With Cut-off Frequency 480 ///////////////////////
+[filt,H1]=lowpassfilter('inverse',M,N,480,1,0.0025); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(abs(filt),'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=in./(filt+%eps);//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=abs(ifft(fftshift(n)));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Full Inverse Filter','color','blue','fontsize',4);
+
+////////////////////////// Filtering With Cut-off Frequency 40 ///////////////////////
+[filt,H1]=lowpassfilter('butterworth',M,N,40,10,0.0025); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(abs(filt),'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=(in.*H1)./(filt+%eps);//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=abs(ifft(fftshift(n)));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 40','color','blue','fontsize',4);
+
+////////////////////////// Filtering With Cut-off Frequency 70 ///////////////////////
+[filt,H1]=lowpassfilter('butterworth',M,N,70,10,0.0025); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(abs(filt),'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=(in.*H1)./(filt+%eps);//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=abs(ifft(fftshift(n)));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 70','color','blue','fontsize',4);
+
+////////////////////////// Filtering With Cut-off Frequency 100 ///////////////////////
+[filt,H1]=lowpassfilter('butterworth',M,N,100,10,0.0025); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(abs(filt),'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=(in.*H1)./(filt+%eps);//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=abs(ifft(fftshift(n)));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 100','color','blue','fontsize',4); \ No newline at end of file
diff --git a/3176/CH5/EX5.12/Ex5_12.sce b/3176/CH5/EX5.12/Ex5_12.sce
index 0ef07a070..c702d5f66 100644
--- a/3176/CH5/EX5.12/Ex5_12.sce
+++ b/3176/CH5/EX5.12/Ex5_12.sce
@@ -1,98 +1,98 @@
-//Ex5_12
-//Comparision of Inverse Filtering and Wiener 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,H1]=lowpassfilter(type1,M,N,D0,n,k)//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); //Distance Calculation
- D=fftshift(D);
- for i=1:M
- for j=1:N
- H(i,j)=exp(-k.*((i-(M/2))^2+(j-(N/2))^2).^(5/6)); //Atmospheric Degradation Function
- end
- end
-
- select type1
-
- case'inverse'then
- if argn(2)==4 then
- n=1;k=0.0025;
- end
- H=H;
- H1=H;
-
- case'butterworth'then
- if argn(2)==4 then
- n=1;
- end
-// H1 = (ones(M,N)./(1+(D./D0).^(2*n)));
- H1=double(D<=D0);
- H=H.*H1;
-
- else
- disp('Unknownfiltertype.')
- end
-endfunction
-
-/////////////////////////////////// Main Programm ////////////////////////////////
-gray=imread('Ex5_12.png');
-gray=im2double(rgb2gray(gray));
-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)
-
-////////////////////////// Filtering With Cut-off Frequency 480 ///////////////////////
-[filt,H1]=lowpassfilter('inverse',M,N,480,1,0.0025); // Function which generate Filter Mask Corresponding to Low Frequency
-//filt_shift=fftshift(filt);
-//figure,ShowImage(abs(filt),'Filter Mask');
-//title('Filter Mask to Specific Cut-Off Frequency');
-n=in./(filt+%eps);//Multiply the Original Spectrum with the Filter Mask.
-Image_filter=abs(ifft(fftshift(n)));
-Image_filter=mat2gray(Image_filter)
-figure,ShowImage(Image_filter,'Filtered Image');
-title('Filtered Image with Full Inverse Filter','color','blue','fontsize',4);
-
-////////////////////////// Filtering With Cut-off Frequency 40 ///////////////////////
-[filt,H1]=lowpassfilter('butterworth',M,N,40,10,0.0025); // Function which generate Filter Mask Corresponding to Low Frequency
-//filt_shift=fftshift(filt);
-//figure,ShowImage(abs(filt),'Filter Mask');
-//title('Filter Mask to Specific Cut-Off Frequency');
-n=(in.*H1)./(filt+%eps);//Multiply the Original Spectrum with the Filter Mask.
-Image_filter=abs(ifft(fftshift(n)));
-Image_filter=mat2gray(Image_filter)
-figure,ShowImage(Image_filter,'Filtered Image');
-title('Filtered Image with Cut-Off Frequency 40','color','blue','fontsize',4);
-
-
-////////////////////////// Filtering With Cut-off Frequency 40 ///////////////////////
-[filt,H1]=lowpassfilter('butterworth',M,N,40,10,0.0025); // Function which generate Filter Mask Corresponding to Low Frequency
-//filt_shift=fftshift(filt);
-//figure,ShowImage(abs(filt),'Filter Mask');
-//title('Filter Mask to Specific Cut-Off Frequency');
-n=(in.*H1)./(((1/filt+%eps).*(filt^2/(filt^2+6)))+%eps); // Wiener Filtering.
-Image_filter=abs(ifft(fftshift(n)));
-Image_filter=mat2gray(Image_filter)
-figure,ShowImage(Image_filter,'Filtered Image');
-title('Filtered Image with Cut-Off Frequency 40','color','blue','fontsize',4);
+//Ex5_12
+//Comparision of Inverse Filtering and Wiener 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,H1]=lowpassfilter(type1,M,N,D0,n,k)//lowpassfilter is used to filter an image .
+ u=0:(M-1);
+ v=0:(N-1);
+ idx=find(u&gt;M/2);
+ u(idx)=u(idx)-M;
+ idy=find(v&gt;N/2);
+ v(idy)=v(idy)-N;
+ [U,V]=meshgrid(v,u);
+ D=sqrt(U.^2+V.^2); //Distance Calculation
+ D=fftshift(D);
+ for i=1:M
+ for j=1:N
+ H(i,j)=exp(-k.*((i-(M/2))^2+(j-(N/2))^2).^(5/6)); //Atmospheric Degradation Function
+ end
+ end
+
+ select type1
+
+ case'inverse'
+ if argn(2)==4
+ n=1;k=0.0025;
+ end
+ H=H;
+ H1=H;
+
+ case'butterworth'
+ if argn(2)==4
+ n=1;
+ end
+// H1 = (ones(M,N)./(1+(D./D0).^(2*n)));
+ H1=double(D&lt;=D0);
+ H=H.*H1;
+
+ else
+ disp('Unknownfiltertype.')
+ end
+endfunction
+
+/////////////////////////////////// Main Programm ////////////////////////////////
+gray=imread('Ex5_12.png');
+gray=im2double(rgb2gray(gray));
+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)
+
+////////////////////////// Filtering With Cut-off Frequency 480 ///////////////////////
+[filt,H1]=lowpassfilter('inverse',M,N,480,1,0.0025); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(abs(filt),'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=in./(filt+%eps);//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=abs(ifft(fftshift(n)));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Full Inverse Filter','color','blue','fontsize',4);
+
+////////////////////////// Filtering With Cut-off Frequency 40 ///////////////////////
+[filt,H1]=lowpassfilter('butterworth',M,N,40,10,0.0025); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(abs(filt),'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=(in.*H1)./(filt+%eps);//Multiply the Original Spectrum with the Filter Mask.
+Image_filter=abs(ifft(fftshift(n)));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 40','color','blue','fontsize',4);
+
+
+////////////////////////// Filtering With Cut-off Frequency 40 ///////////////////////
+[filt,H1]=lowpassfilter('butterworth',M,N,40,10,0.0025); // Function which generate Filter Mask Corresponding to Low Frequency
+//filt_shift=fftshift(filt);
+//figure,ShowImage(abs(filt),'Filter Mask');
+//title('Filter Mask to Specific Cut-Off Frequency');
+n=(in.*H1)./(((1/filt+%eps).*(filt^2/(filt^2+6)))+%eps); // Wiener Filtering.
+Image_filter=abs(ifft(fftshift(n)));
+Image_filter=mat2gray(Image_filter)
+figure,ShowImage(Image_filter,'Filtered Image');
+title('Filtered Image with Cut-Off Frequency 40','color','blue','fontsize',4); \ No newline at end of file
diff --git a/3176/CH5/EX5.3/Ex5_3.sce b/3176/CH5/EX5.3/Ex5_3.sce
index 6d8c27f00..eb734546f 100644
--- a/3176/CH5/EX5.3/Ex5_3.sce
+++ b/3176/CH5/EX5.3/Ex5_3.sce
@@ -1,216 +1,215 @@
-//Ex5_3
-// Illustration of Order Statistic filter
-//To impliment the Following Order Statistic Restoration filter
-// (I)Median (II)MAX (III)MIN (IV)Mid Point (V)Alpha trimmed.
-
-// 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 [f]=arithmetic_mean(v,m,n)
- w=fspecial('average',m);
- f=imfilter(v,w);
-endfunction
-
-function [f]=geometric_mean1(g,m,n);//gmean1() is used to filter an image using Geometric mean filter
- size1=m;
- q=m*n;
- g=double(g);
- [nr,nc]=size(g);
- temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
- temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=g(1:$,1:$)
- temp=temp+1;
- for i=ceil(size1/2):nr+ceil(size1/2)-1
- for j=ceil(size1/2):nc+ceil(size1/2)-1
- t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
- temp2(i,j)=prod(t);
- end
- end
- temp3=temp2.^(1/q);
- nn=temp3(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)
- f1=nn-1;
- f=mat2gray(f1)
-endfunction
-
-function [f]=restoration_filter(v,type,m,n,Q,d)
- if argn(2) ==2 then
- m=7;n=7;Q=1.5;d=10;
- elseif argn(2)==5 then
- Q=parameter;d=parameter;
- elseif argn(2)==4 then
- Q=1.5;d=2;
- else
- disp('wrong number of inputs');
- end
-
- select type
-
- case'median'then
- f=MedianFilter(v,[m n]);
-
- case'MIN'then
- size1=m;
- [nr,nc]=size(v);
- temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
- temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
- for i=ceil(size1/2):nr+ceil(size1/2)-1
- for j=ceil(size1/2):nc+ceil(size1/2)-1
- t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
- y=gsort(t);
- temp2(i-floor(size1/2),j-floor(size1/2))=min(y);
- end
- end
- f=mat2gray(temp2);
-
- case'MAX'then
- size1=m;
- [nr,nc]=size(v);
- temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
- temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
- for i=ceil(size1/2):nr+ceil(size1/2)-1
- for j=ceil(size1/2):nc+ceil(size1/2)-1
- t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
- y=gsort(t);
- temp2(i-floor(size1/2),j-floor(size1/2))=max(y);
- end
- end
- f=mat2gray(temp2);
-
- case'Mid_Point'then
- size1=m;
- [nr,nc]=size(v);
- temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
- temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
- for i=ceil(size1/2):nr+ceil(size1/2)-1
- for j=ceil(size1/2):nc+ceil(size1/2)-1
- t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
- y=gsort(t);
- temp2(i-floor(size1/2),j-floor(size1/2))=0.5*(min(y)+max(y));
- end
- end
- f=mat2gray(temp2);
-
- else
- disp('Unknownfiltertype.')
- end
-endfunction
-
-function [f]=alphatrim(g,m,n,d)//alphatrim()is used to filter an image using alpha-trimmed mean filter
- size1=m;
- [nr,nc]=size(g);
- temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
- temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=g(1:$,1:$)
-
- for i=ceil(size1/2):nr+ceil(size1/2)-1
- for j=ceil(size1/2):nc+ceil(size1/2)-1
- t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2))
- y=gsort(t);
- a=y(:)
- b=a';
- t1=b(1+d/2:$-d/2);
- temp2(i-floor(size1/2),j-floor(size1/2))=mean(t1);
- end
- end
- f=mat2gray(temp2)
-endfunction
-
-
-///////////////////////////////////// Main Programm ////////////////////
-
-gray=imread("Ex5_3.tif");
-//gray=rgb2gray(a);
-//gray=im2double(gray);
-figure,ShowImage(gray,'Gray Image');
-title('Original Image');
-[M,N]=size(gray);
-
-/////////////////////////////////// Median Filter ////////////////////
-v=imnoise(gray,'salt & pepper',0.1);
-figure,ShowImage(v,'Noisy Image');
-title('Original Image with Salt & Pepper Noise');
-//Filtering the corrupted image with median filter
-h=restoration_filter(v,'median',3,3);
-figure,ShowImage(h,'Recovered Image');
-title('Recovered Image with Median Filter');
-//Filtering the corrupted image with median filter
-h1=restoration_filter(h,'median',3,3);
-figure,ShowImage(h1,'Recovered Image');
-title('Recovered Image with Median Filter');
-//Filtering the corrupted image with median filter
-h2=restoration_filter(h1,'median',3,3);
-figure,ShowImage(h2,'Recovered Image');
-title('Recovered Image with Median Filter');
-
-
-/////////////////////////////////// MAX Filter ////////////////////
-temp(1:M,1:N)=0.5;
-r3=imnoise(temp,'salt & pepper',0.1); // Generate salt & pepper Noise
-gray_noise_pepper=gray; // Add Pepper Noise Only
-[r c]=find(r3==0);
- for i=1:length(r)
- gray_noise_pepper(r(i),c(i)) = 0;
- end
-figure,ShowImage(gray_noise_pepper,'Noisy Image');
-title('Noisy Image with Pepper Noise');
-
-//Filtering the Salt Noise corrupted image with MAX filter
-h=restoration_filter(gray_noise_pepper,'MAX',3,3);
-figure,ShowImage(h,'Recovered Image');
-title('Recovered Image with MAX Filter');
-
-
-//////////////////////////////////// MIN Filter ////////////////////
-temp(1:M,1:N)=0.5;
-r3=imnoise(temp,'salt & pepper',0.1); // Generate salt & pepper Noise
-gray_noise_salt=gray; // Add salt Noise Only
-[r c]=find(r3==1);
- for i=1:length(r)
- gray_noise_salt(r(i),c(i)) = 255;
- end
-figure,ShowImage(gray_noise_salt,'Noisy Image');
-title('Noisy Image');
-
-//Filtering the Salt Noise corrupted image with MIN filter
-h=restoration_filter(gray_noise_salt,'MIN',3,3);
-figure,ShowImage(h,'Recovered Image');
-title('Recovered Image with MIN Filter');
-
-
-///////////////////////////////////// Mid-Point Filter ////////////////////
-//v=imnoise(gray,'gaussian',0,0.02);
-//figure,ShowImage(v,'Noisy Image');
-//title('Image with Gaussian Noise');
-////Filtering the Salt Noise corrupted image with Mid-Point filter
-//h=restoration_filter(v,'Mid_Point',3,3);
-//figure,ShowImage(h,'Recovered Image');
-//title('Recovered Image with Mid_Point Filter');
-
-
-///////////////////////////////// Alpha Trimmed Filter ////////////////////
-v=imnoise(gray,'gaussian',0,0.02);
-v=imnoise(v,'salt & pepper',0.05);
-figure,ShowImage(v,'Noisy Image');
-title('Image with Gaussian and Salt&Pepper Noise');
-m=5;n=5;d=5;
-[f]=arithmetic_mean(v,m,n); // Filtering with Arithmetical mean
-figure,ShowImage(f,'Recovered Image');
-title('Recovered Image with Arithmetical Mean Filter');
-[f]=geometric_mean1(v,m,n); // Filtering with Geometric mean
-figure,ShowImage(f,'Recovered Image');
-title('Recovered Image with Geometric Mean Filter');
-//Filtering the corrupted image with median filter
-h=restoration_filter(v,'median',5,5); // Filtering with median Filtering
-figure,ShowImage(h,'Recovered Image');
-title('Recovered Image with Median Filter');
-f=alphatrim(v,m,n,d); // Filtering with alphatrim Filtering
-figure,ShowImage(f,'Recovered Image');
-title('Recovered Image with Alpha Trimmed Filter');
-
+//Ex5_3
+// Illustration of Order Statistic filter
+//To impliment the Following Order Statistic Restoration filter
+// (I)Median (II)MAX (III)MIN (IV)Mid Point (V)Alpha trimmed.
+
+// 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 [f]=arithmetic_mean(v,m,n)
+ w=fspecial('average',m);
+ f=imfilter(v,w);
+endfunction
+
+function [f]=geometric_mean1(g,m,n);//gmean1() is used to filter an image using Geometric mean filter
+ size1=m;
+ q=m*n;
+ g=double(g);
+ [nr,nc]=size(g);
+ temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
+ temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=g(1:$,1:$)
+ temp=temp+1;
+ for i=ceil(size1/2):nr+ceil(size1/2)-1
+ for j=ceil(size1/2):nc+ceil(size1/2)-1
+ t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
+ temp2(i,j)=prod(t);
+ end
+ end
+ temp3=temp2.^(1/q);
+ nn=temp3(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)
+ f1=nn-1;
+ f=mat2gray(f1)
+endfunction
+
+function [f]=restoration_filter(v,type,m,n,Q,d)
+ if argn(2) ==2
+ m=7;n=7;Q=1.5;d=10;
+ elseif argn(2)==5
+ Q=parameter;d=parameter;
+ elseif argn(2)==4
+ Q=1.5;d=2;
+ else
+ disp('wrong number of inputs');
+ end
+
+ select type
+
+ case'median'
+ f=MedianFilter(v,[m n]);
+
+ case'MIN'
+ size1=m;
+ [nr,nc]=size(v);
+ temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
+ temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
+ for i=ceil(size1/2):nr+ceil(size1/2)-1
+ for j=ceil(size1/2):nc+ceil(size1/2)-1
+ t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
+ y=gsort(t);
+ temp2(i-floor(size1/2),j-floor(size1/2))=min(y);
+ end
+ end
+ f=mat2gray(temp2);
+
+ case'MAX'
+ size1=m;
+ [nr,nc]=size(v);
+ temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
+ temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
+ for i=ceil(size1/2):nr+ceil(size1/2)-1
+ for j=ceil(size1/2):nc+ceil(size1/2)-1
+ t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
+ y=gsort(t);
+ temp2(i-floor(size1/2),j-floor(size1/2))=max(y);
+ end
+ end
+ f=mat2gray(temp2);
+
+ case'Mid_Point'
+ size1=m;
+ [nr,nc]=size(v);
+ temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
+ temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
+ for i=ceil(size1/2):nr+ceil(size1/2)-1
+ for j=ceil(size1/2):nc+ceil(size1/2)-1
+ t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
+ y=gsort(t);
+ temp2(i-floor(size1/2),j-floor(size1/2))=0.5*(min(y)+max(y));
+ end
+ end
+ f=mat2gray(temp2);
+
+ else
+ disp('Unknownfiltertype.')
+ end
+endfunction
+
+function [f]=alphatrim(g,m,n,d)//alphatrim()is used to filter an image using alpha-trimmed mean filter
+ size1=m;
+ [nr,nc]=size(g);
+ temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
+ temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=g(1:$,1:$)
+
+ for i=ceil(size1/2):nr+ceil(size1/2)-1
+ for j=ceil(size1/2):nc+ceil(size1/2)-1
+ t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2))
+ y=gsort(t);
+ a=y(:)
+ b=a';
+ t1=b(1+d/2:$-d/2);
+ temp2(i-floor(size1/2),j-floor(size1/2))=mean(t1);
+ end
+ end
+ f=mat2gray(temp2)
+endfunction
+
+
+///////////////////////////////////// Main Programm ////////////////////
+
+gray=imread("Ex5_3.tif");
+//gray=rgb2gray(a);
+//gray=im2double(gray);
+figure,ShowImage(gray,'Gray Image');
+title('Original Image');
+[M,N]=size(gray);
+
+/////////////////////////////////// Median Filter ////////////////////
+v=imnoise(gray,'salt &amp; pepper',0.1);
+figure,ShowImage(v,'Noisy Image');
+title('Original Image with Salt &amp; Pepper Noise');
+//Filtering the corrupted image with median filter
+h=restoration_filter(v,'median',3,3);
+figure,ShowImage(h,'Recovered Image');
+title('Recovered Image with Median Filter');
+//Filtering the corrupted image with median filter
+h1=restoration_filter(h,'median',3,3);
+figure,ShowImage(h1,'Recovered Image');
+title('Recovered Image with Median Filter');
+//Filtering the corrupted image with median filter
+h2=restoration_filter(h1,'median',3,3);
+figure,ShowImage(h2,'Recovered Image');
+title('Recovered Image with Median Filter');
+
+
+/////////////////////////////////// MAX Filter ////////////////////
+temp(1:M,1:N)=0.5;
+r3=imnoise(temp,'salt &amp; pepper',0.1); // Generate salt &amp; pepper Noise
+gray_noise_pepper=gray; // Add Pepper Noise Only
+[r c]=find(r3==0);
+ for i=1:length(r)
+ gray_noise_pepper(r(i),c(i)) = 0;
+ end
+figure,ShowImage(gray_noise_pepper,'Noisy Image');
+title('Noisy Image with Pepper Noise');
+
+//Filtering the Salt Noise corrupted image with MAX filter
+h=restoration_filter(gray_noise_pepper,'MAX',3,3);
+figure,ShowImage(h,'Recovered Image');
+title('Recovered Image with MAX Filter');
+
+
+//////////////////////////////////// MIN Filter ////////////////////
+temp(1:M,1:N)=0.5;
+r3=imnoise(temp,'salt &amp; pepper',0.1); // Generate salt &amp; pepper Noise
+gray_noise_salt=gray; // Add salt Noise Only
+[r c]=find(r3==1);
+ for i=1:length(r)
+ gray_noise_salt(r(i),c(i)) = 255;
+ end
+figure,ShowImage(gray_noise_salt,'Noisy Image');
+title('Noisy Image');
+
+//Filtering the Salt Noise corrupted image with MIN filter
+h=restoration_filter(gray_noise_salt,'MIN',3,3);
+figure,ShowImage(h,'Recovered Image');
+title('Recovered Image with MIN Filter');
+
+
+///////////////////////////////////// Mid-Point Filter ////////////////////
+//v=imnoise(gray,'gaussian',0,0.02);
+//figure,ShowImage(v,'Noisy Image');
+//title('Image with Gaussian Noise');
+////Filtering the Salt Noise corrupted image with Mid-Point filter
+//h=restoration_filter(v,'Mid_Point',3,3);
+//figure,ShowImage(h,'Recovered Image');
+//title('Recovered Image with Mid_Point Filter');
+
+
+///////////////////////////////// Alpha Trimmed Filter ////////////////////
+v=imnoise(gray,'gaussian',0,0.02);
+v=imnoise(v,'salt &amp; pepper',0.05);
+figure,ShowImage(v,'Noisy Image');
+title('Image with Gaussian and Salt&amp;Pepper Noise');
+m=5;n=5;d=5;
+[f]=arithmetic_mean(v,m,n); // Filtering with Arithmetical mean
+figure,ShowImage(f,'Recovered Image');
+title('Recovered Image with Arithmetical Mean Filter');
+[f]=geometric_mean1(v,m,n); // Filtering with Geometric mean
+figure,ShowImage(f,'Recovered Image');
+title('Recovered Image with Geometric Mean Filter');
+//Filtering the corrupted image with median filter
+h=restoration_filter(v,'median',5,5); // Filtering with median Filtering
+figure,ShowImage(h,'Recovered Image');
+title('Recovered Image with Median Filter');
+f=alphatrim(v,m,n,d); // Filtering with alphatrim Filtering
+figure,ShowImage(f,'Recovered Image');
+title('Recovered Image with Alpha Trimmed Filter'); \ No newline at end of file
diff --git a/3176/CH5/EX5.4/Ex5_4.sce b/3176/CH5/EX5.4/Ex5_4.sce
index ca1fde8d4..c2aff7996 100644
--- a/3176/CH5/EX5.4/Ex5_4.sce
+++ b/3176/CH5/EX5.4/Ex5_4.sce
@@ -1,89 +1,89 @@
-//Ex5_4
-//Illustration of Adaptive Local Noise Reduction 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;
-clear;
-close;
-xdel(winsid());
-
-///////////////// Function File /////////////////////
-function [f]=arithmetic_mean(v,m,n)
- w=fspecial('average',m);
- f=imfilter(v,w);
-endfunction
-
-function [f]=geometric_mean1(g,m,n);//gmean1() is used to filter an image using Geometric mean filter
- size1=m;
- q=m*n;
- g=double(g);
- [nr,nc]=size(g);
- temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
- temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=g(1:$,1:$)
- temp=temp+1;
- for i=ceil(size1/2):nr+ceil(size1/2)-1
- for j=ceil(size1/2):nc+ceil(size1/2)-1
- t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
- temp2(i,j)=prod(t);
- end
- end
- temp3=temp2.^(1/q);
- nn=temp3(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)
- f1=nn-1;
- f=mat2gray(f1)
-endfunction
-
-
-///////////////// Main Programm /////////////////////
-A=imread("Ex5_4.tif");
-B = imnoise(A,'gaussian',0,0.01);
-[rw1 ,cl1]=size(B);
-figure;
-ShowImage(B,'Gaussian noise added');
-title('Image with gaussian noise','color','blue','fontsize',4);
-
-///////////////////////////////////// Arithmetical Mean Filter ////////////////////
-m=7;n=7;
-[f]=arithmetic_mean(B,m,n);
-figure,ShowImage(f,'Recovered Image');
-title('Restored Image with Arithmetical Mean Filter','color','blue','fontsize',4);
-
-///////////////////////////////////// Geometric Mean Filter ////////////////////
-m=7;n=7;
-[f]=geometric_mean1(B,m,n);
-figure,ShowImage(f,'Recovered Image');
-title('Restored Image with Geometric Mean Filter','color','blue','fontsize',4);
-
-
-
-////////////////////Adaptive Local Noise Reduction///////////////////////
-B= double(B);
-M=7;
-N=7;
-lvar=zeros([rw1-M+1,cl1-N+1]);
-lmean=zeros([rw1-M+1,cl1-N+1]);
-temp=zeros([rw1-M+1,cl1-N+1]);
-F=zeros([rw1-M+1,cl1-N+1]);
-sz=(rw1-M+1)*(cl1-N+1);
-for i=1:rw1-M+1
- for j=1:cl1-N+1
- temp=B(i:i+(M-1),j:j+(N-1));
- lmean(i,j)=mean(temp);
- lvar(i,j)=mean(temp.*temp)-mean(temp).^2;
- end
-end
-nvar=sum(lvar)/sz;
-lvar=max(lvar,nvar);
-C=B(M/2:rw1-M/2,N/2:cl1-N/2);
-F=nvar./lvar;
-F=F.*(C-lmean);
-F=C-F;
-F=uint8(F);
-figure;
-ShowImage(F,'Restored');
-title('Restored Image using Adaptive Local filter','color','blue','fontsize',4);
+//Ex5_4
+//Illustration of Adaptive Local Noise Reduction 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;
+clear;
+close;
+xdel(winsid());
+
+///////////////// Function File /////////////////////
+function [f]=arithmetic_mean(v,m,n)
+ w=fspecial('average',m);
+ f=imfilter(v,w);
+endfunction
+
+function [f]=geometric_mean1(g,m,n);//gmean1() is used to filter an image using Geometric mean filter
+ size1=m;
+ q=m*n;
+ g=double(g);
+ [nr,nc]=size(g);
+ temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
+ temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=g(1:$,1:$)
+ temp=temp+1;
+ for i=ceil(size1/2):nr+ceil(size1/2)-1
+ for j=ceil(size1/2):nc+ceil(size1/2)-1
+ t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
+ temp2(i,j)=prod(t);
+ end
+ end
+ temp3=temp2.^(1/q);
+ nn=temp3(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)
+ f1=nn-1;
+ f=mat2gray(f1)
+endfunction
+
+
+///////////////// Main Programm /////////////////////
+A=imread("Ex5_4.tif");
+B = imnoise(A,'gaussian',0,0.01);
+[rw1 ,cl1]=size(B);
+figure;
+ShowImage(B,'Gaussian noise added');
+title('Image with gaussian noise','color','blue','fontsize',4);
+
+///////////////////////////////////// Arithmetical Mean Filter ////////////////////
+m=7;n=7;
+[f]=arithmetic_mean(B,m,n);
+figure,ShowImage(f,'Recovered Image');
+title('Restored Image with Arithmetical Mean Filter','color','blue','fontsize',4);
+
+///////////////////////////////////// Geometric Mean Filter ////////////////////
+m=7;n=7;
+[f]=geometric_mean1(B,m,n);
+figure,ShowImage(f,'Recovered Image');
+title('Restored Image with Geometric Mean Filter','color','blue','fontsize',4);
+
+
+
+////////////////////Adaptive Local Noise Reduction///////////////////////
+B= double(B);
+M=7;
+N=7;
+lvar=zeros([rw1-M+1,cl1-N+1]);
+lmean=zeros([rw1-M+1,cl1-N+1]);
+temp=zeros([rw1-M+1,cl1-N+1]);
+F=zeros([rw1-M+1,cl1-N+1]);
+sz=(rw1-M+1)*(cl1-N+1);
+for i=1:rw1-M+1
+ for j=1:cl1-N+1
+ temp=B(i:i+(M-1),j:j+(N-1));
+ lmean(i,j)=mean(temp);
+ lvar(i,j)=mean(temp.*temp)-mean(temp).^2;
+ end
+end
+nvar=sum(lvar)/sz;
+lvar=max(lvar,nvar);
+C=B(M/2:rw1-M/2,N/2:cl1-N/2);
+F=nvar./lvar;
+F=F.*(C-lmean);
+F=C-F;
+F=uint8(F);
+figure;
+ShowImage(F,'Restored');
+title('Restored Image using Adaptive Local filter','color','blue','fontsize',4); \ No newline at end of file
diff --git a/3176/CH9/EX9.10/Ex9_10.sce b/3176/CH9/EX9.10/Ex9_10.sce
index 5470db855..3c06b6d91 100644
--- a/3176/CH9/EX9.10/Ex9_10.sce
+++ b/3176/CH9/EX9.10/Ex9_10.sce
@@ -1,96 +1,96 @@
-//Ex9_10
-// Illustration of Gray Scale Opening and Closing
-// 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 [f]=restoration_filter(v,type,m,n,Q,d)
- if argn(2) ==2 then
- m=7;n=7;Q=1.5;d=10;
- elseif argn(2)==5 then
- Q=parameter;d=parameter;
- elseif argn(2)==4 then
- Q=1.5;d=2;
- else
- disp('wrong number of inputs');
- end
-
- select type
-
- case'median'then
- f=MedianFilter(v,[m n]);
-
- case'MIN'then
- size1=m;
- [nr,nc]=size(v);
- temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
- temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
- for i=ceil(size1/2):nr+ceil(size1/2)-1
- for j=ceil(size1/2):nc+ceil(size1/2)-1
- t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
- y=gsort(t);
- temp2(i-floor(size1/2),j-floor(size1/2))=min(y);
- end
- end
- f=mat2gray(temp2);
-
- case'MAX'then
- size1=m;
- [nr,nc]=size(v);
- temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
- temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
- for i=ceil(size1/2):nr+ceil(size1/2)-1
- for j=ceil(size1/2):nc+ceil(size1/2)-1
- t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
- y=gsort(t);
- temp2(i-floor(size1/2),j-floor(size1/2))=max(y);
- end
- end
- f=mat2gray(temp2);
-
- case'Mid_Point'then
- size1=m;
- [nr,nc]=size(v);
- temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
- temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
- for i=ceil(size1/2):nr+ceil(size1/2)-1
- for j=ceil(size1/2):nc+ceil(size1/2)-1
- t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
- y=gsort(t);
- temp2(i-floor(size1/2),j-floor(size1/2))=0.5*(min(y)+max(y));
- end
- end
- f=mat2gray(temp2);
-
- else
- disp('Unknownfiltertype.')
- end
-endfunction
-
-///////////////////////////////////// Main Programm ////////////////////
-
-a=imread("Ex9_10.png");
-gray=rgb2gray(a);
-//gray=im2double(gray);
-figure,ShowImage(gray,'Gray Image');
-title('Original X-Ray Image','color','blue','fontsize',4);
-[M,N]=size(gray);
-
-//////////////////////////// Gray Scale Opening ////////////////////
-h=restoration_filter(restoration_filter(gray,'MIN',3,3),'MAX',3,3);
-figure,ShowImage(h,'Recovered Image');
-title('Opening using Flat Structureing Element','color','blue','fontsize',4);
-
-
-/////////////////////////////// Gray Scale Closing ////////////////////
-h=restoration_filter(restoration_filter(gray,'MAX',3,3),'MIN',3,3);
-figure,ShowImage(h,'Recovered Image');
-title('Closing using Flat Structureing Element','color','blue','fontsize',4);
+//Ex9_10
+// Illustration of Gray Scale Opening and Closing
+// 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 [f]=restoration_filter(v,type,m,n,Q,d)
+ if argn(2) ==2
+ m=7;n=7;Q=1.5;d=10;
+ elseif argn(2)==5
+ Q=parameter;d=parameter;
+ elseif argn(2)==4
+ Q=1.5;d=2;
+ else
+ disp('wrong number of inputs');
+ end
+
+ select type
+
+ case'median'
+ f=MedianFilter(v,[m n]);
+
+ case'MIN'
+ size1=m;
+ [nr,nc]=size(v);
+ temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
+ temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
+ for i=ceil(size1/2):nr+ceil(size1/2)-1
+ for j=ceil(size1/2):nc+ceil(size1/2)-1
+ t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
+ y=gsort(t);
+ temp2(i-floor(size1/2),j-floor(size1/2))=min(y);
+ end
+ end
+ f=mat2gray(temp2);
+
+ case'MAX'
+ size1=m;
+ [nr,nc]=size(v);
+ temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
+ temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
+ for i=ceil(size1/2):nr+ceil(size1/2)-1
+ for j=ceil(size1/2):nc+ceil(size1/2)-1
+ t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
+ y=gsort(t);
+ temp2(i-floor(size1/2),j-floor(size1/2))=max(y);
+ end
+ end
+ f=mat2gray(temp2);
+
+ case'Mid_Point'
+ size1=m;
+ [nr,nc]=size(v);
+ temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
+ temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
+ for i=ceil(size1/2):nr+ceil(size1/2)-1
+ for j=ceil(size1/2):nc+ceil(size1/2)-1
+ t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
+ y=gsort(t);
+ temp2(i-floor(size1/2),j-floor(size1/2))=0.5*(min(y)+max(y));
+ end
+ end
+ f=mat2gray(temp2);
+
+ else
+ disp('Unknownfiltertype.')
+ end
+endfunction
+
+///////////////////////////////////// Main Programm ////////////////////
+
+a=imread("Ex9_10.png");
+gray=rgb2gray(a);
+//gray=im2double(gray);
+figure,ShowImage(gray,'Gray Image');
+title('Original X-Ray Image','color','blue','fontsize',4);
+[M,N]=size(gray);
+
+//////////////////////////// Gray Scale Opening ////////////////////
+h=restoration_filter(restoration_filter(gray,'MIN',3,3),'MAX',3,3);
+figure,ShowImage(h,'Recovered Image');
+title('Opening using Flat Structureing Element','color','blue','fontsize',4);
+
+
+/////////////////////////////// Gray Scale Closing ////////////////////
+h=restoration_filter(restoration_filter(gray,'MAX',3,3),'MIN',3,3);
+figure,ShowImage(h,'Recovered Image');
+title('Closing using Flat Structureing Element','color','blue','fontsize',4); \ No newline at end of file
diff --git a/3176/CH9/EX9.9/Ex9_9.sce b/3176/CH9/EX9.9/Ex9_9.sce
index b06975cc1..7630d3664 100644
--- a/3176/CH9/EX9.9/Ex9_9.sce
+++ b/3176/CH9/EX9.9/Ex9_9.sce
@@ -1,98 +1,96 @@
-//Ex9_9
-// Illustration of Gray Scale Erosion and Dilation
-// 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 [f]=restoration_filter(v,type,m,n,Q,d)
- if argn(2) ==2 then
- m=7;n=7;Q=1.5;d=10;
- elseif argn(2)==5 then
- Q=parameter;d=parameter;
- elseif argn(2)==4 then
- Q=1.5;d=2;
- else
- disp('wrong number of inputs');
- end
-
- select type
-
- case'median'then
- f=MedianFilter(v,[m n]);
-
- case'MIN'then
- size1=m;
- [nr,nc]=size(v);
- temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
- temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
- for i=ceil(size1/2):nr+ceil(size1/2)-1
- for j=ceil(size1/2):nc+ceil(size1/2)-1
- t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
- y=gsort(t);
- temp2(i-floor(size1/2),j-floor(size1/2))=min(y);
- end
- end
- f=mat2gray(temp2);
-
- case'MAX'then
- size1=m;
- [nr,nc]=size(v);
- temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
- temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
- for i=ceil(size1/2):nr+ceil(size1/2)-1
- for j=ceil(size1/2):nc+ceil(size1/2)-1
- t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
- y=gsort(t);
- temp2(i-floor(size1/2),j-floor(size1/2))=max(y);
- end
- end
- f=mat2gray(temp2);
-
- case'Mid_Point'then
- size1=m;
- [nr,nc]=size(v);
- temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
- temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
- for i=ceil(size1/2):nr+ceil(size1/2)-1
- for j=ceil(size1/2):nc+ceil(size1/2)-1
- t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
- y=gsort(t);
- temp2(i-floor(size1/2),j-floor(size1/2))=0.5*(min(y)+max(y));
- end
- end
- f=mat2gray(temp2);
-
- else
- disp('Unknownfiltertype.')
- end
-endfunction
-
-///////////////////////////////////// Main Programm ////////////////////
-
-a=imread("Ex9_9.png");
-gray=rgb2gray(a);
-//gray=im2double(gray);
-figure,ShowImage(gray,'Gray Image');
-title('Original X-Ray Image','color','blue','fontsize',4);
-[M,N]=size(gray);
-
-//////////////////////////////////// MIN Filter ////////////////////
-h=restoration_filter(gray,'MIN',3,3);
-figure,ShowImage(h,'Recovered Image');
-title('Erosion using Flat Structuring Element','color','blue','fontsize',4);
-
-
-/////////////////////////////////// MAX Filter ////////////////////
-h=restoration_filter(gray,'MAX',3,3);
-figure,ShowImage(h,'Recovered Image');
-title('Dilation using Flat Structuring Element','color','blue','fontsize',4);
-
-
+//Ex9_9
+// Illustration of Gray Scale Erosion and Dilation
+// 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 [f]=restoration_filter(v,type,m,n,Q,d)
+ if argn(2) ==2
+ m=7;n=7;Q=1.5;d=10;
+ elseif argn(2)==5
+ Q=parameter;d=parameter;
+ elseif argn(2)==4
+ Q=1.5;d=2;
+ else
+ disp('wrong number of inputs');
+ end
+
+ select type
+
+ case'median'
+ f=MedianFilter(v,[m n]);
+
+ case'MIN'
+ size1=m;
+ [nr,nc]=size(v);
+ temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
+ temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
+ for i=ceil(size1/2):nr+ceil(size1/2)-1
+ for j=ceil(size1/2):nc+ceil(size1/2)-1
+ t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
+ y=gsort(t);
+ temp2(i-floor(size1/2),j-floor(size1/2))=min(y);
+ end
+ end
+ f=mat2gray(temp2);
+
+ case'MAX'
+ size1=m;
+ [nr,nc]=size(v);
+ temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
+ temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
+ for i=ceil(size1/2):nr+ceil(size1/2)-1
+ for j=ceil(size1/2):nc+ceil(size1/2)-1
+ t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
+ y=gsort(t);
+ temp2(i-floor(size1/2),j-floor(size1/2))=max(y);
+ end
+ end
+ f=mat2gray(temp2);
+
+ case'Mid_Point'
+ size1=m;
+ [nr,nc]=size(v);
+ temp=zeros(nr+2*floor(size1/2),nc+2*floor(size1/2));
+ temp(ceil(size1/2):nr+ceil(size1/2)-1,ceil(size1/2):nc+ceil(size1/2)-1)=v(1:$,1:$);
+ for i=ceil(size1/2):nr+ceil(size1/2)-1
+ for j=ceil(size1/2):nc+ceil(size1/2)-1
+ t=temp(i-floor(size1/2):1:i+floor(size1/2),j-floor(size1/2):1:j+floor(size1/2)) ;
+ y=gsort(t);
+ temp2(i-floor(size1/2),j-floor(size1/2))=0.5*(min(y)+max(y));
+ end
+ end
+ f=mat2gray(temp2);
+
+ else
+ disp('Unknownfiltertype.')
+ end
+endfunction
+
+///////////////////////////////////// Main Programm ////////////////////
+
+a=imread("Ex9_9.png");
+gray=rgb2gray(a);
+//gray=im2double(gray);
+figure,ShowImage(gray,'Gray Image');
+title('Original X-Ray Image','color','blue','fontsize',4);
+[M,N]=size(gray);
+
+//////////////////////////////////// MIN Filter ////////////////////
+h=restoration_filter(gray,'MIN',3,3);
+figure,ShowImage(h,'Recovered Image');
+title('Erosion using Flat Structuring Element','color','blue','fontsize',4);
+
+
+/////////////////////////////////// MAX Filter ////////////////////
+h=restoration_filter(gray,'MAX',3,3);
+figure,ShowImage(h,'Recovered Image');
+title('Dilation using Flat Structuring Element','color','blue','fontsize',4); \ No newline at end of file