diff options
author | prashantsinalkar | 2017-10-10 12:38:01 +0530 |
---|---|---|
committer | prashantsinalkar | 2017-10-10 12:38:01 +0530 |
commit | f35ea80659b6a49d1bb2ce1d7d002583f3f40947 (patch) | |
tree | eb72842d800ac1233e9d890e020eac5fd41b0b1b /3176/CH9/EX9.10/Ex9_10.sce | |
parent | 7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (diff) | |
download | Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.tar.gz Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.tar.bz2 Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.zip |
updated the code
Diffstat (limited to '3176/CH9/EX9.10/Ex9_10.sce')
-rw-r--r-- | 3176/CH9/EX9.10/Ex9_10.sce | 192 |
1 files changed, 96 insertions, 96 deletions
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 |