Title: BIM472 Image processing
1BIM472 Image processing
2Contents
- Visual Perception
- Image Sensing and Acquisition
- Sampling and Quantization
- Representing Digital Images
- Zooming and Shrinking Digital Images
- Some Basic Relationships Between Pixels
3Human Eye
4Elements of Visual Perception
- When the eye is properly focused, light from an
object outside the eye is imaged on the retina - There are discrete light receptors on the retina
- There are two classes of receptors Cones and Rods
5Cones
- Number of 6-7 million
- In the central portion of retina (which is called
fovea) - Highly sensitive to color
- Humans can resolve fine details by them
- Each one is connected to its own nerve end
- Cone vision is called photopic or bright-light
vision
6Rods
- Number of 75-150 millions
- Several nodes are connected to a single nerve
- Less detail is discernible by them
- Serve to give a general, overall picture of the
field of the view - Not involved in color vision
- Sensitive to low-level illumination
- We see colored-objects colorless at moonlight.
This phenomena is called scotopic or dim-light
vision
7Fovea versus CCDs
- We can think fovea as 1.5 mm. 1.5 mm. with
337,000 elements - CCD can contain that number of receptors in an
area of 5 mm. 5 mm.
8Brightness Adaptation and Discrimination
- Real brightness and perceived brightness are a
bit different - Visual system tends to undershoot or overshoot
around the boundary of regions of different
intensities - A regions perceived brightness does not depend
simply on its intensity - Optical illusions
9Undershooting and Overshooting
10Simultaneous Contrast
11Optical Illusions
12Light and EM Spectrum
- The colors that humans perceive in an object are
determined by the nature of the light reflected
from the object - Electromagnetic spectrum was mentioned last week
13Image Sensing and Acquisition
14Image Sensing and Acquisition
- The most familiar sensor is photodiode
- Filter is used to improve selectivity (e.g. green
light)
15Single Sensor
16Sensor Strips
17Sensor Strips
- Scanners
- Photocopy machines
- Geographical imaging
- Medical imaging
- Industrial imaging
18Sensor Arrays
19Sensor Arrays
- Used in digital cameras
- Sensor array is called Charged-Coupled Device
(CCD) - In digital cameras there may be 4000 4000 CCDs
20Sampling and Quantization
- Digitizing the coordinate values is called
sampling - Digitizing the amplitude values is called
quantization - Remember that images are represented by 2D
function f(x,y) - Digitizing x and y is called sampling
- Digitizing f is called quantization
21Sampling and Quantization
22Sampling and Quantization
23Digitizing Digital Images
24Digitizing Digital Images
- The number of gray levels typically is an integer
power of 2 L 2k - We assume that the discrete levels are equally
spaced and that they are in the interval 0, L -
1 - The number of bits required to store a digital
image of size M N is b M N k
25k-bit Image
- The images that have 2k gray levels is called
k-bit images - For example An image with 256 possible
gray-level values is called an 8-bit image
26Spatial and Gray-Level Resolution
- Spatial resolution is the smallest discernible
detail in an image - Gray-level resolution is the smallest discernible
change in gray-level
27Spatial Resolution
28Spatial Resolution
29Gray-Level Resolution
30Gray-Level Resolution
31Details in Digital Images
32Zooming and Shrinking
- Nearest neighbor interpolation
- Example 500 500 ? 750 750
- Pixel replication
- Special case of nearest neighbor interpolation
- Example 500 500 ? 1500 1500
- Bilinear interpolation
- Uses four nearest neighbors
33Bilinear Interpolation
34Some Basic Relationships Between Pixels
- Neighbors of a pixel
- Adjacency
- Path
- Connectivity
- Region
- Boundary
- Edge
- Distance measures
35Neighbors of a Pixel
- Let p be a pixel
- 4-neighbors of p is N4(p)
- Horizontal and vertical neighbors of p
- Diagonal-neighbors of p is ND(p)
- Diagonal neighbors of p
- 8-neighbors of p is N8(p)
- Both N4(p) and ND(p)
- Some neighbors may fall outside of image
36Adjacency
- Let V be a set of gray-level values used to
define adjacency - If the gray-level values of two neighbor pixels
are in V, then they are connected - For binary images with values 0 and 1, V may be
defined as V 1 - For gray-scale images, V may be any subset of all
possible gray-level values - For example V 250,251,252,253,254,255
37Adjacency
- 4-adjacency
- p and q are 4-adjacent if q is in N4(p) and p and
q have values from V - 8-adjacency
- p and q are 8-adjacent if q is in N8(p) and p and
q have values from V - m-adjacency (mixed adjacency)
- p and q have values from V
- i) q is in N4(p) or ii) q is in ND(p) and
the set N4(p)?N4(q) has no pixels whose values
are from V
38Adjacency
N4(p)?N4(q)
39Adjacency Example
40Adjacency
- Two image subsets S1 and S2 are adjacent if some
pixel in S1 is adjacent to some pixel in S2 - Here, adjacent means 4-, 8-, or m-adjacent
41Path
- A (digital) path (or curve) from p (x0 , y0) to
q (xn , yn) is a sequence of distinct pixels
with coordinates (x0 , y0), (x1 , y1), , (xn ,
yn) and (xi , yi) and (xi-1 , yi-1) are adjacent
for 1 i n - Here, n is the length of the path
- If (x0 , y0) (xn , yn), the path is a closed
path - 4-path, 8-path and m-path are defined according
to the adjacency
42Connectivity
- Let S represent a subset of pixels in an image.
- Two pixels p and q are said to be connected in S
if there exists a path between them consisting
entirely of pixels in S. - For any pixel p in S, the set of pixels that are
connected to it in S is called a connected
component of S. - If S has only one connected component, then the
set S is called a connected set.
43Region
- Let R be a subset of pixels in an image.
- We call R a region of the image if R is a
connected set.
44Boundary
- The boundary (border or contour) of a region R is
the set of pixels in the region that have one or
more neighbors that are not in R. - If R happens to be an entire image, then its
boundary is defined as the first and last rows
and columns of the image. - The boundary of a finite region forms a closed
path.
45Edge
- An edge is a set of connected pixels that lie on
the boundary between two regions. - Edges are intensity discontinuities and
boundaries are closed paths.
46Distance Measures
- For pixels p(x,y), q(s,t) and z(v,w), D is a
distance function or metric if - a) D(p,q) 0 and D(p,q) 0 iff p q
- b) D(p,q) D(q,p)
- c) D(p,z) D(p,q) D(q,z).
- The Euclidian distance between p and q is defined
as - De(p,q) (x-s)2 (y-t)21/2
47D4 and D8 Distances
- D4 distance is also called city-block distance
- D4(p,q) x s y t
- D8 distance is also called chessboard distance
- D8(p,q) max( x s , y t )
48Using MATLAB for Image Processing
49Image File Formats
- TIFF Tagged Image File Format
- JPEG Joint Photographic Experts Group
- GIF Graphics Interchange Format
- BMP Windows Bitmap
- PNG Portable Network Graphics
- XWD X Window Dump
50Coordinate Conventions
51Image Functions
- f imread(cameraman.tif)
- size(f)
- M, N size(f)
- imshow(f)
- imshow(f, low high )
- imshow(f, )
- pixval
- imshow(f) figure imshow(g)
- imwrite(f, newpicture.jpg)
- K imfinfo(cameraman.tif)
52Image Types
- The toolbox supports four types of images
- Intensity images
- Binary images
- Indexed images
- RGB images
53Intensity Images
- If the elements of an intensity image are of
class uint8, or class uint16, then they have
integer values in the range 0, 255 and 0,
65535 respectively/ - If the image is of class double, the values are
floating-point numbers and take the values in the
range 0, 1.
54Binary Images
- A binary image is a logical array of 0s and 1s.
- A numeric array is converted to binary using the
function logical.
55Converting between Image Classes
- im2uint8
- im2uint16
- mat2gray
- Converts double matrices to double images in the
range 0, 1 - im2double
- im2bw
- Converts its input to logical image
56Functions
- This program sums and subtracts
- two parameters
- function sum, diff myfunc(a, b)
- sum a b
- diff a - b
- return
Write this code into a file named myfunc.m
57Exercises
- How can you flip an image vertically?
- How can you flip an image horizontally?
- How can you crop an image?
- How can you subsample an image (i.e. make
smaller)?