SlideShare a Scribd company logo
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;

More Related Content

PDF
Hill climbing algorithm in artificial intelligence
PDF
From logistic regression to linear chain CRF
PDF
Recursive algorithms
PPTX
String Matching Finite Automata & KMP Algorithm.
PPTX
Qubit Systems Inc. & Photon Systems Inc.
PDF
Open GL 09 scan conversion
PDF
6. pemrograman pointer
PDF
Pertemuan10 spywareadwaredanspam
Hill climbing algorithm in artificial intelligence
From logistic regression to linear chain CRF
Recursive algorithms
String Matching Finite Automata & KMP Algorithm.
Qubit Systems Inc. & Photon Systems Inc.
Open GL 09 scan conversion
6. pemrograman pointer
Pertemuan10 spywareadwaredanspam

Viewers also liked (20)

PPTX
Pertemuan 1
PDF
7. pemrograman struktur
PDF
Open GL T0074 56 sm1
PDF
Tarby magazine salafiyah kajen
PPSX
Image processing on matlab presentation
PDF
Sensor-based phenotyping technology facilitates science and breeding
PDF
PPT
Dip Morphological
PDF
PDF
PDF
PPTX
Introduction in Image Processing Matlab Toolbox
PPTX
Plant Phenotyping, a new scientific discipline to quantify plant traits
PPTX
Image Processing Using MATLAB
PPTX
Matlab and Image Processing Workshop-SKERG
PPTX
3.point operation and histogram based image enhancement
PPTX
MATLAB & Image Processing
PPTX
New remote and proximal sensing methodologies in high throughput field phenot...
PPTX
PPT Image Analysis(IRDE, DRDO)
DOCX
Image Processing using Matlab ( using a built in Matlab function(Histogram eq...
Pertemuan 1
7. pemrograman struktur
Open GL T0074 56 sm1
Tarby magazine salafiyah kajen
Image processing on matlab presentation
Sensor-based phenotyping technology facilitates science and breeding
Dip Morphological
Introduction in Image Processing Matlab Toolbox
Plant Phenotyping, a new scientific discipline to quantify plant traits
Image Processing Using MATLAB
Matlab and Image Processing Workshop-SKERG
3.point operation and histogram based image enhancement
MATLAB & Image Processing
New remote and proximal sensing methodologies in high throughput field phenot...
PPT Image Analysis(IRDE, DRDO)
Image Processing using Matlab ( using a built in Matlab function(Histogram eq...
Ad

Similar to Matlab (20)

PDF
Matlab intro
PDF
Pasos para la reducción de datos en Cananea. Data_reduction_cananea
PPT
Image processing using matlab
PPTX
Introduction to Image Processing with MATLAB
DOC
Simple Matlab tutorial using matlab inbuilt commands
PDF
Image processing basics using matlab
PPTX
Image processing in MATLAB
PPTX
XIX PUG-PE - Pygame game development
PPT
Image Processing using Matlab . Useful for beginners to learn Image Processing
PPTX
DIP-Enhancement-Spatial.pptx
PPT
Key stages of digital image processing.ppt
PDF
PPTX
ImageProcessingWithMatlab(HasithaEdiriweera)
PDF
Py lecture5 python plots
PPTX
Digital Image Processing (Lab 07)
PDF
The Ring programming language version 1.3 book - Part 38 of 88
PPT
Dital Image Processing (Lab 2+3+4)
PPTX
Image processing lab work
PPTX
Image processing tool box.pptx
PDF
CE344L-200365-Lab5.pdf
Matlab intro
Pasos para la reducción de datos en Cananea. Data_reduction_cananea
Image processing using matlab
Introduction to Image Processing with MATLAB
Simple Matlab tutorial using matlab inbuilt commands
Image processing basics using matlab
Image processing in MATLAB
XIX PUG-PE - Pygame game development
Image Processing using Matlab . Useful for beginners to learn Image Processing
DIP-Enhancement-Spatial.pptx
Key stages of digital image processing.ppt
ImageProcessingWithMatlab(HasithaEdiriweera)
Py lecture5 python plots
Digital Image Processing (Lab 07)
The Ring programming language version 1.3 book - Part 38 of 88
Dital Image Processing (Lab 2+3+4)
Image processing lab work
Image processing tool box.pptx
CE344L-200365-Lab5.pdf
Ad

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
August Patch Tuesday
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Encapsulation theory and applications.pdf
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
1. Introduction to Computer Programming.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Empathic Computing: Creating Shared Understanding
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
OMC Textile Division Presentation 2021.pptx
PPTX
Machine Learning_overview_presentation.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
MIND Revenue Release Quarter 2 2025 Press Release
NewMind AI Weekly Chronicles - August'25-Week II
SOPHOS-XG Firewall Administrator PPT.pptx
Machine learning based COVID-19 study performance prediction
Heart disease approach using modified random forest and particle swarm optimi...
August Patch Tuesday
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Encapsulation theory and applications.pdf
Univ-Connecticut-ChatGPT-Presentaion.pdf
1. Introduction to Computer Programming.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Assigned Numbers - 2025 - Bluetooth® Document
Empathic Computing: Creating Shared Understanding
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Accuracy of neural networks in brain wave diagnosis of schizophrenia
OMC Textile Division Presentation 2021.pptx
Machine Learning_overview_presentation.pptx
Unlocking AI with Model Context Protocol (MCP)
MIND Revenue Release Quarter 2 2025 Press Release

Matlab