Professional Documents
Culture Documents
net/publication/331318829
CITATIONS READS
3 9,189
1 author:
Dr R Senthilkumar
Government College of Engineering Erode
95 PUBLICATIONS 150 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Dr R Senthilkumar on 25 February 2019.
R.Senthilkumar,
Assistant Professor,
Department of Electronics and Communication
Engineering,
Institute of Road and Transport Technology,
Erode – 638 316
[1]. Image Arithmetic
//Prog1.Image Arithmetic - To learn to use arithmetic operations to combine
images. [Program]
clc;
clear;
close;
I = imread('C:\Users\Senthil\Desktop\DigitalImageProcessing\cameraman.jpeg');
//SIVP toolbox
J = imread('C:\Users\Senthil\Desktop\DigitalImageProcessing\rice.png');//SIVP
toolbox
//Addition of two images
IMA = imadd(I,J); //SIVP toolbox
figure
ShowImage(IMA,'Image Addition')//IPD toolbox
//Difference between two images
IMS = imabsdiff(I,J);//SIVP toolbox
figure
ShowImage(IMS,'Image Subtraction');//IPD toolbox
//Division of two images
IMD = imdivide(I,J);//SIVP toolbox
IMD = imdivide(IMD,0.01);//SIVP toolbox
figure
ShowImage(uint8(IMD),'Image Division');//IPD
toolbox
//Multiplication of two images
IMM = immultiply(I,I);//SIVP toolbox
figure
ShowImage(uint8(IMM),'Image Multiply');//IPD
toolbox
Image Subtraction
Image Addition
a=imread('C:\Users\Senthil\Desktop\DigitalImageProcessing\peppers.png'
); //this image is 348x512x3 size
figure
ar=a(:,:,1);
ShowImage(ar,'RED Matrix')
figure
ag=a(:,:,2);
ShowImage(ag,'GREEN Matrix')
figure
ab=a(:,:,3);
ShowImage(ab,'BLUE Matrix')
RGB =
imread('C:\Users\Senthil\Desktop\DigitalImageProc
essing\peppers.png');//SIVP toolbox
RGB_128 = RGB/2;
RGB_128 = round(RGB_128)
[X,map] = RGB2Ind(RGB_128);
figure
ShowImage(X,'Indexed Image',map)
figure
ShowColorImage(RGB,'RGB Color Image')
YIQ = rgb2ntsc(RGB);
figure
ShowColorImage(YIQ,'NTSC image YIQ')
RGB = ntsc2rgb(YIQ);
YCC = rgb2ycbcr(RGB);
figure
ShowColorImage(YCC,'equivalent HSV image YCbCr')
RGB = ycbcr2rgb(YCC);
HSV = rgb2hsv(RGB);
figure
ShowColorImage(HSV,'equivalent HSV image')
RGB = hsv2rgb(HSV);
[9]. Fourier Transform of 2D Gray Image [Program]
//Caption: 2D-Discrete Fourier Transform using inbuilt fast fourier
transform
//function fft2()
clc;
clear;
close;
a=
ReadImage('C:\Users\Senthil\Desktop\DigitalImageProcessing\lenna.j
pg');
[m,n]= size(a);
ShowImage(a,'Original lenna Image');
title('Original lenna Image')
//2D-DFT using FFT
A = fft2(double(a));
figure(1)
ShowImage(abs(A),'2D-Discrete Fourier Transform of Lena Image');
title('2D-Discrete Fourier Transform of Lena Image')
//fftshifted image
B = fftshift(A)
figure(2)
ShowImage(abs(B),'2D-Discrete Fourier Transform of Lena Image-
fftshifted');
title('2D-Discrete Fourier Transform of Lena Image-fftshifted')
//2D-IDFT using FFT
a_inv = fft2(A')
a_inv = a_inv'/(m*n);
figure(3)
ShowImage(uint8(abs(a_inv)),'2D-Inverse Discrete Fourier Transform ');
title('2D-Inverse Discrete Fourier Transform')
[10]. Discrete Wavelet Transform and Inverse
Discrete Wavelet Transform [Program]
//Caption: Scilab code to implement Discrete Wavelet Transform
clc;
clear;
close;
//Original Image
img =
imread('C:\Users\Senthil\Desktop\DigitalImageProcessing\cameram
an.jpeg');
figure(1)
ShowImage(img,'Original Image')
title('Original Image');
[p q] = size(img);
[CA,CH,CV,CD] = dwt2(double(img),'db1');//Compute 2D wavelet transform -daubcheis
wavelet
figure(2)
ShowImage(uint8(CA),'LPF-LPF output')
title('LPF-LPF output')
figure(3)
ShowImage(uint8(CH),'LPF-HPF output')
title('LPF-HPF output')
figure(4)
ShowImage(uint8(CV),'HPF-LPF output')
title('HPF-LPF output')
figure(5)
ShowImage(uint8(CD),'HPF-HPF output')
title('HPF-HPF output')
img_inv = idwt2(CA,CH,CV,CD,'db1');
img_inv = uint8(img_inv);
figure(6)
ShowImage(img_inv,'Reconstructed Image')
title('Reconstructed Image')
[11]. Edge Detection [Program]
//Caption: Scilab code for Edge Detection using Different Edge detectors
//[1]. Sobel [2].Prewitt
close;
a = imread('C:\Users\Senthil\Desktop\DigitalImageProcessing\lenna.jpg');
c = edge(a,'sobel');
d = edge(a,'prewitt');
ShowImage(a,'Original Image')
title('Original Image')
figure
ShowImage(c,'Edge Detected Image-Sobel')
title('Edge Detected Image -Sobel')
figure
ShowImage(d,'Edge Detected Image-Prewitt')
title('Edge Detected Image-Prewitt')
//Caption: Scilab code for Edge Detection using Different Edge
detectors [Program]
//[1]LoG [2] DoG
close;
a=
imread('C:\Users\Senthil\Desktop\DigitalImageProcessing\lenna.
jpg');
//LAPLACIAN OF GAUSSIAN////////////////////////////////////////////////
[c,thresh] = edge(a,'log',0.2,'both',2);
//d = edge(a,'prewitt');
ShowImage(a,'Original Image')
title('Original Image')
figure
ShowImage(c,'Edge Detected Image-LoG')
//DERIVATIVE OF GAUSSIAN FUNCTION
function [mask]=DoG(op1,op2)
//If op1 and op2 are not specified -Default size 3x3
if isempty(op1) then
siz = [3,3];
else
if length(op1)==1 then
siz = [op1, op1];
elseif length(op1)==2 then
siz = op1;
else
error("The second argument should have 1 or 2 elements for gaussian filter");
end
end
//set std for the filter
if isempty(op2) then
g_std = 0.5;
else
if length(op2)>1 then
error("The third argument should have only 1 element for gaussian filter");
else
g_std = op2;
end
end
sizx = (siz(2)-1)/2;
sizy = (siz(1)-1)/2;
x2 = ones(siz(1),1) * ([-sizx:sizx]^2);
y2 = ([-sizy:sizy]^2)' * ones(1, siz(2));
r = sqrt(x2+y2);
sigma = g_std;
F = (1/(sigma^2))*(((r.*r)/sigma^2)-1).*exp(-r.*r/2*sigma^2);
F(F<%eps*max(F)) = 0;
sumF=sum(F);
if sumF~=0 then
F = F / sum(F);
end
mask = F;
endfunction
mask = DoG([ ],[ ]);
mx=filter2(mask,a);
my=filter2(mask',a);
border=sqrt(mx.*mx + my.*my);
if thresh >=0 then
scale_thresh = min(border) * (1-thresh) + max(border)*thresh;
border=border > scale_thresh;
end
d = border;
figure
ShowImage(d,'Edge Detected Image-DoG')
Image Enhancement Methods
[13].Brightness enhancement
[14]. Brightness suppression
[15].Contrast Manipulation
[16]. Image Negative
[17]. Threshold Operation on Gray Image
[18]. Gray level slicing without background
[19]. Image Cropping, Image Complement and Linear
Combination of Images
//Image Arithmetic: Image Complement, Image
//Cropping and Linear Combination of Images [Program]
clc;
clear;
close;
I=
imread('C:\Users\senthilkumar\Desktop\Gautam_PAL_L
ab\DIP_Lab2\cameraman.jpeg');
J=
imread('C:\Users\senthilkumar\Desktop\Gautam_PAL_L
ab\DIP_Lab2\lenna.jpg');
K = imabsdiff(I,J);
ShowImage(I,'Cameraman Image')
title('Cameraman Image')
figure
ShowImage(J,'Lenna Image')
title("Lenna Image")
figure
ShowImage(K,'Absolute Difference Between
cameraman and Lenna Image')
title('Absolute Difference Between cameraman and
Lenna Image')
L = imcomplement(K);
figure
ShowImage(L,'Complement of difference Image K ')
title('Complement of difference Image ')
rect = [20,30,200,200];
I_subimage = imcrop(I,rect);
J_subimage = imcrop(J,rect);
figure
ShowImage(I_subimage,'Sub Image of Cameraman
Image')
title('Sub Image of Cameraman Image')
figure
ShowImage(J_subimage,'Sub Image of Lenna Image')
title('Sub Image of Lenna Image')
a=2;
b =0.5;
M = imlincomb(a,I,b,J);
figure
ShowImage(M,'Linear Combination of cameraman and
Lenna Image')
title('Linear Combination of cameraman and Lenna Image')
N= imlincomb(b,I,a,J);
figure
ShowImage(N,'Linear Combination of cameraman and
Lenna Image')
title('Linear Combination of cameraman and Lenna Image')
[20]. Image Filtering and De-noising
//Neighborhood Operations - To learn about neighborhood
operations and use them for
//i) Linear filtering ii) Non-linear filtering [Program]
clc;
clear;
close;
I=
imread('C:\Users\Senthil\Desktop\DigitalImageProcessing\lenna.jpg
');
I_noise = imnoise(I,'salt & pepper');
figure
ShowImage(I,'Original Lenna Image')
title('Original Lenna Image')
figure
ShowImage(I_noise,'Noisy Lenna Image')
title('Noisy Lenna Image')
//Case 1: Linear Filtering
//(i).Linear Filtering -Example 1: Average Filter
F_linear1 = 1/25*ones(5,5);//5x5 mask
I_linear1 = imfilter(I_noise,F_linear1);//linear filtering
-Average Filter
figure
ShowImage(I_linear1,'Linear Average Filtered Noisy
Lenna Image')
title('Linear Average Filtered Noisy Lenna Image')
//(ii).Linear Filtering - Example 2: Gaussing filter
hsize = [5,5];
sigma = 1;
F_linear2 = fspecial('gaussian', hsize, sigma); //Linear filtering-
gaussian Filter
I_linear2 = imfilter(I_noise,F_linear2);
figure
ShowImage(I_linear2,'Linear Gaussian Filtered Noisy Lenna Image')
title('Linear Gaussian Filtered Noisy Lenna Image')
//Case 2: Non-Linear Filtering (i).Median Filtering
F_NonLinear = [3,3];
I_NonLinear = MedianFilter(I_noise,F_NonLinear);//Median Filter
3x3
figure
ShowImage(I_NonLinear,'Median Filtered(Non-Linear) Noisy Lenna
Image')
title('Median Filtered(Non-Linear) Noisy Lenna Image')
Video Processing -Introduction
Scilab Image and Video Processing [Program]
//Program Simple video reading and writing .avi formats and
manipulation of video frames.
//Note 1: Install xvid codec for read and write video files from
//http://www.xvid.org/Downloads.15.0.html
//Note 2: very large video can not be read by scilab
//Note 3: shuttle.avi is a large file more 100 frames. use shuttlenew.avi file
//for video processing applications
//Using SIVP Atom
//Software version
//OS Windows7 ,8
//Scilab5.4.1 and above
//Image Processing Design Toolbox 8.3.1-1
//Scilab Image and Video Proccessing toolbox 0.5.3.1-2
clear;
clc;
close;
n=
aviopen('C:\Users\Senthil\Desktop\DigitalImageProc
essing\shuttle_Xvid.avi');
im = avireadframe(n); //get a frame
imshow(im);
avilistopened()
aviclose(n);
Image Processing Design Atom is a better tool for Scilab video
Processing [Program]
clear;
clc;
close;
VideoPath = 'C:\Users\Senthil\Desktop\DigitalImageProcessing\shuttle_Xvid.avi';
VideoInfo =
GetVideoStruct('C:\Users\Senthil\Desktop\DigitalImageProcessing\shuttle_Xvid.avi');
VideoFilePointer =
OpenVideoFile('C:\Users\Senthil\Desktop\DigitalImageProcessing\shuttle_Xvid.avi');
figure();
for n = 1 : VideoInfo.NumberOfFrames
RGB = ReadImage(VideoFilePointer);
ShowColorImage(RGB, VideoPath);
end;
CloseVideoFile(VideoFilePointer);
VideoInfo =
Codec: "xvid"
NumberOfFrames: 121
FrameRate: 30.00003
Width: 512
Height: 288
IsColor: %t