SlideShare ist ein Scribd-Unternehmen logo
1 von 42
MATLAB
Image Processing Toolbox
Introduction
 Collection of functions (MATLAB
files) that supports a wide range of image
processing operations
 Documentation

 www.mathworks.com
Read an Image
 Read in an image
 Validates the graphic format
(bmp, hdf, jpeg, pcx, png, tiff, xwd)

 Store it in an array

clear, close all
I = imread(‘pout.tif`);
[X, map] = imread(‘pout.tif’);
Display an Image
imshow(I)
Check the Image in Memory
 < Name, Size, Bytes, Class >
whos
Name
Size
Bytes Class
ans 291x240
69840 uint8 array
Grand total is 69840 elements using 69840 bytes

uint8
uint16
double

[0, 255]
[0, 65535]
[0, 1]
Histogram Equalization
 Histogram: distribution of intensities
figure, imhist(I)

 Equalize Image (contrast)
I2 = histeq(I);

figure, imshow(I2)
figure, imhist(I2)
Histogram Equalization
(cont.)
Histogram Equalization
(cont.)
Write the Image
 Validates the extension
 Writes the image to disk
imwrite(I2, ’pout2.png’);
imwrite(I2, ‘pout2.png’, ‘BitDepth’, 4);
Morphological Opening
 Remove objects that cannot completely
contain a structuring element
 Estimate background illumination
clear, close all
I = imread(‘rice.tif’);
imshow(I)
background = imopen(I, strel(‘disk’, 15));
imshow(background)
Morphological Opening
(cont.)
Subtract Images
 Create a more uniform background
I2 = imsubtract(I, background);
figure, imshow(I2)
Adjust the Image Contrast
 stretchlim computes [low hight] to be
mapped into [bottom top]
I3 = imadjust(I2, stretchlim(I2), [0 1]);
figure, imshow(I3)
Apply Thresholding
to the Image
 Create a binary thresholded image
1.

2.

Compute a threshold to convert the intensity
image to binary
Perform thresholding creating a logical matrix
(binary image)
level = graythresh(I3);
bw = im2bw(I3, level);
figure, imshow(bw)
Apply Thresholding
to the Image (cont.)
Labeling Connected
Components
 Determine the number of objects in the
image
 Accuracy

(size of objects, approximated background,
connectivity parameter, touching objects)
[labeled, numObjects] = bwlabel(bw, 4);
numObjects
{= 80}
max(labeled(:))
Select and Display
Pixels in a Region
 Interactive selection
grain = imcrop(labeled)

 Colormap creation function
RGB_label = label2rgb(labeled,
@spring, ‘c’, ‘shuffle’);
imshow(RGB_label);
rect = [15 25 10 10];
roi = imcrop(labeled, rect)
Object Properties
 Measure object or region properties

graindata = regionprops(labeled, ‘basic’)
graindata(51).Area
{296}
graindata(51).BoundingBox
{142.5 89.5 24.0 26.0}
graindata(51).Centroid
{155.3953 102.1791}

 Create a vector which holds just one property for
each object
allgrains = [graindata.Area];
whos
Statistical Properties
of Objects
max(allgrains)

{ 695 }

 Return the component label of a grain size
biggrain = find(allgrains == 695) { 68 }

 Mean grain size
mean(allgrains)

 Histogram (#bins)
hist(allgrains, 20)

{ 249 }
Statistical Properties
of Objects (cont.)
Storage Classes
 double (64-bit), uint8 (8-bit), and uint16
(16-bit)
 Converting (rescale or offset)
double
im2double (automatic rescale and offsetting)
RGB2 = im2uint8(RGB1);
im2uint16
imapprox (reduce number of colors: indexed images)
Image Types
 Index

 Data

matrix (uint8, uint16, double)
 Colormap matrix (m x 3 array of double [0 1])

 Intensity (black = 0, white = ∞)
 Binary (0, 1)

B = logical(uint8(round(A))); (logical flag on)
B = +A; (logical flag off)

 RGB (m x n x 3 of truecolor)
Converting Image Types






dither
gray2ind
grayslice
im2bw
ind2gray






ind2rgb
mat2gray
rgb2gray
rgb2ind
Multiframe Image Arrays
 Same size, #planes, colormap
 Store separate images into one multiframe
array
A = cat(4, A1, A2, A3, A4, A5)

 Extract frames from a multiframe array
FRM3 = MULTI(:, :, :, 3)

 Display a frame

imshow(MULTI(:, :, :, 7))
Image Arithmetic





imabsdiff
imadd
imcomplement
imdivide

 imlincomb
 immultiply
 imsubtract
Adding Images
I = imread(‘rice.tif’);
J = imread(‘cameraman.tif’);
K = imadd(I, J);
imshow(K)

 Brighten an image results saturation
RGB = imread(‘flowers.tif’);
RGB2 = imadd(RGB, 50);
subplot(1, 2, 1); imshow(RGB);
subplot(1, 2, 2); imshow(RGB2);
Adding Images (cont.)
Adding Images (cont.)
Subtracting Images
 Background of a scene

rice = imread(‘rice.tif’);
background = imopen(rice, strel(‘disk’, 15));
rice2 = imsubtract(rice, background);
imshow(rice), figure, imshow(rice2);

 Negative values
imabsdiff
Subtracting Images (cont.)
Multiplying Images
 Scaling: multiply by a constant
 (brightens

>1, darkens <1)

 Preserves relative contrast
I = imread(‘moon.tif’);
J = immultiply(I, 1.2);
imshow(I);
figure, imshow(J)
Multiplying Images (cont.)
Dividing Images (Ratioing)
I = imread(‘rice.tif’);
background = imopen(I, strel(‘disk’, 15));
Ip = imdivide(I, background);
imshow(Ip, [])

 Linear combination only truncates the final
result
K = imlincomb(.5, I, .5, I2);
Dividing Images (cont.)
Coordinate Systems
 Pixel Coordinates




Discrete unit (integer)
(r, c)
 = (1, 1)
123

 Spatial Coordinates




Continuous unit
(x, y)
= (0.5, 0.5)
Non-default Spatial
Coordinate System
A = magic(5);
x = [19.5 23.5];
y = [8.0 12.0];
image(A, ‘xData’, x, ‘yData’, y), axis image,
colormap(jet(25))
Spatial Transformations
 Map pixel locations in an input image to
new locations in an output image




Resizing
Rotation
Cropping
Resizing Images
 Change the size of an image
I = imread(‘ic.tif’);
J = imresize(I, 1.25);
K = imresize(I, [100 150]);
figure, imshow(J)
figure, imshow(K)
Resizing Images (cont.)
Rotating Images
 Rotate an image by an angle in degrees
I = imread(‘ic.tif’);
J = imrotate(I, 35, ‘bilinear’);
imshow(I)
figure, imshow(J)
Rotating Images (cont.)
Cropping Images
 Extract a rectangular portion of an image
imshow ic.tif
I = imcrop;

Weitere ähnliche Inhalte

Was ist angesagt?

Image proceesing with matlab
Image proceesing with matlabImage proceesing with matlab
Image proceesing with matlab
Ashutosh Shahi
 
Basics of Image Processing using MATLAB
Basics of Image Processing using MATLABBasics of Image Processing using MATLAB
Basics of Image Processing using MATLAB
vkn13
 

Was ist angesagt? (20)

Introductory Digital Image Processing using Matlab, IIT Roorkee
Introductory Digital Image Processing using Matlab, IIT RoorkeeIntroductory Digital Image Processing using Matlab, IIT Roorkee
Introductory Digital Image Processing using Matlab, IIT Roorkee
 
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)
 
Digital Image Processing (Lab 07)
Digital Image Processing (Lab 07)Digital Image Processing (Lab 07)
Digital Image Processing (Lab 07)
 
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 proceesing with matlab
Image proceesing with matlabImage proceesing with matlab
Image proceesing with matlab
 
Basics of Image Processing using MATLAB
Basics of Image Processing using MATLABBasics of Image Processing using MATLAB
Basics of Image Processing using MATLAB
 
Image processing on matlab presentation
Image processing on matlab presentationImage processing on matlab presentation
Image processing on matlab presentation
 
Digital Image Processing (Lab 05)
Digital Image Processing (Lab 05)Digital Image Processing (Lab 05)
Digital Image Processing (Lab 05)
 
Image processing
Image processingImage processing
Image processing
 
Fundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLABFundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLAB
 
Image processing using matlab
Image processing using matlab Image processing using matlab
Image processing using matlab
 
Digital Image Processing (Lab 06)
Digital Image Processing (Lab 06)Digital Image Processing (Lab 06)
Digital Image Processing (Lab 06)
 
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...
 
Images in matlab
Images in matlabImages in matlab
Images in matlab
 
Image processing for robotics
Image processing for roboticsImage processing for robotics
Image processing for robotics
 
Digital Image Processing (Lab 08)
Digital Image Processing (Lab 08)Digital Image Processing (Lab 08)
Digital Image Processing (Lab 08)
 
Working with images in matlab graphics
Working with images in matlab graphicsWorking with images in matlab graphics
Working with images in matlab graphics
 
1.arithmetic & logical operations
1.arithmetic & logical operations1.arithmetic & logical operations
1.arithmetic & logical operations
 
Introduction in Image Processing Matlab Toolbox
Introduction in Image Processing Matlab ToolboxIntroduction in Image Processing Matlab Toolbox
Introduction in Image Processing Matlab Toolbox
 
Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlab
 

Andere mochten auch

Open GL 09 scan conversion
Open GL 09 scan conversionOpen GL 09 scan conversion
Open GL 09 scan conversion
Roziq Bahtiar
 
6. pemrograman pointer
6. pemrograman pointer6. pemrograman pointer
6. pemrograman pointer
Roziq Bahtiar
 
Pertemuan10 spywareadwaredanspam
Pertemuan10 spywareadwaredanspamPertemuan10 spywareadwaredanspam
Pertemuan10 spywareadwaredanspam
Roziq Bahtiar
 
7. pemrograman struktur
7. pemrograman struktur7. pemrograman struktur
7. pemrograman struktur
Roziq Bahtiar
 
Open GL T0074 56 sm1
Open GL T0074 56 sm1Open GL T0074 56 sm1
Open GL T0074 56 sm1
Roziq Bahtiar
 
PPT Image Analysis(IRDE, DRDO)
PPT Image Analysis(IRDE, DRDO)PPT Image Analysis(IRDE, DRDO)
PPT Image Analysis(IRDE, DRDO)
Nidhi Gopal
 
Contrast limited adaptive histogram equalization
Contrast limited adaptive histogram equalizationContrast limited adaptive histogram equalization
Contrast limited adaptive histogram equalization
Er. Nancy
 

Andere mochten auch (20)

Qubit Systems Inc. & Photon Systems Inc.
Qubit Systems Inc. & Photon Systems Inc.Qubit Systems Inc. & Photon Systems Inc.
Qubit Systems Inc. & Photon Systems Inc.
 
Open GL 09 scan conversion
Open GL 09 scan conversionOpen GL 09 scan conversion
Open GL 09 scan conversion
 
6. pemrograman pointer
6. pemrograman pointer6. pemrograman pointer
6. pemrograman pointer
 
Pertemuan10 spywareadwaredanspam
Pertemuan10 spywareadwaredanspamPertemuan10 spywareadwaredanspam
Pertemuan10 spywareadwaredanspam
 
Pertemuan 1
Pertemuan 1Pertemuan 1
Pertemuan 1
 
7. pemrograman struktur
7. pemrograman struktur7. pemrograman struktur
7. pemrograman struktur
 
Open GL T0074 56 sm1
Open GL T0074 56 sm1Open GL T0074 56 sm1
Open GL T0074 56 sm1
 
Tarby magazine salafiyah kajen
Tarby magazine  salafiyah kajenTarby magazine  salafiyah kajen
Tarby magazine salafiyah kajen
 
Sensor-based phenotyping technology facilitates science and breeding
Sensor-based phenotyping technology facilitates science and breeding Sensor-based phenotyping technology facilitates science and breeding
Sensor-based phenotyping technology facilitates science and breeding
 
Pcd 11
Pcd 11Pcd 11
Pcd 11
 
Dip Morphological
Dip MorphologicalDip Morphological
Dip Morphological
 
Pcd 10
Pcd 10Pcd 10
Pcd 10
 
Week15
Week15Week15
Week15
 
Pcd 4
Pcd 4Pcd 4
Pcd 4
 
Plant Phenotyping, a new scientific discipline to quantify plant traits
Plant Phenotyping, a new scientific discipline to quantify plant traitsPlant Phenotyping, a new scientific discipline to quantify plant traits
Plant Phenotyping, a new scientific discipline to quantify plant traits
 
3.point operation and histogram based image enhancement
3.point operation and histogram based image enhancement3.point operation and histogram based image enhancement
3.point operation and histogram based image enhancement
 
MATLAB & Image Processing
MATLAB & Image ProcessingMATLAB & Image Processing
MATLAB & Image Processing
 
New remote and proximal sensing methodologies in high throughput field phenot...
New remote and proximal sensing methodologies in high throughput field phenot...New remote and proximal sensing methodologies in high throughput field phenot...
New remote and proximal sensing methodologies in high throughput field phenot...
 
PPT Image Analysis(IRDE, DRDO)
PPT Image Analysis(IRDE, DRDO)PPT Image Analysis(IRDE, DRDO)
PPT Image Analysis(IRDE, DRDO)
 
Contrast limited adaptive histogram equalization
Contrast limited adaptive histogram equalizationContrast limited adaptive histogram equalization
Contrast limited adaptive histogram equalization
 

Ähnlich wie Matlab

Matlab intro
Matlab introMatlab intro
Matlab intro
fvijayami
 
Pasos para la reducción de datos en Cananea. Data_reduction_cananea
Pasos para la reducción de datos en Cananea. Data_reduction_cananeaPasos para la reducción de datos en Cananea. Data_reduction_cananea
Pasos para la reducción de datos en Cananea. Data_reduction_cananea
pugahermoso16
 
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
Ashok Kumar
 
ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)
Hasitha Ediriweera
 
Image processing tool box.pptx
Image processing tool box.pptxImage processing tool box.pptx
Image processing tool box.pptx
AvinashJain66
 

Ähnlich wie Matlab (20)

Matlab intro
Matlab introMatlab intro
Matlab intro
 
Pasos para la reducción de datos en Cananea. Data_reduction_cananea
Pasos para la reducción de datos en Cananea. Data_reduction_cananeaPasos para la reducción de datos en Cananea. Data_reduction_cananea
Pasos para la reducción de datos en Cananea. Data_reduction_cananea
 
Simple Matlab tutorial using matlab inbuilt commands
Simple Matlab tutorial using matlab inbuilt commandsSimple Matlab tutorial using matlab inbuilt commands
Simple Matlab tutorial using matlab inbuilt commands
 
Image processing in MATLAB
Image processing in MATLABImage processing in MATLAB
Image processing in MATLAB
 
XIX PUG-PE - Pygame game development
XIX PUG-PE - Pygame game developmentXIX PUG-PE - Pygame game development
XIX PUG-PE - Pygame game development
 
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
 
DIP-Enhancement-Spatial.pptx
DIP-Enhancement-Spatial.pptxDIP-Enhancement-Spatial.pptx
DIP-Enhancement-Spatial.pptx
 
Dip 1
Dip 1Dip 1
Dip 1
 
ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)ImageProcessingWithMatlab(HasithaEdiriweera)
ImageProcessingWithMatlab(HasithaEdiriweera)
 
Py lecture5 python plots
Py lecture5 python plotsPy lecture5 python plots
Py lecture5 python plots
 
The Ring programming language version 1.3 book - Part 38 of 88
The Ring programming language version 1.3 book - Part 38 of 88The Ring programming language version 1.3 book - Part 38 of 88
The Ring programming language version 1.3 book - Part 38 of 88
 
Image processing lab work
Image processing lab workImage processing lab work
Image processing lab work
 
Image processing tool box.pptx
Image processing tool box.pptxImage processing tool box.pptx
Image processing tool box.pptx
 
CE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdfCE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdf
 
matlab.docx
matlab.docxmatlab.docx
matlab.docx
 
Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.
 
Data visualization using the grammar of graphics
Data visualization using the grammar of graphicsData visualization using the grammar of graphics
Data visualization using the grammar of graphics
 
Dip syntax 4
Dip syntax 4Dip syntax 4
Dip syntax 4
 
The Ring programming language version 1.5.3 book - Part 58 of 184
The Ring programming language version 1.5.3 book - Part 58 of 184The Ring programming language version 1.5.3 book - Part 58 of 184
The Ring programming language version 1.5.3 book - Part 58 of 184
 
The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 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 🐘
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

Matlab