Upload
saurabh-gupt
View
226
Download
0
Embed Size (px)
Citation preview
7/31/2019 2_matlabtool
1/16
MATLAB for Image Processing
7/31/2019 2_matlabtool
2/16
CRD LabsCybernetics Research & Development
MATLAB Image Processing Toolbox
Built on the computation and function capabilitiesof MATLAB and the Signal Processing Toolbox.
Can read/write image data in a variety of formats.
Provides functions for image transforms, filtering,
enhancement, image registration, deblurring,feature extraction, etc.
Expandable, by adding own functions.
Command-line oriented, but adding new GUIs toaccess tools is possible.
7/31/2019 2_matlabtool
3/16
7/31/2019 2_matlabtool
4/16
CRD LabsCybernetics Research & Development
CMY Model
Based on secondary colors
Realizes a subtractive color scheme.
Yellow results when the blue is subtracted from white
Red is realized when yellow and magenta are
removed from white.
This approach is used for hard copy devices.
7/31/2019 2_matlabtool
5/16
CRD LabsCybernetics Research & Development
YIQ Model Simple linear transform of RGB:
Used in TV broadcasting
Y component provides information for monochromedisplay.
Exploits human visual system, since we areparticularly sensitive to luminance.
0.299 0.587 0.114
0.596 0.275 0.321
0.212 0.523 0.311
Y R
I G
Q B
7/31/2019 2_matlabtool
6/16
CRD LabsCybernetics Research & Development
HIS Model Most relevant to IP is Hue,
Saturation, and Intensity
(HIS) model
Hue = perceived color
which is approximately thedominant wavelength
Saturation = dilution of
color by white light
7/31/2019 2_matlabtool
7/16
CRD LabsCybernetics Research & Development
MATLAB Image Types
Indexed Images
Intensity Images
Binary Images
RGB Images
Multiframe Image Arrays
Image data in MATLAB can be logical, double,
uint8, uint16
7/31/2019 2_matlabtool
8/16
CRD LabsCybernetics Research & Development
Indexed Images8
Consists of a data matrix,Iand a colormap matrix, C
C is an m-by-3 matrix, with each row specifying the R, G, and B
components of a single color. Values in C are floating point numbers in the range [0, 1]
Color of each pixel is determined by using the corresponding value ofI
as an index into the colormap R G B
0
1 0
Map
1
2
m
100.5 0.5 0.5
1 0.35 0.25 Example:.>> [x, map] = imread('forest.tif');>> imshow(x, map)
1 0
1
10
Image
7/31/2019 2_matlabtool
9/16
7/31/2019 2_matlabtool
10/16
7/31/2019 2_matlabtool
11/16
CRD LabsCybernetics Research & Development
Colormap A colormap is an m-by-3 matrix of real numbers
between 0.0 and 1.0
Each row is an RGB vector that defines one color
>> load flujet
>> figure;imagesc(X);>> figure;imagesc(X);colormap gray
7/31/2019 2_matlabtool
12/16
CRD LabsCybernetics Research & Development
Reading Images12
MATLAB can read images of various formats including BMP, HDF, JPEG, PCX, TIFF, XWD
Use function imreadto read image filesimreadreads indexed, intensity, and truecolor images
Images are read into a uint8 matrix of appropriate size
imreadautomatically determines the format of the image based oninformation in the header
You can specify a format as an optional second argument
>> Crusader = imread(Crusader.jpg');>> image(Crusader)
7/31/2019 2_matlabtool
13/16
CRD LabsCybernetics Research & Development
Writing Images MATLAB can write images of various formats including the following
BMP, HDF, JPEG, PCX, TIFF, PNG, PNM Use function imwrite to write image files
imwrite determines the format from extension of filename You can specify an optional format if extension is absent or to force a particular format
Use imfinfo(filename) to get information on an image file
13
>> Abrams = imread(Abrams.jpg');>> image(Abrams)>> whos Abrams
Name Size Bytes ClassAbrams 511x640x3 981120 uint8 arrayGrand total is 981120 elements using 981120 bytes>> AbramsGray = rgb2gray(Abrams);>> colormap gray;>> image(AbramsGray)>> imwrite(AbramsGray, 'Abrams.bmp');
7/31/2019 2_matlabtool
14/16
CRD LabsCybernetics Research & Development
Summary
imreadUsed to read images
imwriteWrite matrices to specified image format
imshow/imageDisplay images
imfinfoRetrieve information about image
colormapSet/change colormap used for
displaying image
7/31/2019 2_matlabtool
15/16
CRD LabsCybernetics Research & Development
More on image display
>> a = imread(kids.jpg);>> b = imread('SCHOT_CENTER.JPG')>> subplot(121); subimage(a);
>> subplot(122); subimage(b);
>> imshow(F,[-1 5]);>> colormap(jet),colorbar
Use to display multiple images in the
same figure.
Use colorbar to add a colorbar to the image..
7/31/2019 2_matlabtool
16/16
CRD LabsCybernetics Research & Development
Image Arithmetic
Standard MATLAB arithmetic operators are defined fordouble data. The IP toolbox provides a set of functions to do arithmetic
on other data types.