From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 3176/CH2/EX2.12/Ex2_12.sce | 38 ++++++++++++++++++++++++++++++++++++++ 3176/CH2/EX2.2/Ex2_2.sce | 28 ++++++++++++++++++++++++++++ 3176/CH2/EX2.3/Ex2_3.sce | 34 ++++++++++++++++++++++++++++++++++ 3176/CH2/EX2.4/Ex2_4.sce | 39 +++++++++++++++++++++++++++++++++++++++ 3176/CH2/EX2.5/Ex2_5.sce | 43 +++++++++++++++++++++++++++++++++++++++++++ 3176/CH2/EX2.6/Ex2_6.sce | 37 +++++++++++++++++++++++++++++++++++++ 3176/CH2/EX2.7/Ex2_7.sce | 44 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 263 insertions(+) create mode 100644 3176/CH2/EX2.12/Ex2_12.sce create mode 100644 3176/CH2/EX2.2/Ex2_2.sce create mode 100644 3176/CH2/EX2.3/Ex2_3.sce create mode 100644 3176/CH2/EX2.4/Ex2_4.sce create mode 100644 3176/CH2/EX2.5/Ex2_5.sce create mode 100644 3176/CH2/EX2.6/Ex2_6.sce create mode 100644 3176/CH2/EX2.7/Ex2_7.sce (limited to '3176/CH2') diff --git a/3176/CH2/EX2.12/Ex2_12.sce b/3176/CH2/EX2.12/Ex2_12.sce new file mode 100644 index 000000000..7e15ee1bb --- /dev/null +++ b/3176/CH2/EX2.12/Ex2_12.sce @@ -0,0 +1,38 @@ +//Ex2_12 +// Standard Deviation +// 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). + +////////////////// Image Rotation ///////////////////// +gray1=imread("Ex2_12.tif"); +gray1=im2double(gray1); //Convert the data type into double range +figure,ShowImage(gray1,'Gray Image'); +title('Original Image'); +gray2=imread("Ex2_12_1.tif"); +gray2=im2double(gray2); ///Convert the data type into double range +figure,ShowImage(gray2,'Gray Image'); +title('Original Image'); +gray3=imread("Ex2_12_2.tif"); +gray3=im2double(gray3); //Convert the data type into double range +figure,ShowImage(gray3,'Gray Image'); +title('Original Image'); + +y=variance(gray1); // calculate variance +disp('Variance of Image 1:') +disp(y); +y=variance(gray2); // calculate variance +disp('Variance of Image 2:') +disp(y); +y=variance(gray3); // calculate variance +disp('Variance of Image 3:') +disp(y); + diff --git a/3176/CH2/EX2.2/Ex2_2.sce b/3176/CH2/EX2.2/Ex2_2.sce new file mode 100644 index 000000000..2f64d2ed9 --- /dev/null +++ b/3176/CH2/EX2.2/Ex2_2.sce @@ -0,0 +1,28 @@ +//Ex2_2 +//Illustration of the Effects of Reducing Image Spatial Resolution +// 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). +gray=imread("Ex2_2.tif"); +figure,ShowImage(gray,'Gray Image'); +title('Original Image (1250 DPI)'); +[M,N]=size(gray); +a1=imresize(gray,[443 337],'nearest'); +figure,ShowImage(a1,'Resize Image'); +title('Resize Image (300 DPI)'); + +a2=imresize(gray,[886 675],'nearest'); +figure,ShowImage(a2,'Resize Image'); +title('Resize Image (150 DPI)'); + +a3=imresize(gray,[213 162],'nearest'); +figure,ShowImage(a3,'Resize Image'); +title('Resize Image (72 DPI)'); diff --git a/3176/CH2/EX2.3/Ex2_3.sce b/3176/CH2/EX2.3/Ex2_3.sce new file mode 100644 index 000000000..2af90885b --- /dev/null +++ b/3176/CH2/EX2.3/Ex2_3.sce @@ -0,0 +1,34 @@ +//Ex2_3 +//Typical Effects of Varying the Number of Intensity Levels in a digital Image +// 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). +gray=rgb2gray(imread("Ex2_3.png")); +figure,ShowImage(gray,'Gray Image'); +title('Original Image'); +[nr nc]=size(gray); +b=gray; +level=[128 64 32 16 8 4 2]; +for x=1:length(level) +k=level(x); +for y=1:k +for i=1:nr + for j=1:nc + if(gray(i,j)>=((255/k)*(y-1)) & gray(i,j)<((255/k)*y)) + b(i,j)=((255/k)*(y-1))+((255/k)/2); + end + end +end +end +figure,ShowImage(b,'OutPut Image'); +title('Image With Less Number of Gray Level'); +end + diff --git a/3176/CH2/EX2.4/Ex2_4.sce b/3176/CH2/EX2.4/Ex2_4.sce new file mode 100644 index 000000000..17dee6d04 --- /dev/null +++ b/3176/CH2/EX2.4/Ex2_4.sce @@ -0,0 +1,39 @@ +//Ex2_4 +//Comparision of Interpolation Approaches for Image Shrinking and Zooming +// Version : Scilab 5.4.1 +// Operating System : Window-xp, Window-7 +//Toolbox: Image Processing Design 8.3.1-1 +//Toolbox: SIVP 0.5.3.1-2 +//Reference book name : Digital Image Processing +//book author: Rafael C. Gonzalez and Richard E. Woods + +clc; +close; +clear; +xdel(winsid())//to close all currently open figure(s). +gray=imread("Ex2_4.tif"); +figure,ShowImage(gray,'Gray Image'); +title('Original Image (1250 DPI)'); +[M,N]=size(gray); + +a2=imresize(gray,[213 162],'nearest'); //nearest neigubour Interpolation +figure,ShowImage(a2,'Resize Image'); +title('Resize Image (72 DPI) nearest neigubour Interpolation'); +a2=imresize(gray,[213 162],'bilinear'); ///bilinear Interpolation +figure,ShowImage(a2,'Resize Image'); +title('Resize Image (72 DPI) with bilinear Interpolation'); +a2=imresize(gray,[213 162],'bicubic'); //bicubic Interpolation +figure,ShowImage(a2,'Resize Image'); +title('Resize Image (72 DPI) with bicubic Interpolation'); + +a3=imresize(gray,[886 675],'nearest'); //nearest neigubour Interpolation +figure,ShowImage(a3,'Resize Image'); +title('Resize Image (150 DPI) with nearest neigubour Interpolation'); +a3=imresize(gray,[886 675],'nearest'); ///bilinear Interpolation +figure,ShowImage(a3,'Resize Image'); +title('Resize Image (150 DPI) with bilinear Interpolation'); +a3=imresize(gray,[886 675],'nearest'); //bicubic Interpolation +figure,ShowImage(a3,'Resize Image'); +title('Resize Image (150 DPI) with bicubic Interpolation'); + + diff --git a/3176/CH2/EX2.5/Ex2_5.sce b/3176/CH2/EX2.5/Ex2_5.sce new file mode 100644 index 000000000..326df7f35 --- /dev/null +++ b/3176/CH2/EX2.5/Ex2_5.sce @@ -0,0 +1,43 @@ +//Ex2_5 +//Addition of Noisy Images for Noise Reduction +// 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). +gray=imread("Ex2_5.tif"); +//gray=rgb2gray(a); +gray=im2double(gray); + +figure,ShowImage(gray,'Gray Image'); +title('Original Image'); +[nr nc]=size(gray); +noise_image=gray; + +out_image=double(zeros(nr,nc)); +level=[5 10 20 50 100]; +for i=1:length(level) +No=level(i); +disp(No); +for k=1:No + noisy_image=imnoise(noise_image,'gaussian',0,0.02); +// figure,ShowImage(noisy_image,'Image corrupted by salt & pepper noise');//ShowImage() is used to sho w image, figure is command to view images in separate window. +// title('Image corrupted by Gaussian noise');//title() is used for providing a title to an image. +// disp(size(noise_image)); + out_image=imadd(out_image,noisy_image); +end +out_image=out_image/No; +out_image=mat2gray(out_image); + +figure,ShowImage(out_image,'Image Recoverd from the Noise');//ShowImage() is used to show image, figure is command to view images in separate window. + title('Image Recoverd from the Noise');//title() is used for providing a title to an image. +//Recoverd_Image=0.5*out_image.^0.15;//Gamma Transformation +//figure,ShowImage(Recoverd_Image,'Recoverd Image after Gamma Transormation');//ShowImage() is used to show image, figure is command to view images in separate window. +//title('Image Recoverd from the Noise');//title() is used for providing a title to an image. +end diff --git a/3176/CH2/EX2.6/Ex2_6.sce b/3176/CH2/EX2.6/Ex2_6.sce new file mode 100644 index 000000000..8eb91a2b2 --- /dev/null +++ b/3176/CH2/EX2.6/Ex2_6.sce @@ -0,0 +1,37 @@ +//Ex2_6 +//Image Subtraction for Enhancing differences +// 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). +gray=imread("Ex2_6.tif"); +gray=imresize(gray,0.25,'bicubic'); //Resize the Image with bicubic Interpolation +figure,ShowImage(gray,'Gray Image'); +title('Original Image'); +[nr nc]=size(gray); +for i=1:8 + c(:,:,i)=mtlb_logical(bitget(gray,9-i)); // Separate bit Planes from the Gray Scale Image + +end +c(:,:,8)=zeros(nr,nc); // Set Zeros to LSB +//c(:,:,7)=zeros(nr,nc); // Set Zeros to LSB + +for i=1:nr + for j=1:nc + mask(i,j)=(2^7)*c(i,j,1)+(2^6)*c(i,j,2)+(2^5)*c(i,j,3)+(2^4)*c(i,j,4)+(2^3)*c(i,j,5)+(2^2)*c(i,j,6)+(2^1)*c(i,j,7)+(2^0)*c(i,j,8); + end +end +figure;ShowImage(mask,'Modified Image'); +title('Image Obtained by Setting Zeros to LSB '); +mask=uint8(mask); //Convert the Image to uint8 Data Type +Diff_image=imsubtract(gray,mask); //Subtract two Images +Diff_image=mat2gray(Diff_image); +figure;ShowImage(Diff_image,'Modified Image'); +title('Difference of two images'); diff --git a/3176/CH2/EX2.7/Ex2_7.sce b/3176/CH2/EX2.7/Ex2_7.sce new file mode 100644 index 000000000..96eb47f12 --- /dev/null +++ b/3176/CH2/EX2.7/Ex2_7.sce @@ -0,0 +1,44 @@ +//Ex2_7 +// Image Multiplication for Shadding Correction. +// 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). + +////////////////// Image Division ///////////////////// +gray=imread("Ex2_7.tif"); +shade=imread("Ex2_7_1.tif"); +gray=im2double(imresize(gray,0.5,'bicubic')); //Resize the Image with Bicubic Interpolation +shade=im2double(imresize(shade,0.5,'bicubic')); //Resize the Image with Bicubic Interpolation +figure,ShowImage(gray,'Gray Image'); +title('Original Image'); +figure,ShowImage(shade,'Sahde Image'); +title('Shading Pattern Image'); +[nr nc]=size(gray); +Enhance_image=imdivide(gray,shade); +Enhance_image=mat2gray(Enhance_image); +figure,ShowImage(Enhance_image,'Enhance Image'); +title('Enhance Image after Shading Correction'); + +////////////////// Image Multiplication ///////////////////// +gray=imread("Ex2_7_2.tif"); +mask=imread("Ex2_7_3.tif"); +gray=im2double(imresize(gray,0.5,'bicubic')); //Resize the Image with Bicubic Interpolation +mask=im2double(imresize(mask,0.5,'bicubic')); //Resize the Image with Bicubic Interpolation +figure,ShowImage(gray,'Gray Image'); +title('Original Image'); +figure,ShowImage(mask,'mask Image'); +title('mask Pattern Image(ROI)'); +[nr nc]=size(gray); +Enhance_image=immultiply(gray,mask); +Enhance_image=mat2gray(Enhance_image); +figure,ShowImage(Enhance_image,'Enhance Image'); +title('ROI Selection'); + -- cgit