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/CH4/EX4.24 | |
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/CH4/EX4.24')
-rw-r--r-- | 3176/CH4/EX4.24/Ex4_24.sce | 126 |
1 files changed, 60 insertions, 66 deletions
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 |