SlideShare a Scribd company logo
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)
Simple Matlab tutorial using matlab inbuilt commands
-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
Ad

Recommended

PPT
Dip Morphological
Mubbasher Khaliq
 
PPTX
Digital Image Processing (Lab 09 and 10)
Moe Moe Myint
 
PPTX
Digital Image Processing (Lab 07)
Moe Moe Myint
 
PPTX
Digital Image Processing (Lab 06)
Moe Moe Myint
 
PPTX
Digital Image Processing (Lab 05)
Moe Moe Myint
 
PPT
Dital Image Processing (Lab 2+3+4)
Moe Moe Myint
 
PPSX
point processing
Rumah Belajar
 
PPTX
Chapter 9 morphological image processing
Ahmed Daoud
 
PPT
Morphological Image Processing
kumari36
 
PDF
Digital image processing using matlab: basic transformations, filters and ope...
thanh nguyen
 
PPTX
Hit and-miss transform
Krish Everglades
 
DOCX
Image Processing using Matlab ( using a built in Matlab function(Histogram eq...
Majd Khaleel
 
DOCX
Zooming an image in visual basic
Hotland Sitorus
 
PDF
A Comparative Study of Histogram Equalization Based Image Enhancement Techniq...
Shahbaz Alam
 
PPTX
Erosion and dilation
Akhil .B
 
PPT
morphological tecnquies in image processing
soma saikiran
 
PPT
Matlab
Aman kazmi
 
DOCX
Resize image vb.net
Hotland Sitorus
 
PPT
Image processing using matlab
SangeethaSasi1
 
PDF
Math behind the kernels
Revanth Kumar
 
PDF
Week 6
AliHassan1274
 
PPTX
Image enhancement using alpha rooting based hybrid technique
Rahul Yadav
 
PPT
Image enhancement
shabanam tamboli
 
PPTX
Lect 02 second portion
Moe Moe Myint
 
PPT
Image Texture Analysis
lalitxp
 
PPTX
DIP-Enhancement-Spatial.pptx
NidhiSharma764884
 
PPTX
CLASS on the and some what sore free 5.pptx
helloworldw793
 

More Related Content

What's hot (20)

PPT
Morphological Image Processing
kumari36
 
PDF
Digital image processing using matlab: basic transformations, filters and ope...
thanh nguyen
 
PPTX
Hit and-miss transform
Krish Everglades
 
DOCX
Image Processing using Matlab ( using a built in Matlab function(Histogram eq...
Majd Khaleel
 
DOCX
Zooming an image in visual basic
Hotland Sitorus
 
PDF
A Comparative Study of Histogram Equalization Based Image Enhancement Techniq...
Shahbaz Alam
 
PPTX
Erosion and dilation
Akhil .B
 
PPT
morphological tecnquies in image processing
soma saikiran
 
PPT
Matlab
Aman kazmi
 
DOCX
Resize image vb.net
Hotland Sitorus
 
PPT
Image processing using matlab
SangeethaSasi1
 
PDF
Math behind the kernels
Revanth Kumar
 
PDF
Week 6
AliHassan1274
 
PPTX
Image enhancement using alpha rooting based hybrid technique
Rahul Yadav
 
PPT
Image enhancement
shabanam tamboli
 
PPTX
Lect 02 second portion
Moe Moe Myint
 
PPT
Image Texture Analysis
lalitxp
 
Morphological Image Processing
kumari36
 
Digital image processing using matlab: basic transformations, filters and ope...
thanh nguyen
 
Hit and-miss transform
Krish Everglades
 
Image Processing using Matlab ( using a built in Matlab function(Histogram eq...
Majd Khaleel
 
Zooming an image in visual basic
Hotland Sitorus
 
A Comparative Study of Histogram Equalization Based Image Enhancement Techniq...
Shahbaz Alam
 
Erosion and dilation
Akhil .B
 
morphological tecnquies in image processing
soma saikiran
 
Matlab
Aman kazmi
 
Resize image vb.net
Hotland Sitorus
 
Image processing using matlab
SangeethaSasi1
 
Math behind the kernels
Revanth Kumar
 
Image enhancement using alpha rooting based hybrid technique
Rahul Yadav
 
Image enhancement
shabanam tamboli
 
Lect 02 second portion
Moe Moe Myint
 
Image Texture Analysis
lalitxp
 

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

PPTX
DIP-Enhancement-Spatial.pptx
NidhiSharma764884
 
PPTX
CLASS on the and some what sore free 5.pptx
helloworldw793
 
PPT
Dip syntax 4
Shajun Nisha
 
PPTX
HTML 5_Canvas
Vishakha Vaidya
 
DOCX
matlab.docx
AraniNavaratnarajah2
 
PPTX
Image enhancement techniques
Saideep
 
PPTX
Image enhancement techniques
Arshad khan
 
PDF
Image processing basics using matlab
Ankur Tyagi
 
PDF
Dip 2
moramvenkat
 
PPTX
imageenhancementtechniques-140316011049-phpapp01 (1).pptx
salutiontechnology
 
PDF
CE344L-200365-Lab5.pdf
UmarMustafa13
 
PDF
Computer vision image enhancement ppt prajwal deshmukh
prajdesh26
 
PPTX
image enhancement.pptx
Arid Agriculture University, Rawalpindi
 
PPT
Image Processing using Matlab . Useful for beginners to learn Image Processing
Ashok Kumar
 
PPT
Key stages of digital image processing.ppt
vasudeva873639
 
PDF
Can someone please explain what the code below is doing and comment on.pdf
kuldeepkumarapgsi
 
PPTX
Image Processing Using MATLAB
Amarjeetsingh Thakur
 
PPTX
Image processing in MATLAB
Amarjeetsingh Thakur
 
PPT
Introduction To Advanced Image Processing
Suren Kumar
 
PDF
Dip 3
moramvenkat
 
DIP-Enhancement-Spatial.pptx
NidhiSharma764884
 
CLASS on the and some what sore free 5.pptx
helloworldw793
 
Dip syntax 4
Shajun Nisha
 
HTML 5_Canvas
Vishakha Vaidya
 
Image enhancement techniques
Saideep
 
Image enhancement techniques
Arshad khan
 
Image processing basics using matlab
Ankur Tyagi
 
imageenhancementtechniques-140316011049-phpapp01 (1).pptx
salutiontechnology
 
CE344L-200365-Lab5.pdf
UmarMustafa13
 
Computer vision image enhancement ppt prajwal deshmukh
prajdesh26
 
Image Processing using Matlab . Useful for beginners to learn Image Processing
Ashok Kumar
 
Key stages of digital image processing.ppt
vasudeva873639
 
Can someone please explain what the code below is doing and comment on.pdf
kuldeepkumarapgsi
 
Image Processing Using MATLAB
Amarjeetsingh Thakur
 
Image processing in MATLAB
Amarjeetsingh Thakur
 
Introduction To Advanced Image Processing
Suren Kumar
 
Ad

More from Lakshmi Sarvani Videla (20)

DOCX
Data Science Using Python
Lakshmi Sarvani Videla
 
DOCX
Programs on multithreading
Lakshmi Sarvani Videla
 
PPT
Menu Driven programs in Java
Lakshmi Sarvani Videla
 
DOCX
Recursion in C
Lakshmi Sarvani Videla
 
DOCX
Simple questions on structures concept
Lakshmi Sarvani Videla
 
PPTX
Errors incompetitiveprogramming
Lakshmi Sarvani Videla
 
DOCX
Relational Operators in C
Lakshmi Sarvani Videla
 
PPTX
Recursive functions in C
Lakshmi Sarvani Videla
 
PPTX
Function Pointer in C
Lakshmi Sarvani Videla
 
PPTX
Functions
Lakshmi Sarvani Videla
 
DOCX
Java sessionnotes
Lakshmi Sarvani Videla
 
DOCX
Singlelinked list
Lakshmi Sarvani Videla
 
PPTX
Functions in python3
Lakshmi Sarvani Videla
 
PPTX
Dictionary
Lakshmi Sarvani Videla
 
DOCX
DataStructures notes
Lakshmi Sarvani Videla
 
DOCX
Solutionsfor co2 C Programs for data structures
Lakshmi Sarvani Videla
 
Data Science Using Python
Lakshmi Sarvani Videla
 
Programs on multithreading
Lakshmi Sarvani Videla
 
Menu Driven programs in Java
Lakshmi Sarvani Videla
 
Recursion in C
Lakshmi Sarvani Videla
 
Simple questions on structures concept
Lakshmi Sarvani Videla
 
Errors incompetitiveprogramming
Lakshmi Sarvani Videla
 
Relational Operators in C
Lakshmi Sarvani Videla
 
Recursive functions in C
Lakshmi Sarvani Videla
 
Function Pointer in C
Lakshmi Sarvani Videla
 
Java sessionnotes
Lakshmi Sarvani Videla
 
Singlelinked list
Lakshmi Sarvani Videla
 
Functions in python3
Lakshmi Sarvani Videla
 
DataStructures notes
Lakshmi Sarvani Videla
 
Solutionsfor co2 C Programs for data structures
Lakshmi Sarvani Videla
 
Ad

Recently uploaded (20)

PDF
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 
PDF
The Growing Value and Application of FME & GenAI
Safe Software
 
PDF
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
PDF
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
PDF
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
PDF
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
PPTX
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
PPTX
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
PPTX
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
PDF
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
PDF
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
PDF
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
PDF
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
All Things Open
 
PDF
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
PDF
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
PPTX
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
PDF
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
PDF
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
PPTX
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
PDF
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
 
The Growing Value and Application of FME & GenAI
Safe Software
 
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
All Things Open
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Python Conference Singapore - 19 Jun 2025
ninefyi
 

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)
  • 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