Published by John Wiley & Sons, Inc., Hoboken, New Jersey, 4th ed 2007 4 Digital Signal and Image Processing Using MATLAB, Gerard Blanchet Maurice Charbit, Printed and bound in Great Br
Trang 1IMAGE PROCESSING
Using
MATLAB
Trang 2Tại sao lại dùng matlab?
Matlab (MATrix LABoratory)
Ảnh trong matlab được xử lý như là ma
trận
Mỗi pixel là một phần tử của ma trận
Tất cả các toán tử trong matlab đều tác
độ ng lên ma trận và có thể được dùng
để tác động lên ảnh: +, -, *, /, ^, sqrt,
sin, cos, etc.
Trang 3Tài Liệu
1) Digital image processing using Matlab, Rafael C Gonzalez,
Richard E Woods, Steven L Eddins, Printed in India, (2005)
2) Graphics and GUIs with MATLAB by Patrick Marchand and O
Thomas Holland, 3rd ed (2003)
3) Digital image processing, Pratt, William K Published by John Wiley & Sons,
Inc., Hoboken, New Jersey, 4th ed (2007)
4) Digital Signal and Image Processing Using MATLAB, Gerard Blanchet
Maurice Charbit, Printed and bound in Great Britain by Antony Rowe Ltd, Chippenham, Wiltshire, (2006)
5) Image processing and analysis, Chan T and Shen J Printed in United states
of America, (2005)
6) Biosignal and Biomedical Image processing (Matlab-Based application),
John L Semmlow, Printed in United states of America, (2004)
7) Image processing and jump regression analysis, Peihua Qiu, Printed in
United states of America (2005)
8) Image Analysis of Food Microstructure, John C Russ, Printed in the United
States of America, (2005)
Trang 5XỬ LÝ ẢNH IMAGE PROCESSING
Trang 6recognition, segmentation
High Level Process Input: Attributes Output: Understanding Examples: Scene
understanding, autonomous navigation
In this course we will
stop here Low Level Process Mid Level Process High Level Process
Trang 7CÁC L Ĩ NH V Ự LIÊN QUAN
Trang 8Ứ ng dụng của Computer Vision & Image processing
Trang 9APPLICATION OF IMAGE PROCESSING
Trang 10APPLICATION OF IMAGE PROCESSING
Trang 13APPLICATION OF IMAGE PROCESSING
Trang 15Computer Vision System
Kiểm tra sản phẩm
Trang 16APPLICATION OF IMAGE PROCESSING
Trang 25Traffic Monitoring
Ứ ng dụng trong giao thông
Trang 26APPLICATION OF IMAGE PROCESSING
Trang 29Ứ ng dụng trong công nghiệp
Trang 30Face Detection
Ứ ng dụng trong an ninh quốc phòng
Trang 31Image Types in MATHLAB
Indexed images
Intensity (or grayscale) images
RGB (or truecolor) images:
Black and White Images
Trang 32Indexed Images
An indexed image consists of a data matrix, X ((of type
uint8, uint16, or double), and a colormap matrix, map
Youcan read X and map by
The pixels in the image are represented by integers,
which are pointers (indices) to color values stored in the colormap
For example pixel X= 5 points to
[0.29 0.0627 0.0627]
Trang 34Intensity Images
An intensity image is a data matrix, I, whose values represent intensities within some range.
MATLAB stores an intensity image as a single matrix of class double, uint8, or uint16, with each element of the matrix corresponding to one image pixel.
Trang 368-Bit and 16-Bit RGB Images
The color components of an 8-bit RGB image are integers in the range [0, 255] rather than floating-point values in the range [0, 1].
A pixel whose color components are (255,255,255) displays as white.
To obtain red, blue and green
components of a pixel (10,5) of the
image I
Trang 38Ả nh màu
Một ảnh màu được mô tả bởi 3 ma trận
31.087
.065.0
75.082.056.0
02.038.048.0
73.093.037
0 0.19 0.84 0.71
92.056.016.0
Trang 39G N
G
M G G
G
M G G
G
G
f f
f
f f
f
f f
f f
, ,
2 ,
1
2 , 2
, 2 2
, 1
1 , 1
, 2 1
, 1
B N
B
M B B
B
M B B
B B
f f
f
f f
f
f f
f f
, ,
2 ,
1
2 , 2
, 2 2
, 1
1 , 1
, 2 1
, 1
R N
R
M R R
R
M R R
R
R
f f
f
f f
f
f f
f f
, ,
2 ,
1
2 , 2
, 2 2
, 1
1 , 1
, 2 1
, 1
N
M M
f f
f
f f
f
f f
f
, ,
2 ,
1
2 , 2
, 2 2
, 1
1 , 1
, 2 1
, 1
Trang 40BLUE
GREEN
Qu á trình tác động nên các phần tử của ma trận ảnh để làm nổi bật các đặc trưng mong muốn gọi là xử lý ảnh
Các màu cơ bản
và quá trình xử lý ảnh
Trang 42Example RGB
Trang 44Ả nh các đường biên ngăn cách các vùng màu khác nhau của màng
mỏng Au
Trang 45ứ ng dụng trong khoa học vật liệu
Cấu trúc bề mặt của màng mỏng
vàng trên đế silic sau khi ủ Ảnh khi tách các vùng giàu Au ra từ ảnh ở bên trái
Trang 46Tách các vùng giàu Au ra từ ảnh màng mỏng vàng trên đế Si (xem hình 2)
Hình 6: Phần bề mặt màu đỏ được tách riêng ra và có diện
tích S=6.92% diện tích toàn bề mặt
Trang 47Basics about image processing in matlab
In this section we present:
Basics of working with images in Matlab
We will see how to read, display, write and convert images
We will also talk about the way images are represented in Matlab and how to convert between the different types.
Trang 48One pixel
1 2 3
Trang 49intensity
RGB binary
Trang 52Grand total is 400 elements using 400
bytes f is an array of class uint8, and
size 20x20 That means 20 rows and 20 columns We can see some of this information with the following commands
Trang 54Basics about image processing in matlab
Trang 55Basics about image processing in matlab
The syntax imshow(f, [low high]) displays
all pixels with values less than or equal to
low as black, all pixels with values greater
or equal to high as white.
figure, imshow(f) figure, imshow(f, [100, 150]) figure, imshow(f, [100, 200])
Trang 56Basics about image processing in matlab
We can also display portions of an image by specifying the range
>> figure, imshow(f(10:100, 10:200), [50, 210])
Trang 57Basics about image processing in matlab
Another matlab tool available to display images and do simple image manipulations
is imtool.
Trang 58Basics about image processing in matlab
Images can be written to disk using the function
imwrite Its format is
Trang 59Image types, data classes and image classes
There are different image types and image classes available in MATLAB The two primary image types you will be working with are as follows:
1/ Intensity images
uint16 [0, 65535] (CCD cameras on microscopes)
uint8[0, 255] (From your standard digital camera)
double [-10308, 10308]
2/ Binary images (black and white)
logical, 0 or 1
Trang 60Image types, data classes and image classes
Raw images typically come in the form of an unsigned
integer (uint16 denotes 16-bit unsigned integer, and uint8
denotes 8-bit unsigned integer) However floating-point operations (mathematical operations that involve a decimal
point, such as log(a)) can only be done with arrays of class
Trang 61Many MATLAB image processing operations operate under the assumption that the image is scaled to the range [0,1] For instance, when
imshow displays an double image, it displays an
intensity of 0 as black and 1 as white You can
automatically create a scaled double image using
Trang 62Matlab converts f to class double, and then sets to
0 the values below T and to 1 the values above T The result is of class logical See the following
Trang 63Basic Segmentation using Thresholding
Many biological images comprise of light objects over a constant dark background, in such a way that object and background pixels have gray levels grouped into two dominant modes One obvious way
to extract the objects from the background is to select a threshold T that separates these modes:
where g(x,y) is the thresholded binary image of f(x,y) We can
implement the thresholding operation in MATLAB by the
following function:
>> g = im2bw(f, T)
Trang 64Image histograms and threshold
Image histograms provide a means to visualize the distribution of grayscale intensity values in the entire image They are useful for estimating background values, determining thresholds, and for visualizing the effect of contrast djustments on the image (next section) The matlabfunction to visualize image histograms is imhist
>> f = imread('rice.png');
>> imhist(f) >> imhist(f, 30)
Trang 65Image histograms and threshold
Trang 66Image histograms and threshold
imb = im2bw(im,level+0.1); imb = im2bw(im,level-0.1);
How to solve?
Trang 67Image histograms and threshold
Using the binary image, we can then calculate region properties of objects in the image, such as area, diameter, etc… An object in a binary image is a set of white pixels (ones) that are connected to each other
We can enumerate all the objects in the figure using the bwlabel command: