SlideShare a Scribd company logo
1 of 57
Download to read offline
Digital Image Processing using 
Scilab 
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:UsersSenthilDesktopDigitalImageProcessingcameraman.jpeg'); 
//SIVP toolbox 
J = imread('C:UsersSenthilDesktopDigitalImageProcessingrice.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 Addition 
Image Division 
Image Subtraction 
Image Multiplication
[2]. Image Format Conversion (RGB to Gray and Gray to Binary) 
//Program: Image Format Conversion [Program] 
//[1].RGB to Gray 
//[2]. Gray to Binary 
clc; 
clear; 
close; 
I = imread('C:UsersSenthilDesktopDigitalImageProcessingredrose.jpg'); 
ShowColorImage(I,'Red Rose Color Image') 
//RGB to Gray Image 
I_gray = rgb2gray(I); 
figure 
ShowImage(I_gray,'Red Rose Gray Image') 
Imean = mean2(I_gray); 
Ithreshold = double(Imean)/double(max(I_gray(:))); 
I_bw = im2bw(I,Ithreshold); 
figure 
ShowImage(I_bw,'Red Rose Binary Image')
Red Rose Colour Image Red Rose Gray Image 
Red Rose Binary Image
[3]. Image Interpolation 
//To learn the role of interpolation operation 
// i) Bi-linear ii) Bi-cubic iii) nearest neighbor [Program] 
clc; 
clear; 
close; 
I = 
imread('C:UsersSenthilDesktopDigitalImageProcessingle 
nna512.png');//size 512x512 
ShowColorImage(I,'Lenna512 Colour Image') 
title('Lenna512 Colour Image') 
I = rgb2gray(I); 
[m,n] = size(I);
I_nearest = imresize(I,[256,256]); //'nearest' - nearest-neigbor 
interpolation -SIVP Atom 
I_bilinear = imresize(I,[256,256],'bilinear');// 'bilinear' - bilinear 
interpolation 
I_bicubic = imresize(I,[256,256],'bicubic');//'bicubic' - bicubic 
interpolation 
figure 
ShowImage(uint8(I_nearest),'nearest-neigbor interpolation'); 
title('nearest-neigbor interpolation') 
figure 
ShowImage(uint8(I_bilinear),'bilinear - bilinear interpolation'); 
title('bilinear - bilinear interpolation') 
figure 
ShowImage(uint8(I_bicubic),'bicubic - bicubic interpolation'); 
title('bicubic - bicubic interpolation')
[4]. Point Operations- Image Enhancement 
//Point Operations - To learn image enhancement 
through point transformation [Program] 
//i)Linear transformation ii) Non-linear transformation 
clc; 
clear; 
close; 
I = 
imread('C:UsersSenthilDesktopDigitalImageProcessi 
ngrice.png'); 
//(i). Linear Transformation 
//IMAGE NEGATIVE
I = double(I); 
J = 255-I; 
figure 
ShowImage(I,'Original Image') 
title('Original Image') 
figure 
ShowImage(J,'Linear Transformation-IMAGE NEGATIVE') 
title('Linear Transformation-IMAGE NEGATIVE') 
//(ii) Non-linear transformation 
//GAMMA TRANSFORMATION 
GAMMA = 0.9; 
K = I.^GAMMA; 
figure 
ShowImage(K,'Non-linear transformation-GAMMA TRANSFORMATION') 
title('Non-linear transformation-GAMMA TRANSFORMATION')
[5]. Image Histogram Plot 
//Caption: Histogram Plot [Program] 
clc; 
clear; 
close; 
a=imread('C:UsersSenthilDesktopDigitalImagePro 
cessingpout.jpg') 
[m n]=size(a); 
for i=1:256 
b(i)=length(find(a==(i-1))); 
end
figure, 
ShowImage(a,'Original Image')//IPD toolbox 
title('Original Image') 
figure 
plot2d3('gnn',[0:255],b) 
title('Histogram of the Image') 
//using SIVP Atom 
[count,cells]=imhist(a); 
figure 
plot2d3('gnn',cells,count) 
title('Histogram plot using SIVP atom') 
//using IPD Atom 
Histogram = CreateHistogram(a,cells); 
figure 
plot2d3('gnn',cells,Histogram) 
title('Histogram plot using IPD atom')
[6]. Histogram Equalization 
//Image Histogram Equalisation[Program] 
clc; 
close; 
f=ReadImage('C:UsersSenthilDesktopDigitalImageProcessin 
gpout.jpg');// Get image (Keep image file in same folder) 
OrigSize=size(f);//Get size of original image 
OrigRow=OrigSize(1);//Get number of rows in original image 
OrigCol=OrigSize(2);//Get number of colomns in original image 
figure 
ShowImage(f,'Original Image Pout') 
WriteImage(f,'Exp6OriginalImagePout.jpg') //Comment out if 
you do not want o/p file to be written on disk
OrigHist=CreateHistogram(uint8(f));//Create 
Histogram 
figure 
plot2d3(OrigHist)//Show Histogram 
title('Original Image Histogram') 
P=OrigHist/(OrigRow*OrigCol);//get average pixel 
value 
C=zeros(1,256); 
for i=2:256 
C(1,i)=C(1,i-1)+P(1,i); 
end
Cdash = round(C*255); 
EqImage=[]//Empty matrix for output image 
for i=1:OrigRow 
for j=1:OrigCol 
EqImage(i,j)=Cdash(1,f(i,j)+1); 
end 
end 
figure 
ShowImage(uint8(EqImage),'Image Histogram Equalisation') 
WriteImage(uint8(EqImage),'Exp6ImageHistogramEqualisation.jpg') 
//Comment out if you do not want o/p file to be written on disk 
EqHist=CreateHistogram(uint8(EqImage));//Create Histogram 
figure 
plot2d3(EqHist)//Show Histogram 
title('Histogram Equalized Image')
[7]. Morphological Operations: Dilation and Erosion [Program] 
clc; 
clear; 
close; 
Image = 
imread('C:UsersSenthilDesktopDigitalImageProcessingtire.jpeg'); 
StructureElement = CreateStructureElement('square',3); // generate 
structuring element IPD atom 
ResultImage1 = ErodeImage(Image,StructureElement); //IPD Atom 
ResultImage2 = DilateImage(Image,StructureElement); //IPD Atom 
ResultImage3 = BottomHat(Image,StructureElement); //IPD Atom 
ResultImage4 = TopHat(Image,StructureElement); //IPD Atom 
figure 
ShowImage(Image,'Original Image') 
title('Original tire.jpg Image')
figure 
ShowImage(ResultImage1,'Eroded Image') 
title('Eroded Image') 
figure 
ShowImage(ResultImage2,'Dilated Image') 
title("Dilated Image") 
figure 
ShowImage(ResultImage3,'bottom hat filtered image') 
title('Botton hat filtered Image') 
figure 
ShowImage(ResultImage4,'top hat filtered image') 
title('Top hat Filtered Image') 
ResultImage5 = imadd(ResultImage3,ResultImage4);
figure 
ShowImage(ResultImage4,'top hat filtered 
image+bottom hat filtered image') 
title('Top hat filtered image+ Bottom hat Filtered 
Image')
[8]. Colour Image Manipulations [Program] 
clc 
clear 
close 
//Showing RGB components of a color RGB image. 
//Splitting the color image (RGB Image) into three planes 
a=imread('C:UsersSenthilDesktopDigitalImageProcessingpeppers.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:UsersSenthilDesktopDigitalImageProc 
essingpeppers.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:UsersSenthilDesktopDigitalImageProcessinglenna.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:UsersSenthilDesktopDigitalImageProcessingcameram 
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:UsersSenthilDesktopDigitalImageProcessinglenna.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:UsersSenthilDesktopDigitalImageProcessinglenna. 
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:UserssenthilkumarDesktopGautam_PAL_L 
abDIP_Lab2cameraman.jpeg'); 
J = 
imread('C:UserssenthilkumarDesktopGautam_PAL_L 
abDIP_Lab2lenna.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:UsersSenthilDesktopDigitalImageProcessinglenna.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:UsersSenthilDesktopDigitalImageProc 
essingshuttle_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:UsersSenthilDesktopDigitalImageProcessingshuttle_Xvid.avi'; 
VideoInfo = 
GetVideoStruct('C:UsersSenthilDesktopDigitalImageProcessingshuttle_Xvid.avi'); 
VideoFilePointer = 
OpenVideoFile('C:UsersSenthilDesktopDigitalImageProcessingshuttle_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

More Related Content

What's hot

Class[6][5th aug] [three js-loaders]
Class[6][5th aug] [three js-loaders]Class[6][5th aug] [three js-loaders]
Class[6][5th aug] [three js-loaders]Saajid Akram
 
C Graphics Functions
C Graphics FunctionsC Graphics Functions
C Graphics FunctionsSHAKOOR AB
 
Graphics in C programming
Graphics in C programmingGraphics in C programming
Graphics in C programmingKamal Acharya
 
Templateless Marked Element Recognition Using Computer Vision
Templateless Marked Element Recognition Using Computer VisionTemplateless Marked Element Recognition Using Computer Vision
Templateless Marked Element Recognition Using Computer Visionshivam chaurasia
 
C graphics programs file
C graphics programs fileC graphics programs file
C graphics programs fileshubham kanojia
 
How to develop a Graphical User Interface (GUI) in Scilab
How to develop a Graphical User Interface (GUI) in ScilabHow to develop a Graphical User Interface (GUI) in Scilab
How to develop a Graphical User Interface (GUI) in ScilabScilab
 
Image processing for robotics
Image processing for roboticsImage processing for robotics
Image processing for roboticsSALAAMCHAUS
 
IRJET - Wavelet based Image Fusion using FPGA for Biomedical Application
 IRJET - Wavelet based Image Fusion using FPGA for Biomedical Application IRJET - Wavelet based Image Fusion using FPGA for Biomedical Application
IRJET - Wavelet based Image Fusion using FPGA for Biomedical ApplicationIRJET Journal
 
Computer Graphics Programes
Computer Graphics ProgramesComputer Graphics Programes
Computer Graphics ProgramesAbhishek Sharma
 
QML\Qt Quick на практике
QML\Qt Quick на практикеQML\Qt Quick на практике
QML\Qt Quick на практикеPlatonov Sergey
 

What's hot (16)

Class[6][5th aug] [three js-loaders]
Class[6][5th aug] [three js-loaders]Class[6][5th aug] [three js-loaders]
Class[6][5th aug] [three js-loaders]
 
C Graphics Functions
C Graphics FunctionsC Graphics Functions
C Graphics Functions
 
Graphics in C programming
Graphics in C programmingGraphics in C programming
Graphics in C programming
 
Introduction to graphics programming in c
Introduction to graphics programming in cIntroduction to graphics programming in c
Introduction to graphics programming in c
 
AutoCAD
AutoCAD AutoCAD
AutoCAD
 
10java 2d
10java 2d10java 2d
10java 2d
 
Bai 1
Bai 1Bai 1
Bai 1
 
Templateless Marked Element Recognition Using Computer Vision
Templateless Marked Element Recognition Using Computer VisionTemplateless Marked Element Recognition Using Computer Vision
Templateless Marked Element Recognition Using Computer Vision
 
C graphics programs file
C graphics programs fileC graphics programs file
C graphics programs file
 
How to develop a Graphical User Interface (GUI) in Scilab
How to develop a Graphical User Interface (GUI) in ScilabHow to develop a Graphical User Interface (GUI) in Scilab
How to develop a Graphical User Interface (GUI) in Scilab
 
Image processing for robotics
Image processing for roboticsImage processing for robotics
Image processing for robotics
 
Games 3 dl4-example
Games 3 dl4-exampleGames 3 dl4-example
Games 3 dl4-example
 
IRJET - Wavelet based Image Fusion using FPGA for Biomedical Application
 IRJET - Wavelet based Image Fusion using FPGA for Biomedical Application IRJET - Wavelet based Image Fusion using FPGA for Biomedical Application
IRJET - Wavelet based Image Fusion using FPGA for Biomedical Application
 
Computer Graphics Programes
Computer Graphics ProgramesComputer Graphics Programes
Computer Graphics Programes
 
OpenVX 1.1 Reference Guide
OpenVX 1.1 Reference GuideOpenVX 1.1 Reference Guide
OpenVX 1.1 Reference Guide
 
QML\Qt Quick на практике
QML\Qt Quick на практикеQML\Qt Quick на практике
QML\Qt Quick на практике
 

Similar to Dip iit workshop

Basics of image processing using MATLAB
Basics of image processing using MATLABBasics of image processing using MATLAB
Basics of image processing using MATLABMohsin Siddique
 
Digital Image Processing (Lab 09 and 10)
Digital Image Processing (Lab 09 and 10)Digital Image Processing (Lab 09 and 10)
Digital Image Processing (Lab 09 and 10)Moe Moe Myint
 
CE344L-200365-Lab7.pdf
CE344L-200365-Lab7.pdfCE344L-200365-Lab7.pdf
CE344L-200365-Lab7.pdfUmarMustafa13
 
Intro to computer vision in .net
Intro to computer vision in .netIntro to computer vision in .net
Intro to computer vision in .netStephen Lorello
 
A basic introduction to open cv for image processing
A basic introduction to open cv for image processingA basic introduction to open cv for image processing
A basic introduction to open cv for image processingChu Lam
 
Open Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 TutorialOpen Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 Tutorialantiw
 
Computer graphics
Computer graphics Computer graphics
Computer graphics shafiq sangi
 
I wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdfI wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdffeelinggifts
 
Introducing AlloyUI DiagramBuilder
Introducing AlloyUI DiagramBuilderIntroducing AlloyUI DiagramBuilder
Introducing AlloyUI DiagramBuilderEduardo Lundgren
 
Migrating to Angular 2
Migrating to Angular 2Migrating to Angular 2
Migrating to Angular 2FITC
 
Creating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdfCreating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdfShaiAlmog1
 

Similar to Dip iit workshop (20)

Basics of image processing using MATLAB
Basics of image processing using MATLABBasics of image processing using MATLAB
Basics of image processing using MATLAB
 
Digital Image Processing (Lab 09 and 10)
Digital Image Processing (Lab 09 and 10)Digital Image Processing (Lab 09 and 10)
Digital Image Processing (Lab 09 and 10)
 
Dip 1
Dip 1Dip 1
Dip 1
 
CE344L-200365-Lab7.pdf
CE344L-200365-Lab7.pdfCE344L-200365-Lab7.pdf
CE344L-200365-Lab7.pdf
 
Open Cv Tutorial Ii
Open Cv Tutorial IiOpen Cv Tutorial Ii
Open Cv Tutorial Ii
 
Open Cv Tutorial Ii
Open Cv Tutorial IiOpen Cv Tutorial Ii
Open Cv Tutorial Ii
 
Image processing in MATLAB
Image processing in MATLABImage processing in MATLAB
Image processing in MATLAB
 
Image Processing Using MATLAB
Image Processing Using MATLABImage Processing Using MATLAB
Image Processing Using MATLAB
 
Drawing Figures
Drawing FiguresDrawing Figures
Drawing Figures
 
Intro to computer vision in .net
Intro to computer vision in .netIntro to computer vision in .net
Intro to computer vision in .net
 
Of class1
Of class1Of class1
Of class1
 
A basic introduction to open cv for image processing
A basic introduction to open cv for image processingA basic introduction to open cv for image processing
A basic introduction to open cv for image processing
 
Open Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 TutorialOpen Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 Tutorial
 
Computer graphics
Computer graphics Computer graphics
Computer graphics
 
I wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdfI wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdf
 
Introducing AlloyUI DiagramBuilder
Introducing AlloyUI DiagramBuilderIntroducing AlloyUI DiagramBuilder
Introducing AlloyUI DiagramBuilder
 
Migrating to Angular 2
Migrating to Angular 2Migrating to Angular 2
Migrating to Angular 2
 
Creating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdfCreating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdf
 
dip.pdf
dip.pdfdip.pdf
dip.pdf
 
662305 LAB13
662305 LAB13662305 LAB13
662305 LAB13
 

More from Electronics and Communication Engineering, Institute of Road and Transport Technology (9)

Chennai python augustmeetup
Chennai python augustmeetupChennai python augustmeetup
Chennai python augustmeetup
 
Bang pypers agustmeetup
Bang pypers agustmeetupBang pypers agustmeetup
Bang pypers agustmeetup
 
Sci py india_conference_2019
Sci py india_conference_2019Sci py india_conference_2019
Sci py india_conference_2019
 
Python for Image and Video processing applications
Python for Image and Video processing applicationsPython for Image and Video processing applications
Python for Image and Video processing applications
 
Unit5 power devices and display devices class9
Unit5 power devices and display devices class9Unit5 power devices and display devices class9
Unit5 power devices and display devices class9
 
Unit4 special semiconductor devices class4
Unit4 special semiconductor devices class4Unit4 special semiconductor devices class4
Unit4 special semiconductor devices class4
 
Electronic circuits ii unit5 part1_power_amplifiers
Electronic circuits ii unit5 part1_power_amplifiersElectronic circuits ii unit5 part1_power_amplifiers
Electronic circuits ii unit5 part1_power_amplifiers
 
Electronic circuits ii
Electronic circuits iiElectronic circuits ii
Electronic circuits ii
 
Dsp iit workshop
Dsp iit workshopDsp iit workshop
Dsp iit workshop
 

Recently uploaded

4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxMusic 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxleah joy valeriano
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 

Recently uploaded (20)

4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxMusic 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 

Dip iit workshop

  • 1. Digital Image Processing using Scilab R.Senthilkumar, Assistant Professor, Department of Electronics and Communication Engineering, Institute of Road and Transport Technology, Erode – 638 316
  • 2. [1]. Image Arithmetic //Prog1.Image Arithmetic - To learn to use arithmetic operations to combine images. [Program] clc; clear; close; I = imread('C:UsersSenthilDesktopDigitalImageProcessingcameraman.jpeg'); //SIVP toolbox J = imread('C:UsersSenthilDesktopDigitalImageProcessingrice.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
  • 3. //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
  • 4.
  • 5. Image Addition Image Division Image Subtraction Image Multiplication
  • 6. [2]. Image Format Conversion (RGB to Gray and Gray to Binary) //Program: Image Format Conversion [Program] //[1].RGB to Gray //[2]. Gray to Binary clc; clear; close; I = imread('C:UsersSenthilDesktopDigitalImageProcessingredrose.jpg'); ShowColorImage(I,'Red Rose Color Image') //RGB to Gray Image I_gray = rgb2gray(I); figure ShowImage(I_gray,'Red Rose Gray Image') Imean = mean2(I_gray); Ithreshold = double(Imean)/double(max(I_gray(:))); I_bw = im2bw(I,Ithreshold); figure ShowImage(I_bw,'Red Rose Binary Image')
  • 7. Red Rose Colour Image Red Rose Gray Image Red Rose Binary Image
  • 8. [3]. Image Interpolation //To learn the role of interpolation operation // i) Bi-linear ii) Bi-cubic iii) nearest neighbor [Program] clc; clear; close; I = imread('C:UsersSenthilDesktopDigitalImageProcessingle nna512.png');//size 512x512 ShowColorImage(I,'Lenna512 Colour Image') title('Lenna512 Colour Image') I = rgb2gray(I); [m,n] = size(I);
  • 9. I_nearest = imresize(I,[256,256]); //'nearest' - nearest-neigbor interpolation -SIVP Atom I_bilinear = imresize(I,[256,256],'bilinear');// 'bilinear' - bilinear interpolation I_bicubic = imresize(I,[256,256],'bicubic');//'bicubic' - bicubic interpolation figure ShowImage(uint8(I_nearest),'nearest-neigbor interpolation'); title('nearest-neigbor interpolation') figure ShowImage(uint8(I_bilinear),'bilinear - bilinear interpolation'); title('bilinear - bilinear interpolation') figure ShowImage(uint8(I_bicubic),'bicubic - bicubic interpolation'); title('bicubic - bicubic interpolation')
  • 10.
  • 11. [4]. Point Operations- Image Enhancement //Point Operations - To learn image enhancement through point transformation [Program] //i)Linear transformation ii) Non-linear transformation clc; clear; close; I = imread('C:UsersSenthilDesktopDigitalImageProcessi ngrice.png'); //(i). Linear Transformation //IMAGE NEGATIVE
  • 12. I = double(I); J = 255-I; figure ShowImage(I,'Original Image') title('Original Image') figure ShowImage(J,'Linear Transformation-IMAGE NEGATIVE') title('Linear Transformation-IMAGE NEGATIVE') //(ii) Non-linear transformation //GAMMA TRANSFORMATION GAMMA = 0.9; K = I.^GAMMA; figure ShowImage(K,'Non-linear transformation-GAMMA TRANSFORMATION') title('Non-linear transformation-GAMMA TRANSFORMATION')
  • 13.
  • 14. [5]. Image Histogram Plot //Caption: Histogram Plot [Program] clc; clear; close; a=imread('C:UsersSenthilDesktopDigitalImagePro cessingpout.jpg') [m n]=size(a); for i=1:256 b(i)=length(find(a==(i-1))); end
  • 15. figure, ShowImage(a,'Original Image')//IPD toolbox title('Original Image') figure plot2d3('gnn',[0:255],b) title('Histogram of the Image') //using SIVP Atom [count,cells]=imhist(a); figure plot2d3('gnn',cells,count) title('Histogram plot using SIVP atom') //using IPD Atom Histogram = CreateHistogram(a,cells); figure plot2d3('gnn',cells,Histogram) title('Histogram plot using IPD atom')
  • 16.
  • 17. [6]. Histogram Equalization //Image Histogram Equalisation[Program] clc; close; f=ReadImage('C:UsersSenthilDesktopDigitalImageProcessin gpout.jpg');// Get image (Keep image file in same folder) OrigSize=size(f);//Get size of original image OrigRow=OrigSize(1);//Get number of rows in original image OrigCol=OrigSize(2);//Get number of colomns in original image figure ShowImage(f,'Original Image Pout') WriteImage(f,'Exp6OriginalImagePout.jpg') //Comment out if you do not want o/p file to be written on disk
  • 18. OrigHist=CreateHistogram(uint8(f));//Create Histogram figure plot2d3(OrigHist)//Show Histogram title('Original Image Histogram') P=OrigHist/(OrigRow*OrigCol);//get average pixel value C=zeros(1,256); for i=2:256 C(1,i)=C(1,i-1)+P(1,i); end
  • 19. Cdash = round(C*255); EqImage=[]//Empty matrix for output image for i=1:OrigRow for j=1:OrigCol EqImage(i,j)=Cdash(1,f(i,j)+1); end end figure ShowImage(uint8(EqImage),'Image Histogram Equalisation') WriteImage(uint8(EqImage),'Exp6ImageHistogramEqualisation.jpg') //Comment out if you do not want o/p file to be written on disk EqHist=CreateHistogram(uint8(EqImage));//Create Histogram figure plot2d3(EqHist)//Show Histogram title('Histogram Equalized Image')
  • 20.
  • 21. [7]. Morphological Operations: Dilation and Erosion [Program] clc; clear; close; Image = imread('C:UsersSenthilDesktopDigitalImageProcessingtire.jpeg'); StructureElement = CreateStructureElement('square',3); // generate structuring element IPD atom ResultImage1 = ErodeImage(Image,StructureElement); //IPD Atom ResultImage2 = DilateImage(Image,StructureElement); //IPD Atom ResultImage3 = BottomHat(Image,StructureElement); //IPD Atom ResultImage4 = TopHat(Image,StructureElement); //IPD Atom figure ShowImage(Image,'Original Image') title('Original tire.jpg Image')
  • 22. figure ShowImage(ResultImage1,'Eroded Image') title('Eroded Image') figure ShowImage(ResultImage2,'Dilated Image') title("Dilated Image") figure ShowImage(ResultImage3,'bottom hat filtered image') title('Botton hat filtered Image') figure ShowImage(ResultImage4,'top hat filtered image') title('Top hat Filtered Image') ResultImage5 = imadd(ResultImage3,ResultImage4);
  • 23. figure ShowImage(ResultImage4,'top hat filtered image+bottom hat filtered image') title('Top hat filtered image+ Bottom hat Filtered Image')
  • 24. [8]. Colour Image Manipulations [Program] clc clear close //Showing RGB components of a color RGB image. //Splitting the color image (RGB Image) into three planes a=imread('C:UsersSenthilDesktopDigitalImageProcessingpeppers.png' ); //this image is 348x512x3 size figure ar=a(:,:,1); ShowImage(ar,'RED Matrix') figure ag=a(:,:,2); ShowImage(ag,'GREEN Matrix')
  • 25. figure ab=a(:,:,3); ShowImage(ab,'BLUE Matrix') RGB = imread('C:UsersSenthilDesktopDigitalImageProc essingpeppers.png');//SIVP toolbox RGB_128 = RGB/2; RGB_128 = round(RGB_128) [X,map] = RGB2Ind(RGB_128); figure ShowImage(X,'Indexed Image',map)
  • 26. 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);
  • 27.
  • 28.
  • 29. [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:UsersSenthilDesktopDigitalImageProcessinglenna.j pg'); [m,n]= size(a); ShowImage(a,'Original lenna Image'); title('Original lenna Image') //2D-DFT using FFT A = fft2(double(a));
  • 30. 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')
  • 31.
  • 32. [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:UsersSenthilDesktopDigitalImageProcessingcameram an.jpeg'); figure(1) ShowImage(img,'Original Image') title('Original Image'); [p q] = size(img);
  • 33. [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')
  • 34.
  • 35. [11]. Edge Detection [Program] //Caption: Scilab code for Edge Detection using Different Edge detectors //[1]. Sobel [2].Prewitt close; a = imread('C:UsersSenthilDesktopDigitalImageProcessinglenna.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')
  • 36.
  • 37. //Caption: Scilab code for Edge Detection using Different Edge detectors [Program] //[1]LoG [2] DoG close; a = imread('C:UsersSenthilDesktopDigitalImageProcessinglenna. 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')
  • 38. //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");
  • 39. 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);
  • 40. 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')
  • 41.
  • 42. 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
  • 43. [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:UserssenthilkumarDesktopGautam_PAL_L abDIP_Lab2cameraman.jpeg'); J = imread('C:UserssenthilkumarDesktopGautam_PAL_L abDIP_Lab2lenna.jpg');
  • 44. 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);
  • 45. 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')
  • 46. 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')
  • 47.
  • 48.
  • 49. [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:UsersSenthilDesktopDigitalImageProcessinglenna.jpg '); I_noise = imnoise(I,'salt & pepper'); figure ShowImage(I,'Original Lenna Image') title('Original Lenna Image') figure
  • 50. 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
  • 51. 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')
  • 52.
  • 53. 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
  • 54. clear; clc; close; n = aviopen('C:UsersSenthilDesktopDigitalImageProc essingshuttle_Xvid.avi'); im = avireadframe(n); //get a frame imshow(im); avilistopened() aviclose(n);
  • 55.
  • 56. Image Processing Design Atom is a better tool for Scilab video Processing [Program] clear; clc; close; VideoPath = 'C:UsersSenthilDesktopDigitalImageProcessingshuttle_Xvid.avi'; VideoInfo = GetVideoStruct('C:UsersSenthilDesktopDigitalImageProcessingshuttle_Xvid.avi'); VideoFilePointer = OpenVideoFile('C:UsersSenthilDesktopDigitalImageProcessingshuttle_Xvid.avi'); figure(); for n = 1 : VideoInfo.NumberOfFrames RGB = ReadImage(VideoFilePointer); ShowColorImage(RGB, VideoPath); end; CloseVideoFile(VideoFilePointer);
  • 57. VideoInfo = Codec: "xvid" NumberOfFrames: 121 FrameRate: 30.00003 Width: 512 Height: 288 IsColor: %t