Title: Image Processing : Basic Concept
1Image Processing Basic Concept
2Imaging Systems Overview
- Consists of two primary components
- Hardware Image acquisition system, computer,
and display devices - Software Image manipulation(??), analysis, and
processing -
3 4- Image is accessed (??) as a 2-D array (??) of
data, where each data point is referred to as a
pixel (??) - Notation
- I(r,c) Brightness (??) of image at the pt
(r,c) - where
- r row(?), and c column(?)
5Visible Light Imaging
- Reflectance (??) function determines manner in
- which objects (??) reflect light
6- Sensors Converts (??) light energy into
electrical energy -
-
a) Single imaging sensor b) Linear ( line)
sensor c) 2-D or array sensor
- CCD 4kx4k CMOS less power, cheaper, image
quality not as good as CCD
7Image Representation
- Optical (??) image Collection of spatially
distributed (????) light energy measured by an
image sensor to generate I(r,c) - Matrix 2-D array like the image model,
- I(r,c)
- Vector One row or column in a matrix
-
8Image Types
- Binary (???) images Simplest type of images,
which can take two values, typically black or
white, or 0 or 1 - Gray scale (??) images One-color or monochrome
images that contains only brightness information
and no color information - Color images 3 band monochrome images, where
each band corresponds to a different color,
typically red, blue and green or RGB
9- Color pixel vector Single pixels values for a
color image, (R,G,B) - Multispectral(???) Images Images of many bands
containing information outside of the visible
spectrum(????)
10Color Transform/Color Model
- Mathematical model or algorithm to map(??) RGB
data into another color space (????) - Decouples (??) brightness and color information
- Hue(??)/Saturation(???)/Lightness(??) (HSL) Color
Transform - Describes colors in terms that we can more
readily understand -
11- Hue corresponds to color, saturation corresponds
to the amount of white in color, and lightness is
the brightness - For example a deep, bright orange color would
have a large intensity (bright), a hue of
orange , and a high value of saturation
(deep(??)) - But in terms of RGB components, this color would
have the values as R 245, G 110, and B20
12(No Transcript)
13- Equations for mapping RGB to HSL are
-
-
- where
14Digital Image File Formats
- Bitmap images (raster images) Images that can be
represented by our image model, I (r,c)
15- Image file header (????) A set of parameters
(??) found at the start of the file image and
contains information regarding - Number of rows (??)(height, ?)
- Number of columns (??)(width, ?)
- Number of bands (???)
- Number of bits per pixel (?????? ??)(bpp)
- File type (????)
-
16- Look-up table (LUT) Used for storing RGB values
for 8-bit color images
17- Common image file formats are
- BIN, RAW
- PPM,PBM,PGM
- BMP
- JPEG
- TIFF
- GIF
- RAS
- SGI
- PNG
- PICT, FPX
- EPS
- VIP
-
18Matlab ????I/O??????
- ?Matlab?,?????(pixel)?????0?1???????1????,0?????
- ???????RGB,??? red(?) ?green(?) ?blue(?)???????
- ?????????????,??????,?????????
19Matlab ????I/O??????
- ?????????????,?????????????????RGB ??????????
20Matlab ????I/O??????
- Show ???imshow( )
- ??????imshow(???? A,?? N) ,?????? A?N???????????
- ?N???,??24?????,???256???
- ????A?????A( , , 3)???????,A( , ,
1)??????? A( , , 2)??????? A( , ,
3)????????
21Matlab ????I/O??????
- ????????????,??????????????,???????????????imshow
(???? A, lim_l lim_h) - ?????? A ??????lim_l,????????lim_h,??????
22Matlab ????I/O??????
- ???????????,????Matlab?workspace?,??imread(????)
??,??imshow( )??????? - imwrite( )????????????,??????imwrite(????,
????????, ????)
23Ex2_1.m
- clear close all
- Aimread('1.bmp')
- figure ?????
- imshow(A)
- size(A)
- figure
- imshow(A(,,2)) ?show????
- imwrite(A(,,2),'ex2_1.tif','tif')
- BA(100150,150200,1) ????????
- figure
- imshow(B)
- figure
- imshow(B,100 200)
24Convolution Mask (????)
- Mask Operation (????)
- ????? 3 x 3 (???? 5 x 5, 7 x 7)
25- Convolution Consist of following process
- Overlay (??) the mask (??) on the image
- Multiply the coincident terms (???????)
- Sum all the results (?????)
- Move to the next pixel, across the entire image
-
-
Convolution mask for first order hold (?????????)
26(No Transcript)
27(No Transcript)
28- Spatial Filters (?????)
- Operate on raw (???) image data in the (r,c)
space, by considering small neighborhoods (??),
3x3, 5x5, 7x7, and moving sequentially
(???)across and down the image - Returns a result based on a linear (??) or
nonlinear (???) operation
29- Consists of three types of filters
- Mean filters (?????)
- Median filters (?????)
- Enhancement filters (?????)
- Many spatial filters are linear filters
implemented with a convolution mask (????????)
the result is a weighted sum (???) of a pixel and
its neighbors
30- Mask coefficients (??) tend to effect (??) the
image in the following general ways - Coefficients are positive (??) blurs (???) the
image - Coefficients are alternating positive and
negative (????) sharpens (??) the image - Coefficients sum to 1 (?????1) brightness
retained (??) - Coefficients sum to 0 (?????1) dark (?) image
31- Mean filters (?????)
- Averaging filters (?????)
- Tend to blur (???) the image
- Adds a softer look to the image
- Example 3x3 convolution mask (????)
-
32Mean filter
Mean filtered image
Original image
33- Median filters (?????)
- Nonlinear filter
- Sorts (??) the pixel values in a small
neighborhood and replaces the center (???) pixel
with the middle value (???) in the sorted list
(?????) - Output image (????) needs to be written to a
separate image (a buffer (???)), so that results
are not corrupted (??) - Neighborhood (??) can be of any size but 3x3, 5x5
and 7x7 are typical (??) -
34Median filter
Original image with salt and pepper noise (?????)
Median filtered image (3x3)
35Ex3_2.m (mean filter ? median filter???)
- Image ???
- Image_noisy ??????
- Image_low ???????????
- Image_med ???????????
- Imageimread('ex2_1.tif')
???? - ??????????????,??0.06 ?????
- Image_noisy imnoise (Image ,'salt
pepper',0.06) - Image2_noisydouble(Image_noisy)/255 ??
double?? - h1/9 1/9 1/91/9 1/9 1/9 1/9 1/9 1/9
??????? - Image_lowfilter2(h, Image2_noisy)
?????? - Image_medmedfilt2(Image_noisy,3 3)
?????33?? - imshow(Image)
- figure,imshow(Image_noisy)
- figure,imshow(Image_low)
- figure,imshow(Image_med)
36- Enhancement filters (?????)
- Implemented with convolution masks having
alternating positive and negative (????)
coefficients - Enhance the image by sharpening (??)
- Two types considered here
- Laplacian-type (?????) filters
- Difference filters (???)
-
37- 1. Laplacian-type (?????) filters
- Are rotationally invariant (?????), that is they
enhance the details (????) in all directions
equally (???????) - Example convolution masks of Laplacian-type
filters are -
Filter 1
Filter 2
Filter 3
38Laplacian filter
Contrast enhanced (????) Version of Laplacian
filtered image
Laplacian filtered image
Original image
39- 2. Difference (??) filters
- Also called as emboss (??) filters
- Enhances the details in the direction specific
(????) to the mask selected - Four primary difference filter convolution masks,
corresponding to the edges (?) in the vertical
(??), horizontal (??), and two diagonal
directions (????) are
Diagonal 2
Horizontal
Diagonal 1
Vertical
40Difference filter
Original image
Difference filtered image
Difference filtered image added to the original
image, with contrast enhanced (????)
41Ex3_3.m (????????)
- close all clear
- Aimread('cat.bmp')
- m,nsize(A) ????size?mxn
- imshow(A)
- CM_lapa0 -1 0 -1 5 -1 0 -1 0 Laplacian????
- CM_diff1 0 0 0 1 0 0 0 -1 difference ????
- Bfilter2(CM_lapa,A) ??Laplacian ????
- Cfilter2(CM_diff,A) ??difference ????
- figure imshow(B/256)
- figure imshow(C/256)
42- Binary Image Analysis (??????)
- Binary images are useful in many computer vision
applications which require simple object shape
such as positioning a robot to grasp (??) an
object, to check a manufactured object for
defects (??), FAX, OCR(??????) -
43- Binary Image Analysis (??????)
- Most cameras provide us color or gray level
images, thus we need to convert those images into
binary images - Next, we extract (??) simple binary features and
use them to classify (??) binary objects
44- Thresholding via Histogram (?????????)
- Thresholding is required to create a binary image
(????) from a gray level image (????) - This is done by specifying a threshold value
(??????) which will set all values above the
specified gray level to 1 and everything below
the specified value to 0 - Typically 255 is used for 1 and 0 is used for
the 0 value
45- In many applications the threshold value is
determined experimentally (?????) and is highly
dependent on lighting conditions and object to
background contrast (?????,???????????????) - It is much easier to find a good threshold value
with proper lighting, and good background to
object contrast
46Figure 3.3-1 Effects of Lighting and Object to
Background Contrast on Thresholding
b) Result of thresholding (???) image (a)
a) An image of a bowl with high object to
background contrast (??????? ????) and good
lighting (????)
47Figure 3.3-1 Effects of Lighting and Object to
Background Contrast on Thresholding (contd)
d) Result of thresholding image (c)
c) An image of a bowl with poor object to
background contrast (??????? ????) and poor
lighting(????)
48- The histogram (???) is a plot of gray level
versus the number of pixels (??????????) in the
image at each gray level - Histogram of an image is examined (??) to select
the proper (???) threshold value - The peaks (??) and valleys (??) in the histogram
are examined and a threshold is experimentally
selected (??????) that will best separate (?????)
the object from the background (??)
49Figure 3.3-2 Histograms (???)
Threshold ?
b) The histogram of image (a), showing the
threshold that separates object and
background (????????? ??????)
a) An image of a bowl with high object to
background contrast and good lighting
Image after threshold (????????)
50Figure 3.3-2 Histograms (contd)
Threshold ?
d) The histogram of image (c), showing what
appears to be a good threshold, but it does
not successfully separate object and
background
c) An image of a bowl with poor object to
background contrast and poor lighting
Image after threshold
51Ex3_5.m (??????)
- Aimread('car_number.bmp') imshow(A)
XA(,,3) - m,nsize(X)
- figure, imshow(X)
- figure, imhist(X) ?????????
- th70 ?????
- Czeros(m,n)
- for i1m
- for j1n
- if X(i,j)gtth
- C(i,j)1
- end
- end
- end
- figure,imshow(C)
52- Histogram equalization (?????)
- A technique where the histogram of the resultant
image is as flat as possible (???????????) - The theoretical basis for histogram equalization
involves probability theory, where we treat the
histogram as the probability distribution of the
gray levels (?????????????) - Its function is similar to that of a histogram
stretch but often provides more visually pleasing
results across a wider range of images
(??????????????????????)
53- Consists of 4 steps
- 1. Find the running sum of the histogram
- values (??????????)
- 2. Normalize the values from step (1) by
- dividing by the total number of pixels
(?(1)? ??????????) - 3. Multiply the values from step (2) by the
- maximum gray level value and round
(?(2)? ?????????????????) - 4. Map the gray level values to the results
- from step (3) using a one-to-one
- correspondence (???????????? ??????(3)?????)
54- Example
- 3-bits per pixel image range is 0 to 7.
- Given the following histogram
- Number of Pixels
- Gray Level Value (Histogram values)
- 0 10
- 1 8
- 2 9
- 3 2
- 4 14
- 5 1
- 6 5
- 7 2
55- 1) Create a running sum of the histogram values.
(??????????) This means the first value is 10,
the second is 10818, next 108927, and so on.
Here we get 10, 18, 27, 29, 43, 44, 49, 51 - 2) Normalize by dividing by the total number of
pixels. (?(1)? ??????????) - The total number of pixels is 1089214150
51 (note this is the last number from step 1),
so we get 10/51, 18/51, 27/51, 29/51, 43/51,
44/51, 49/51, 51/51 - 3) Multiply these values by the maximum gray
level values, in this case 7, and then round the
result to the closest integer (?(2)???????????????
???). After this is done we obtain 1, 2, 4, 4,
6, 6, 7, 7
56- 4) Map the original values to the results from
step 3 by a one-to-one correspondence
(??????????????????(3)?????). This is done as
follows -
- Original Gray Histogram
- Level Value Equalized Values
- 0 1
- 1 2
- 2 4
- 3 4
- 4 6
- 5 6
- 6 7
- 7 7
57- All pixels in the original image with gray level
0 are set to 1, values of 1 are set to 2, 2 set
to 4, 3 set to 4, and so on. After the histogram
equalization values are calculated and can be
implemented efficiently with a look-up-table
(LUT)(?????????,???????), as discussed in Chapter
2 - We can see the original histogram and the
resulting histogram equalized histogram in Fig.
8.2.14. Although the result is not flat, it is
closer to being flat than the original
histogram(????????,?????????????) -
58(No Transcript)
59Histogram Equalization Examples (???????)
1.
Input image
Resultant image after histogram equalization
60Histogram Equalization Examples (contd)
2.
Input image
Resultant image after histogram equalization
Note As can be seen histogram equalization
provides similar results regardless
of the input image (??????????????,
????????????)
61- Histogram equalization of a digital image will
not typically provide a histogram that is
perfectly flat, but it will make it as flat as
possible (???????????????,?????????????) - Histogram equalization may not always provide the
desired effect, since its goal is fixed to
distribute the gray level values as evenly as
possible. (????????????)To allow for interactive
histogram manipulation, the ability to specify
the histogram is necessary
62Ex8_3.m (??????)
- ??????
- image_1 ???image_2 ???????????
- image_1imread('L5_1.bmp') ????
- image_2histeq(image_1)????????????
- imshow(image_1) ?????
- figure,imshow(image_2) ????????
- figure,imhist(image_1) ?????????
- figure,imhist (image_2) ???????????
63- Morphological Filtering (????)
- Morphology(???) relates to form and structure of
objects (????????) - Morphological filtering simplifies a segmented
image to facilitate the search for objects of
interest(???????????,???????????) - This is done by smoothing out object outlines
(?????????), filling small holes (?????),
eliminating small projections (?????), and with
other similar techniques
64- The two principal morphological operations(?????)
are dilation (??)and erosion (??) - Dilation allows objects to expand (??), thus
potentially filling in small holes (?????), and
connecting disjoint objects (????????) - Erosion shrinks (??) objects by etching away
(eroding) (??) their boundaries (??)
65- These operations can be customized for an
application by the proper selection of the
structuring element (?????????), which determines
exactly how the objects will be dilated or eroded - Basically, the structuring element is used to
probe (??) the image to find how it will fit, or
not fit, into the image object(s)
66- Dilation(??) It is performed by laying the
structuring element on the image and sliding it
across the image in a manner similar to
convolution (???????????????????) - If the origin of the structuring element
coincides with a 0 in the image, there is no
change move to the next pixel (???????????????0
,????,??????) - If the origin of the structuring element
coincides with a 1 in the image, perform the OR
logic operation on all pixels within the
structuring element (???????????????1
,?????????????OR????)
67- With a dilation operation, all the 1 pixels in
the original image will be retained - (??), any boundaries will be expanded (??????),
and small holes will be - filled (??????)
68- Note In 1st printing
- of book, the structuring
- element is incorrect
69- Erosion (??) It is similar to dilation, but we
turn pixels to '0', not '1' - If the origin of the structuring element
coincides with a '0' in the image, there is no
change move to the next pixel (???????????????0
,????,??????) - If the origin of the structuring element
coincides with a 1 in the image, and any of the
1 pixels in the structuring element extend
beyond the object (1 pixels) in the image, then
change the 1 pixel in the image, whose location
corresponds to the origin of the structuring
element, to a 0(???????????????1,???????1
???????1 ,?????????????????0).
70- With an erosion operation, the only remaining
pixels are those that coincide to - the origin of the structuring element where
it is all contained in the object
71Note In first printing of book, the 4th row,
4th col 0, should be a 1, in the IMAGE
72- Opening (??) It consists of an erosion followed
by a dilation (??????) - It can be used to eliminate all pixels in regions
that are too small to contain the structuring
element (??????????????????????) - In this case the structuring element is often
called a probe, as it is probing the image
looking for small objects to filter out of the
image
73- The output image tends to take a shape similar
to the structuring element itself
74- Closing (??) It consists of a dilation followed
by erosion(??????) - It can be used to fill in holes and small gaps
(??????) - It will connect small, adjacent objects
(?????????) - Closing tends to close up or fill in objects
75- Note that holes and gaps are filled, but, unlike
dilation, more of the original - boundary is retained
76- Closing and opening will have different
results(?????????)even though both consist of an
erosion and a dilation - Therefore, order of operation is important
(????????) for morphological operations - Different structuring elements will also provide
different results (???????????????). As noted
before, objects in the output image will tend to
take the shape of the structuring element
(????????????????????)
77Figure 4.3-18 Binary Dilation with Various Shape
Structuring Elements
a) Original image, a microscope cell image that
has undergone a threshold operation
(original image courtesy of Sara Sawyer, SIUE)
b) Dilation with a circular (???)structuring
element
78Figure 4.3-18 Binary Dilation with Various Shape
Structuring Elements (contd)
d) Dilation with a cross shape (???)structuring
element
c) Dilation with a square (??) structuring
element
79Figure 4.3-19 Dilation with Different Size
Structuring Elements
b) Dilation with a circular structuring
element of size 3
a) Original image
80Figure 4.3-19 Dilation with Different Size
Structuring Elements (contd)
d) Dilation with a circular structuring
element of size 11
c) Dilation with a circular structuring
element of size 7
81Figure 4.3-20 Binary Erosion with Various Shape
Structuring Elements
b) Erosion with a circular structuring element
a) Original image, a microscope cell image
that has undergone a threshold operation
(original image courtesy of Sara Sawyer,
SIUE),
82Figure 4.3-20 Binary Erosion with Various Shape
Structuring Elements (contd)
d) Erosion with a cross shape structuring
element
c) Erosion with a square structuring element
83Figure 4.3-21 Binary Opening with Various
Shape Structuring Elements
b) Opening with a circular structuring element
a) Original image, a microscope cell image
that has undergone a threshold operation
(original image courtesy of Sara Sawyer,
SIUE),
84Figure 4.3-21 Binary Opening with Various
Shape Structuring Elements (contd)
d) Opening with a cross shape structuring
element
c) Opening with a square structuring element
85Figure 4.3-22 Binary Closing with Various Shape
Structuring Elements
b) Closing with a circular structuring element
a) Original image, a microscope cell image
that has undergone a threshold operation
(original image courtesy of Sara Sawyer,
SIUE),
86Figure 4.3-22 Binary Closing with Various Shape
Structuring Elements (contd)
d) Closing with a cross shape structuring
element
c) Closing with a square structuring element
87Figure 4.3-23 Opening and Closing with Different
Size Structuring Elements
a) Original microscopic cell image (courtesy
of Sara Sawyer, SIUE)
b) Image after undergoing a threshold
operation
88Figure 4.3-23 Opening and Closing with Different
Size Structuring Elements (contd)
d) Closing with a circular structuring
element of size 5
c) Opening with a circular structuring
element of size 5