SlideShare a Scribd company logo
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Fundamentals
of
Matlab
Improve this with www.csie.ntnu.edu.tw/~violet/IP93/Chapter01.ppt
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Image Formats
http://en.wikipedia.org/wiki/Image_formats
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
More Image Formats
• PPM(Portable Pixelmap) • PGM(Portable Graymap)
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Displaying Images
f = imread(‘rose.tif’);
imshow(f);
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Try this:
>> f = imread(“Image_Name.extension”);
>> imshow(f)
>> impixelinfo
>> size(f)
ans =
1024 1024
>> [M,N] = size(f);
>> whos f
Name Size Bytes Class Attributes
r 1024x1024 1048576 uint8
Displaying Images Info.
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
imfinfo (bubbles.jpg)
ans =
Filename: 'bubble.jpg'
FileModDate: '14-Jan-2008 17:08:08'
FileSize: 7904
Format: 'jpg'
FormatVersion: ‘ '
Width: 720
Height: 688
BitDepth: 8
ColorType: 'grayscale'
FormatSignature: ‘ '
NumberOfSamples: 1
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {}
Displaying Images Info.
Try this
>> K imfinfo('bubbles.jpg');
>> K.FileSize
ans =
7904
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Syntax:
variable=imread(“Image_name.extension’);
Imwrite(variable,”Name.ext”);
Try This:
Step1:Read
>> b = imread(‘bubbles.tif’);
Step2:Write
>> imwrite(b,'bubbles.png');
>> imwrite(b,'bubbles.jpg');
>> imwrite(b,'bubbles', 'jpg');
Writing Images
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Data Classes
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Converting Between
Data Classes
Example: Suppose
A is an array of class uint8
C is an array of class double
B = double(A)
D = uint8(C)
Syntax: B = data_class_name(A)
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Converting Between
Image Classes & Types
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Converting Between
Image Classes & Types
Example: Consider the following 2 X 2 image f of class double:
Try This:
>> f = [-0.5 0.5; 0.75 1.5]
f =
-0.5 0.5
0.75 1.5
>> g = im2uint8(f)
g =
0 128
191 255
>> h = uint8([25 50; 128 200]);
>> g = im2double(h);
g =
0.0980 0.1961
0.4706 0.7843
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Array Indexing
Example:
>> v = [1 3 5 7 9]
v =
1 3 5 7 9
>> v(2) “2nd
index”
ans =
3
>> v(2:4) “2nd
to 4th
index”
ans =
3 5 7
Guess the output of: v(3:end) v(1:2:end) v(end:-2:1)
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Matrix Indexing
Example:
>> A = [1 2 3; 4 5 6; 7 8 9]
A =
1 2 3
4 5 6
7 8 9
>> A(2, 3)
ans =
6
>> R2 = A(2, :)
R2 =
4 5 6
Guess the output of: A(1:2, 1:3) A(end, end-2) A(:, 3)
Try this:
C3 = A(:, 3)
C3 =
3
6
9
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Standard Arrays
>> A = 5*ones(3, 3)
A =
5 5 5
5 5 5
5 5 5
>> magic(3)
ans =
8 1 6
3 5 7
4 9 2
>> B = rand(2, 4)
B =
0.2311 0.4860 0.7621 0.0185
0.6068 0.8913 0.4565 0.8214
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Operators
Example:
f =
1 2
3 4
>> v = f(:) “All column in to one column”
v =
1
3
2
4
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Arithmetic Operations
Example:
>> imshow(imcomplement(f))
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Relational Operators
Example:
>> A = [1 2; 3 4]
A =
1 2
3 4
>> B = [0 2; 3 5;]
B =
0 2
3 5
>> A>=B
ans =
1 1
1 0
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Logical Operators and Functions
www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins
Digital Image Processing Using MATLAB®
Flow Control Statements
Ad

Recommended

WF ED 540, Class Meeting 2 - Identifying & converting data types, 2016
WF ED 540, Class Meeting 2 - Identifying & converting data types, 2016
Penn State University
 
Efficient Immutable Data Structures (Okasaki for Dummies)
Efficient Immutable Data Structures (Okasaki for Dummies)
Tom Faulhaber
 
A Short Introduction to Generative Adversarial Networks
A Short Introduction to Generative Adversarial Networks
Jong Wook Kim
 
8.2 notes
8.2 notes
Mrs. Hedrick's Class
 
Tukuba r#7
Tukuba r#7
Yuki Tani
 
Basic image processing
Basic image processing
Jay Thakkar
 
Information visualization: information dashboards
Information visualization: information dashboards
Katrien Verbert
 
Basics of Image Processing using MATLAB
Basics of Image Processing using MATLAB
vkn13
 
基礎影像處理
基礎影像處理
weihan cheng
 
Introduction of image processing
Introduction of image processing
Avani Shah
 
TESTIMAGES - a large-scale archive for testing visual devices and basic image...
TESTIMAGES - a large-scale archive for testing visual devices and basic image...
Tecnick.com LTD
 
Introduction to Digital Image Processing Using MATLAB
Introduction to Digital Image Processing Using MATLAB
Ray Phan
 
Image proceesing with matlab
Image proceesing with matlab
Ashutosh Shahi
 
Image Processing Basics
Image Processing Basics
Nam Le
 
Automatic speech recognition
Automatic speech recognition
Richie
 
Face recognition using neural network
Face recognition using neural network
Indira Nayak
 
Image processing ppt
Image processing ppt
Raviteja Chowdary Adusumalli
 
Speech recognition
Speech recognition
Charu Joshi
 
Voice Recognition
Voice Recognition
Amrita More
 
Digital Image Processing
Digital Image Processing
Sahil Biswas
 
lec1_matlab.ppt basic all operations matlab operations
lec1_matlab.ppt basic all operations matlab operations
samraj sundarraj
 
lec1b.ppt
lec1b.ppt
RithikRaj25
 
Digital Image Processing Using Matlab 2nd Edition Rafael C Gonzalez
Digital Image Processing Using Matlab 2nd Edition Rafael C Gonzalez
rusetidawnel
 
Understanding Digital Image Processing Vipin Tyagi
Understanding Digital Image Processing Vipin Tyagi
matlonesser
 
Digital Image Processing - MATLAB Notes - Akshansh
Digital Image Processing - MATLAB Notes - Akshansh
Akshansh Chaudhary
 
Intro matlab
Intro matlab
danie_sileshi
 
Image Processing Using MATLAB
Image Processing Using MATLAB
Amarjeetsingh Thakur
 
Image processing in MATLAB
Image processing in MATLAB
Amarjeetsingh Thakur
 
Digital Image Processing
Digital Image Processing
Ankur Nanda
 
Introductory Digital Image Processing using Matlab, IIT Roorkee
Introductory Digital Image Processing using Matlab, IIT Roorkee
Vinayak Sahai
 

More Related Content

Viewers also liked (12)

基礎影像處理
基礎影像處理
weihan cheng
 
Introduction of image processing
Introduction of image processing
Avani Shah
 
TESTIMAGES - a large-scale archive for testing visual devices and basic image...
TESTIMAGES - a large-scale archive for testing visual devices and basic image...
Tecnick.com LTD
 
Introduction to Digital Image Processing Using MATLAB
Introduction to Digital Image Processing Using MATLAB
Ray Phan
 
Image proceesing with matlab
Image proceesing with matlab
Ashutosh Shahi
 
Image Processing Basics
Image Processing Basics
Nam Le
 
Automatic speech recognition
Automatic speech recognition
Richie
 
Face recognition using neural network
Face recognition using neural network
Indira Nayak
 
Image processing ppt
Image processing ppt
Raviteja Chowdary Adusumalli
 
Speech recognition
Speech recognition
Charu Joshi
 
Voice Recognition
Voice Recognition
Amrita More
 
Digital Image Processing
Digital Image Processing
Sahil Biswas
 
基礎影像處理
基礎影像處理
weihan cheng
 
Introduction of image processing
Introduction of image processing
Avani Shah
 
TESTIMAGES - a large-scale archive for testing visual devices and basic image...
TESTIMAGES - a large-scale archive for testing visual devices and basic image...
Tecnick.com LTD
 
Introduction to Digital Image Processing Using MATLAB
Introduction to Digital Image Processing Using MATLAB
Ray Phan
 
Image proceesing with matlab
Image proceesing with matlab
Ashutosh Shahi
 
Image Processing Basics
Image Processing Basics
Nam Le
 
Automatic speech recognition
Automatic speech recognition
Richie
 
Face recognition using neural network
Face recognition using neural network
Indira Nayak
 
Speech recognition
Speech recognition
Charu Joshi
 
Voice Recognition
Voice Recognition
Amrita More
 
Digital Image Processing
Digital Image Processing
Sahil Biswas
 

Similar to Digital image processing using matlab (fundamentals) (20)

lec1_matlab.ppt basic all operations matlab operations
lec1_matlab.ppt basic all operations matlab operations
samraj sundarraj
 
lec1b.ppt
lec1b.ppt
RithikRaj25
 
Digital Image Processing Using Matlab 2nd Edition Rafael C Gonzalez
Digital Image Processing Using Matlab 2nd Edition Rafael C Gonzalez
rusetidawnel
 
Understanding Digital Image Processing Vipin Tyagi
Understanding Digital Image Processing Vipin Tyagi
matlonesser
 
Digital Image Processing - MATLAB Notes - Akshansh
Digital Image Processing - MATLAB Notes - Akshansh
Akshansh Chaudhary
 
Intro matlab
Intro matlab
danie_sileshi
 
Image Processing Using MATLAB
Image Processing Using MATLAB
Amarjeetsingh Thakur
 
Image processing in MATLAB
Image processing in MATLAB
Amarjeetsingh Thakur
 
Digital Image Processing
Digital Image Processing
Ankur Nanda
 
Introductory Digital Image Processing using Matlab, IIT Roorkee
Introductory Digital Image Processing using Matlab, IIT Roorkee
Vinayak Sahai
 
Lecture1_computer vision-2023.pdf
Lecture1_computer vision-2023.pdf
ssuserff72e4
 
MATLAB & Image Processing
MATLAB & Image Processing
Techbuddy Consulting Pvt. Ltd.
 
Image processing tool box.pptx
Image processing tool box.pptx
AvinashJain66
 
tutorial1.pdf
tutorial1.pdf
ShwetaPandey248972
 
Image processing on matlab presentation
Image processing on matlab presentation
Naatchammai Ramanathan
 
Image processing-on-matlab-presentation-1
Image processing-on-matlab-presentation-1
Naatchammai Ramanathan
 
Gettingstartedwithmatlabimageprocessing
Gettingstartedwithmatlabimageprocessing
tvanii
 
Fundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLAB
Ali Ghanbarzadeh
 
MATLAB - PRESENTATION for PG studentspdf
MATLAB - PRESENTATION for PG studentspdf
Karthik537368
 
image processing engimage processing eng
image processing engimage processing eng
hxusmze
 
lec1_matlab.ppt basic all operations matlab operations
lec1_matlab.ppt basic all operations matlab operations
samraj sundarraj
 
Digital Image Processing Using Matlab 2nd Edition Rafael C Gonzalez
Digital Image Processing Using Matlab 2nd Edition Rafael C Gonzalez
rusetidawnel
 
Understanding Digital Image Processing Vipin Tyagi
Understanding Digital Image Processing Vipin Tyagi
matlonesser
 
Digital Image Processing - MATLAB Notes - Akshansh
Digital Image Processing - MATLAB Notes - Akshansh
Akshansh Chaudhary
 
Digital Image Processing
Digital Image Processing
Ankur Nanda
 
Introductory Digital Image Processing using Matlab, IIT Roorkee
Introductory Digital Image Processing using Matlab, IIT Roorkee
Vinayak Sahai
 
Lecture1_computer vision-2023.pdf
Lecture1_computer vision-2023.pdf
ssuserff72e4
 
Image processing tool box.pptx
Image processing tool box.pptx
AvinashJain66
 
Image processing on matlab presentation
Image processing on matlab presentation
Naatchammai Ramanathan
 
Image processing-on-matlab-presentation-1
Image processing-on-matlab-presentation-1
Naatchammai Ramanathan
 
Gettingstartedwithmatlabimageprocessing
Gettingstartedwithmatlabimageprocessing
tvanii
 
Fundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLAB
Ali Ghanbarzadeh
 
MATLAB - PRESENTATION for PG studentspdf
MATLAB - PRESENTATION for PG studentspdf
Karthik537368
 
image processing engimage processing eng
image processing engimage processing eng
hxusmze
 
Ad

Recently uploaded (20)

"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
Safe Software
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
The Future of Product Management in AI ERA.pdf
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
Safe Software
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
The Future of Product Management in AI ERA.pdf
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
Ad

Digital image processing using matlab (fundamentals)

  • 1. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Fundamentals of Matlab Improve this with www.csie.ntnu.edu.tw/~violet/IP93/Chapter01.ppt
  • 2. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB®
  • 3. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Image Formats http://en.wikipedia.org/wiki/Image_formats
  • 4. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® More Image Formats • PPM(Portable Pixelmap) • PGM(Portable Graymap)
  • 5. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Displaying Images f = imread(‘rose.tif’); imshow(f);
  • 6. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Try this: >> f = imread(“Image_Name.extension”); >> imshow(f) >> impixelinfo >> size(f) ans = 1024 1024 >> [M,N] = size(f); >> whos f Name Size Bytes Class Attributes r 1024x1024 1048576 uint8 Displaying Images Info.
  • 7. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® imfinfo (bubbles.jpg) ans = Filename: 'bubble.jpg' FileModDate: '14-Jan-2008 17:08:08' FileSize: 7904 Format: 'jpg' FormatVersion: ‘ ' Width: 720 Height: 688 BitDepth: 8 ColorType: 'grayscale' FormatSignature: ‘ ' NumberOfSamples: 1 CodingMethod: 'Huffman' CodingProcess: 'Sequential' Comment: {} Displaying Images Info. Try this >> K imfinfo('bubbles.jpg'); >> K.FileSize ans = 7904
  • 8. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Syntax: variable=imread(“Image_name.extension’); Imwrite(variable,”Name.ext”); Try This: Step1:Read >> b = imread(‘bubbles.tif’); Step2:Write >> imwrite(b,'bubbles.png'); >> imwrite(b,'bubbles.jpg'); >> imwrite(b,'bubbles', 'jpg'); Writing Images
  • 9. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Data Classes
  • 10. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Converting Between Data Classes Example: Suppose A is an array of class uint8 C is an array of class double B = double(A) D = uint8(C) Syntax: B = data_class_name(A)
  • 11. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Converting Between Image Classes & Types
  • 12. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Converting Between Image Classes & Types Example: Consider the following 2 X 2 image f of class double: Try This: >> f = [-0.5 0.5; 0.75 1.5] f = -0.5 0.5 0.75 1.5 >> g = im2uint8(f) g = 0 128 191 255 >> h = uint8([25 50; 128 200]); >> g = im2double(h); g = 0.0980 0.1961 0.4706 0.7843
  • 13. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Array Indexing Example: >> v = [1 3 5 7 9] v = 1 3 5 7 9 >> v(2) “2nd index” ans = 3 >> v(2:4) “2nd to 4th index” ans = 3 5 7 Guess the output of: v(3:end) v(1:2:end) v(end:-2:1)
  • 14. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Matrix Indexing Example: >> A = [1 2 3; 4 5 6; 7 8 9] A = 1 2 3 4 5 6 7 8 9 >> A(2, 3) ans = 6 >> R2 = A(2, :) R2 = 4 5 6 Guess the output of: A(1:2, 1:3) A(end, end-2) A(:, 3) Try this: C3 = A(:, 3) C3 = 3 6 9
  • 15. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Standard Arrays >> A = 5*ones(3, 3) A = 5 5 5 5 5 5 5 5 5 >> magic(3) ans = 8 1 6 3 5 7 4 9 2 >> B = rand(2, 4) B = 0.2311 0.4860 0.7621 0.0185 0.6068 0.8913 0.4565 0.8214
  • 16. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB®
  • 17. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Operators Example: f = 1 2 3 4 >> v = f(:) “All column in to one column” v = 1 3 2 4
  • 18. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Arithmetic Operations Example: >> imshow(imcomplement(f))
  • 19. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Relational Operators Example: >> A = [1 2; 3 4] A = 1 2 3 4 >> B = [0 2; 3 5;] B = 0 2 3 5 >> A>=B ans = 1 1 1 0
  • 20. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Logical Operators and Functions
  • 21. www.imageprocessingbook.com© 2004 R. C. Gonzalez, R. E. Woods, and S. L. Eddins Digital Image Processing Using MATLAB® Flow Control Statements