SlideShare una empresa de Scribd logo
1 de 16
To read an image into ‘a’ variable
a=imread(C:Usersm12cs018Desktopr1.jpg)
To obtain information about a graphics file and its
contents:
imfinfo('C:Usersm12cs018Desktopr1.jpg')
Filename: 'C:Usersm12cs018Desktopr1.jpg'
FileModDate: '13-Mar-2013 14:26:31'
FileSize: 93228
Format: 'png'
FormatVersion: []
Width: 194
Height: 279
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: [137 80 78 71 13 10 26 10]
Colormap: [ ]
Histogram: [ ]
InterlaceType: 'none'
Transparency: 'none'
SimpleTransparencyData: [ ]
BackgroundColor: [ ]
RenderingIntent: 'perceptual'
Chromaticities: [0.3127 0.3290 0.6400 0.3300 0.3000 0.6000 0.1500 0.0600]
Gamma: 0.4545
XResolution: 3779
YResolution: 3779
ResolutionUnit: 'meter'
XOffset: [ ]
YOffset: [ ]
OffsetUnit: [ ]
SignificantBits: [ ]
Convert image to binary image, based on threshold
BW = im2bw(I, level) converts the grayscale image I to a binary image. The
output image BW replaces all pixels in the input image with luminance greater than
level with the value 1 (white) and replaces all other pixels with the value 0 (black).
>>b= im2bw(a,0.89)
>> imshow(b);
Convert an RGB image to a grayscale image
>>c=rgb2gray(a)
>> imshow(c);
Display histogram of image data
>> imhist(c)
Contrast enhancement
imadjust
Adjust image intensity values or colormap
Syntax: J = imadjust(I)
Creating the binary of an image using graythresh
Thresholding can be performed by using the graythresh
Global image threshold using Otsu's method
Syntax
level = graythresh(I)
level = graythresh(I) computes a global threshold (level)
that can be used to convert an intensity image to a binary image
with im2bw. level is a normalized intensity value that lies in the
range [0, 1].
I=rgb2gray(a)
level = graythresh(I);
BW = im2bw(I,level);
imshow(BW)
histeq
Enhance contrast using histogram equalization.
a=imread('C:fp1.jpg')
b=rgb2gray(a)
imhist(b)
0
100
200
300
400
500
0 50 100 150 200 250
c=histeq(b)
imhist(c)
0
100
200
300
400
500
600
700
800
900
1000
0 50 100 150 200 250
Spatial Transformations
To resize an image, use the imresize function. When you resize an image, you specify the image to be
resized and the magnification factor. To enlarge an image, specify a magnification factor greater than 1. To
reduce an image, specify a magnification factor between 0 and 1.
For example, the command below reduces the size of an image by 0.75 times.
>> I = rgb2gray(a); >> J = imresize(I,.75);
>> imshow(I) >>imshow(J)
You can specify the size of the output image by passing a vector that contains the number of rows and columns in
the output image.
If the specified size does not produce the same aspect ratio as the input image, the
output image will be distorted.
This example creates an output image with 100 rows and 150 columns.
>>J = imresize(I,[100 150]);
To use bilinear
>>Y = imresize(X,[100 150],'bilinear')
Using the imcrop function
imcrop is used to extract a rectangular portion of an image,
You can specify the crop region interactively using the mouse
>>J = imcrop(I);
or
You can specify the crop rectangle as a four-element position vector, [xmin
ymin width height] i.e, [60 40 100 90]
>>J = imcrop(I,[60 40 100 90]);
To rotate an image
Use the imrotate function. We specify rotation angle, in degrees.
If you specify a positive rotation angle, imrotate rotates the image counterclockwise;
if you specify a negative rotation angle, imrotate rotates the image clockwise.
To rotate the image 35° counterclockwise using bilinear interpolation
>>J = imrotate(I,35,'bilinear');
>>imshow(J)
imrotate uses nearest-neighbor
interpolation by default to determine the
value of pixels in the output image, but
you can specify other interpolation
methods.
To perfrom Translation to (40,40) from origin
>> xform = [ 1 0 0
0 1 0
40 40 1 ]
xform =
1 0 0
0 1 0
40 40 1
>> tform_translate =
maketform('affine',xform);
>> k= imtransform(I, tform_translate);
>>[cb_trans xdata ydata]= imtransform(I,
tform_translate);
>> cb_trans2 = imtransform(I,
tform_translate,...
'XData', [1 (size(I,2)+ xform(3,1))],...
'YData', [1 (size(I,1)+ xform(3,2))]);
>> imshow(cb_trans2)
Image Arithmetic
Creating the negative of an image using imcomplement
>>J=imcomplement(I)
>> imshow(J)
Imadd
Add two images or add constant to image
c=imresize(a,[300,300])
d=imresize(b,[300,300])
imshow(c)
K=imadd(c,d)
imshow(K)
OUTPUT:
imsubtract
Subtract one image from another or subtract constant from image
K=imsubtract(c,d)
imshow(K)
imdivide
Divides two images or divides image by constant
K=imdivide(c,d)
imshow(K)
immultiply
Multiply two images or multiply image by constant
K=immultiply(c,d)
imshow(K)
imabsdiff
absolute difference of two images
K=immultiply(c,d)
imshow(K)
To display an image in the background and another image on foreground.
>> b = imresize(a,[300 300]);
>> d = imresize(c,[300 300]);
>> e = imlincomb(.5,b,.5,d);
>> imshow(b)
>> imshow(d)
>> imshow(e)
Removing Noise By Adaptive Filtering
I = rgb2gray(a);
>> imshow(I)
>> J = imnoise(I,'gaussian',0,0.025);
>> imshow(I)
>> imshow(J)
Output after applying Gaussian noise.
Remove the noise, using the wiener2 function.
K = wiener2(J,[5 5]);
imshow(K)
Removing noise using Median filter
K=medfilt2(J,[3 3])
imshow(K)
Removing noise using Gaussian filter
1. Add Salt and pepper noise
J=imnoise(I,'salt & pepper',.02)
imshow(J)
2. Creating Gaussian filter
h = fspecial(type,parameters) creates a two-
dimensional filter h of the specified type. fspecial
returns h as a correlation kernel, which is the
appropriate form to use with imfilter. type is a string
having one of these values.
h=fspecial('gaussian',[3 3],.7)
h =
0.0113 0.0838 0.0113
0.0838 0.6193 0.0838
0.0113 0.0838 0.0113
3. Filter noisy image with Gaussian filter
L=imfilter(J,h)
imshow(L)
Removing noise using 2 dimensionl order-statistics filter
L=ordfilt2(J,5,ones(3,3))
imshow(L)
-1
-0.5
0
0.5
1
-1
0
1
0
0.5
1
Fx
F
y
Magnitude
Removing noise using Averaging filter
1.Create kernel for average filter with low pass characterisitics
k=[ 1 1 1
1 1 1
1 1 1]/9
k =
0.1111 0.1111 0.1111
0.1111 0.1111 0.1111
0.1111 0.1111 0.1111
2. Plot frequency response characteristics
freqz2(k)
3.Apply averaging filter
Filter M=imfilter(J,k)
imshow(M)
Find the edges of an image using the Prewitt , Sobel and Canny methods.
BW1 = edge(I,'prewitt');
BW2 = edge(I,'canny');
Imshow(BW2)
BW2 = edge(I,'sobel');
Imshow(BW2)
Visit my blog:
enthusiaststudent.blogspot.in
Simple Matlab tutorial using matlab inbuilt commands

Más contenido relacionado

La actualidad más candente

Morphological Image Processing
Morphological Image ProcessingMorphological Image Processing
Morphological Image Processingkumari36
 
Digital image processing using matlab: basic transformations, filters and ope...
Digital image processing using matlab: basic transformations, filters and ope...Digital image processing using matlab: basic transformations, filters and ope...
Digital image processing using matlab: basic transformations, filters and ope...thanh nguyen
 
Image Processing using Matlab ( using a built in Matlab function(Histogram eq...
Image Processing using Matlab ( using a built in Matlab function(Histogram eq...Image Processing using Matlab ( using a built in Matlab function(Histogram eq...
Image Processing using Matlab ( using a built in Matlab function(Histogram eq...Majd Khaleel
 
Zooming an image in visual basic
Zooming an image in visual basicZooming an image in visual basic
Zooming an image in visual basicHotland Sitorus
 
A Comparative Study of Histogram Equalization Based Image Enhancement Techniq...
A Comparative Study of Histogram Equalization Based Image Enhancement Techniq...A Comparative Study of Histogram Equalization Based Image Enhancement Techniq...
A Comparative Study of Histogram Equalization Based Image Enhancement Techniq...Shahbaz Alam
 
Erosion and dilation
Erosion and dilationErosion and dilation
Erosion and dilationAkhil .B
 
morphological tecnquies in image processing
morphological tecnquies in image processingmorphological tecnquies in image processing
morphological tecnquies in image processingsoma saikiran
 
Image processing using matlab
Image processing using matlab Image processing using matlab
Image processing using matlab SangeethaSasi1
 
Math behind the kernels
Math behind the kernelsMath behind the kernels
Math behind the kernelsRevanth Kumar
 
Image enhancement using alpha rooting based hybrid technique
Image enhancement using alpha rooting based hybrid techniqueImage enhancement using alpha rooting based hybrid technique
Image enhancement using alpha rooting based hybrid techniqueRahul Yadav
 
Lect 02 second portion
Lect 02  second portionLect 02  second portion
Lect 02 second portionMoe Moe Myint
 
Image Texture Analysis
Image Texture AnalysisImage Texture Analysis
Image Texture Analysislalitxp
 

La actualidad más candente (20)

Morphological Image Processing
Morphological Image ProcessingMorphological Image Processing
Morphological Image Processing
 
Digital image processing using matlab: basic transformations, filters and ope...
Digital image processing using matlab: basic transformations, filters and ope...Digital image processing using matlab: basic transformations, filters and ope...
Digital image processing using matlab: basic transformations, filters and ope...
 
Hit and-miss transform
Hit and-miss transformHit and-miss transform
Hit and-miss transform
 
Image Processing using Matlab ( using a built in Matlab function(Histogram eq...
Image Processing using Matlab ( using a built in Matlab function(Histogram eq...Image Processing using Matlab ( using a built in Matlab function(Histogram eq...
Image Processing using Matlab ( using a built in Matlab function(Histogram eq...
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
Mathematical tools in dip
Mathematical tools in dipMathematical tools in dip
Mathematical tools in dip
 
Zooming an image in visual basic
Zooming an image in visual basicZooming an image in visual basic
Zooming an image in visual basic
 
A Comparative Study of Histogram Equalization Based Image Enhancement Techniq...
A Comparative Study of Histogram Equalization Based Image Enhancement Techniq...A Comparative Study of Histogram Equalization Based Image Enhancement Techniq...
A Comparative Study of Histogram Equalization Based Image Enhancement Techniq...
 
Erosion and dilation
Erosion and dilationErosion and dilation
Erosion and dilation
 
morphological tecnquies in image processing
morphological tecnquies in image processingmorphological tecnquies in image processing
morphological tecnquies in image processing
 
Matlab
MatlabMatlab
Matlab
 
Histogram processing
Histogram processingHistogram processing
Histogram processing
 
Resize image vb.net
Resize image vb.netResize image vb.net
Resize image vb.net
 
Image processing using matlab
Image processing using matlab Image processing using matlab
Image processing using matlab
 
Math behind the kernels
Math behind the kernelsMath behind the kernels
Math behind the kernels
 
Week 6
Week 6Week 6
Week 6
 
Image enhancement using alpha rooting based hybrid technique
Image enhancement using alpha rooting based hybrid techniqueImage enhancement using alpha rooting based hybrid technique
Image enhancement using alpha rooting based hybrid technique
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
Lect 02 second portion
Lect 02  second portionLect 02  second portion
Lect 02 second portion
 
Image Texture Analysis
Image Texture AnalysisImage Texture Analysis
Image Texture Analysis
 

Similar a Simple Matlab tutorial using matlab inbuilt commands

DIP-Enhancement-Spatial.pptx
DIP-Enhancement-Spatial.pptxDIP-Enhancement-Spatial.pptx
DIP-Enhancement-Spatial.pptxNidhiSharma764884
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniquesSaideep
 
Image enhancement techniques
Image enhancement techniques Image enhancement techniques
Image enhancement techniques Arshad khan
 
Image processing basics using matlab
Image processing basics using matlabImage processing basics using matlab
Image processing basics using matlabAnkur Tyagi
 
imageenhancementtechniques-140316011049-phpapp01 (1).pptx
imageenhancementtechniques-140316011049-phpapp01 (1).pptximageenhancementtechniques-140316011049-phpapp01 (1).pptx
imageenhancementtechniques-140316011049-phpapp01 (1).pptxsalutiontechnology
 
CE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdfCE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdfUmarMustafa13
 
Computer vision image enhancement ppt prajwal deshmukh
Computer vision image enhancement ppt prajwal deshmukhComputer vision image enhancement ppt prajwal deshmukh
Computer vision image enhancement ppt prajwal deshmukhprajdesh26
 
Image Processing using Matlab . Useful for beginners to learn Image Processing
Image Processing using Matlab . Useful for beginners to learn Image ProcessingImage Processing using Matlab . Useful for beginners to learn Image Processing
Image Processing using Matlab . Useful for beginners to learn Image ProcessingAshok Kumar
 
Can someone please explain what the code below is doing and comment on.pdf
Can someone please explain what the code below is doing and comment on.pdfCan someone please explain what the code below is doing and comment on.pdf
Can someone please explain what the code below is doing and comment on.pdfkuldeepkumarapgsi
 
Introduction To Advanced Image Processing
Introduction To Advanced Image ProcessingIntroduction To Advanced Image Processing
Introduction To Advanced Image ProcessingSuren Kumar
 
openFrameworks 007 - graphics
openFrameworks 007 - graphicsopenFrameworks 007 - graphics
openFrameworks 007 - graphicsroxlu
 

Similar a Simple Matlab tutorial using matlab inbuilt commands (20)

DIP-Enhancement-Spatial.pptx
DIP-Enhancement-Spatial.pptxDIP-Enhancement-Spatial.pptx
DIP-Enhancement-Spatial.pptx
 
Dip syntax 4
Dip syntax 4Dip syntax 4
Dip syntax 4
 
HTML 5_Canvas
HTML 5_CanvasHTML 5_Canvas
HTML 5_Canvas
 
matlab.docx
matlab.docxmatlab.docx
matlab.docx
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniques
 
Image enhancement techniques
Image enhancement techniques Image enhancement techniques
Image enhancement techniques
 
Image processing basics using matlab
Image processing basics using matlabImage processing basics using matlab
Image processing basics using matlab
 
Dip 2
Dip 2Dip 2
Dip 2
 
imageenhancementtechniques-140316011049-phpapp01 (1).pptx
imageenhancementtechniques-140316011049-phpapp01 (1).pptximageenhancementtechniques-140316011049-phpapp01 (1).pptx
imageenhancementtechniques-140316011049-phpapp01 (1).pptx
 
CE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdfCE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdf
 
Computer vision image enhancement ppt prajwal deshmukh
Computer vision image enhancement ppt prajwal deshmukhComputer vision image enhancement ppt prajwal deshmukh
Computer vision image enhancement ppt prajwal deshmukh
 
image enhancement.pptx
image enhancement.pptximage enhancement.pptx
image enhancement.pptx
 
Image Processing using Matlab . Useful for beginners to learn Image Processing
Image Processing using Matlab . Useful for beginners to learn Image ProcessingImage Processing using Matlab . Useful for beginners to learn Image Processing
Image Processing using Matlab . Useful for beginners to learn Image Processing
 
Can someone please explain what the code below is doing and comment on.pdf
Can someone please explain what the code below is doing and comment on.pdfCan someone please explain what the code below is doing and comment on.pdf
Can someone please explain what the code below is doing and comment on.pdf
 
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
 
Introduction To Advanced Image Processing
Introduction To Advanced Image ProcessingIntroduction To Advanced Image Processing
Introduction To Advanced Image Processing
 
Dip 3
Dip 3Dip 3
Dip 3
 
openFrameworks 007 - graphics
openFrameworks 007 - graphicsopenFrameworks 007 - graphics
openFrameworks 007 - graphics
 
Test
TestTest
Test
 

Más de Lakshmi Sarvani Videla (20)

Data Science Using Python
Data Science Using PythonData Science Using Python
Data Science Using Python
 
Programs on multithreading
Programs on multithreadingPrograms on multithreading
Programs on multithreading
 
Menu Driven programs in Java
Menu Driven programs in JavaMenu Driven programs in Java
Menu Driven programs in Java
 
Recursion in C
Recursion in CRecursion in C
Recursion in C
 
Simple questions on structures concept
Simple questions on structures conceptSimple questions on structures concept
Simple questions on structures concept
 
Errors incompetitiveprogramming
Errors incompetitiveprogrammingErrors incompetitiveprogramming
Errors incompetitiveprogramming
 
Relational Operators in C
Relational Operators in CRelational Operators in C
Relational Operators in C
 
Recursive functions in C
Recursive functions in CRecursive functions in C
Recursive functions in C
 
Function Pointer in C
Function Pointer in CFunction Pointer in C
Function Pointer in C
 
Functions
FunctionsFunctions
Functions
 
Java sessionnotes
Java sessionnotesJava sessionnotes
Java sessionnotes
 
Singlelinked list
Singlelinked listSinglelinked list
Singlelinked list
 
Graphs
GraphsGraphs
Graphs
 
B trees
B treesB trees
B trees
 
Functions in python3
Functions in python3Functions in python3
Functions in python3
 
Dictionary
DictionaryDictionary
Dictionary
 
Sets
SetsSets
Sets
 
Lists
ListsLists
Lists
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
 

Último

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 

Último (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 

Simple Matlab tutorial using matlab inbuilt commands

  • 1. To read an image into ‘a’ variable a=imread(C:Usersm12cs018Desktopr1.jpg) To obtain information about a graphics file and its contents: imfinfo('C:Usersm12cs018Desktopr1.jpg') Filename: 'C:Usersm12cs018Desktopr1.jpg' FileModDate: '13-Mar-2013 14:26:31' FileSize: 93228 Format: 'png' FormatVersion: [] Width: 194 Height: 279 BitDepth: 24 ColorType: 'truecolor' FormatSignature: [137 80 78 71 13 10 26 10] Colormap: [ ] Histogram: [ ] InterlaceType: 'none' Transparency: 'none' SimpleTransparencyData: [ ] BackgroundColor: [ ] RenderingIntent: 'perceptual' Chromaticities: [0.3127 0.3290 0.6400 0.3300 0.3000 0.6000 0.1500 0.0600] Gamma: 0.4545 XResolution: 3779 YResolution: 3779 ResolutionUnit: 'meter' XOffset: [ ] YOffset: [ ] OffsetUnit: [ ] SignificantBits: [ ]
  • 2. Convert image to binary image, based on threshold BW = im2bw(I, level) converts the grayscale image I to a binary image. The output image BW replaces all pixels in the input image with luminance greater than level with the value 1 (white) and replaces all other pixels with the value 0 (black). >>b= im2bw(a,0.89) >> imshow(b); Convert an RGB image to a grayscale image >>c=rgb2gray(a) >> imshow(c); Display histogram of image data >> imhist(c)
  • 3. Contrast enhancement imadjust Adjust image intensity values or colormap Syntax: J = imadjust(I) Creating the binary of an image using graythresh Thresholding can be performed by using the graythresh Global image threshold using Otsu's method Syntax level = graythresh(I) level = graythresh(I) computes a global threshold (level) that can be used to convert an intensity image to a binary image with im2bw. level is a normalized intensity value that lies in the range [0, 1]. I=rgb2gray(a) level = graythresh(I); BW = im2bw(I,level); imshow(BW)
  • 4. histeq Enhance contrast using histogram equalization. a=imread('C:fp1.jpg') b=rgb2gray(a) imhist(b) 0 100 200 300 400 500 0 50 100 150 200 250 c=histeq(b) imhist(c)
  • 5. 0 100 200 300 400 500 600 700 800 900 1000 0 50 100 150 200 250 Spatial Transformations To resize an image, use the imresize function. When you resize an image, you specify the image to be resized and the magnification factor. To enlarge an image, specify a magnification factor greater than 1. To reduce an image, specify a magnification factor between 0 and 1. For example, the command below reduces the size of an image by 0.75 times. >> I = rgb2gray(a); >> J = imresize(I,.75); >> imshow(I) >>imshow(J)
  • 6. You can specify the size of the output image by passing a vector that contains the number of rows and columns in the output image. If the specified size does not produce the same aspect ratio as the input image, the output image will be distorted. This example creates an output image with 100 rows and 150 columns. >>J = imresize(I,[100 150]); To use bilinear >>Y = imresize(X,[100 150],'bilinear') Using the imcrop function imcrop is used to extract a rectangular portion of an image, You can specify the crop region interactively using the mouse >>J = imcrop(I); or You can specify the crop rectangle as a four-element position vector, [xmin ymin width height] i.e, [60 40 100 90] >>J = imcrop(I,[60 40 100 90]);
  • 7. To rotate an image Use the imrotate function. We specify rotation angle, in degrees. If you specify a positive rotation angle, imrotate rotates the image counterclockwise; if you specify a negative rotation angle, imrotate rotates the image clockwise. To rotate the image 35° counterclockwise using bilinear interpolation >>J = imrotate(I,35,'bilinear'); >>imshow(J) imrotate uses nearest-neighbor interpolation by default to determine the value of pixels in the output image, but you can specify other interpolation methods. To perfrom Translation to (40,40) from origin >> xform = [ 1 0 0 0 1 0 40 40 1 ] xform = 1 0 0 0 1 0 40 40 1 >> tform_translate = maketform('affine',xform); >> k= imtransform(I, tform_translate); >>[cb_trans xdata ydata]= imtransform(I, tform_translate); >> cb_trans2 = imtransform(I, tform_translate,... 'XData', [1 (size(I,2)+ xform(3,1))],... 'YData', [1 (size(I,1)+ xform(3,2))]); >> imshow(cb_trans2) Image Arithmetic
  • 8. Creating the negative of an image using imcomplement >>J=imcomplement(I) >> imshow(J) Imadd Add two images or add constant to image c=imresize(a,[300,300]) d=imresize(b,[300,300]) imshow(c) K=imadd(c,d) imshow(K) OUTPUT:
  • 9. imsubtract Subtract one image from another or subtract constant from image K=imsubtract(c,d) imshow(K) imdivide Divides two images or divides image by constant K=imdivide(c,d) imshow(K) immultiply Multiply two images or multiply image by constant K=immultiply(c,d) imshow(K) imabsdiff absolute difference of two images K=immultiply(c,d) imshow(K) To display an image in the background and another image on foreground. >> b = imresize(a,[300 300]); >> d = imresize(c,[300 300]); >> e = imlincomb(.5,b,.5,d);
  • 10. >> imshow(b) >> imshow(d) >> imshow(e) Removing Noise By Adaptive Filtering I = rgb2gray(a); >> imshow(I)
  • 11. >> J = imnoise(I,'gaussian',0,0.025); >> imshow(I) >> imshow(J) Output after applying Gaussian noise. Remove the noise, using the wiener2 function. K = wiener2(J,[5 5]); imshow(K) Removing noise using Median filter K=medfilt2(J,[3 3]) imshow(K)
  • 12. Removing noise using Gaussian filter 1. Add Salt and pepper noise J=imnoise(I,'salt & pepper',.02) imshow(J) 2. Creating Gaussian filter h = fspecial(type,parameters) creates a two- dimensional filter h of the specified type. fspecial returns h as a correlation kernel, which is the appropriate form to use with imfilter. type is a string having one of these values. h=fspecial('gaussian',[3 3],.7) h = 0.0113 0.0838 0.0113 0.0838 0.6193 0.0838 0.0113 0.0838 0.0113 3. Filter noisy image with Gaussian filter L=imfilter(J,h) imshow(L) Removing noise using 2 dimensionl order-statistics filter L=ordfilt2(J,5,ones(3,3)) imshow(L)
  • 13.
  • 14. -1 -0.5 0 0.5 1 -1 0 1 0 0.5 1 Fx F y Magnitude Removing noise using Averaging filter 1.Create kernel for average filter with low pass characterisitics k=[ 1 1 1 1 1 1 1 1 1]/9 k = 0.1111 0.1111 0.1111 0.1111 0.1111 0.1111 0.1111 0.1111 0.1111 2. Plot frequency response characteristics freqz2(k) 3.Apply averaging filter Filter M=imfilter(J,k) imshow(M)
  • 15. Find the edges of an image using the Prewitt , Sobel and Canny methods. BW1 = edge(I,'prewitt'); BW2 = edge(I,'canny'); Imshow(BW2) BW2 = edge(I,'sobel'); Imshow(BW2) Visit my blog: enthusiaststudent.blogspot.in