Download as pdf or txt
Download as pdf or txt
You are on page 1of 80

CSCI451: Digital Image Processing

Prof. Walid Al-Atabany


Professor at ITCS School
Nile University
The school is committed to prepare scientifically and
professionally distinguished graduates in several disciplines in the
field of information technology and computer science. It
elaborates to contribute to society's prosperity, to achieve
sustainable development goals and to support the information
technology industry through multidisciplinary scientific research,
innovation, and enhancing entrepreneurial capabilities
Course Aim and Description
Course Aims:
This course aims to introduce the principles of digital image processing and to
develop students’ knowledge from basic signal processing techniques to
advanced image processing and analysis systems.

Course Description:
The course covers image sampling and quantization, color, point operations,
segmentation, morphological image processing, linear image filtering and
correlation, image transforms, multi-resolution image processing, image
compression, noise reduction and image restoration. Emphasis is on the
general principles of image processing and practical projects.

Prerequisite and Requirements:


- CSCI304 Analysis and Design of Algorithms
- Programming skills
- Good math background (Linear Algebra, Statistical Methods)
Intended Learning Outcomes
Knowledge and Understanding Skills
A1 Explain digital image format.
A2 Describe structure of human eye
A3 Recognize linear and non lienear operations
Intellectual Skills
B1 Analyze imaging using histogram
B2 Analyze image using spatial filtering and frequency domain
B3 Utilize morphological operator
Profession al Skills
C1 Implement spatial domain filtering
C2 Implement frequency domain filtering
C3 Apply morophological operators and segmentation techmiqes in real life images
Transferable Skills
D1 Work in teams and manage time and organizational skills.
D2 Communicate Effectively
D3 Use the general computing facilities.
Course Material
• Digital Image Processing
by Gonzalez 3rd Edition

• An Introduction to
Digital Image Processing
with Matlab Notes for
SCM2511 Image
Processing

• Lecture Notes
CS451 – Digital Image Processing
Instructors:
Prof. Walid Al-Atabany w.al-atabany@nu.edu.eg
Dr. Mustafa A. Elattar melattar@nu.edu.eg

Office hours:
Sun 10:30 - 11:30
Wednesday 10:30 - 11:30
Location: (First Floor) 210
Course Grading Scheme

Quiz 10
Project 15
Assignments 15
Labs 15
Midterm 15
Final Exam 30
Total 100
Course contents
• Introduction to Image Processing
• Image representation
• Image enhancement and filtering
– Point processing
– Histogram processing
– Spatial filtering
– Edge detection
• Image enhancement and filtering in Frequency domain
• Image morphology
• Image coding and compression
• Image segmentation
• Applications
Policies
• Work groups
You must work alone on all assignments stated unless otherwise
• Submission
Assignments due will be announcement
Electronic or physical submissions (no exceptions!)
• Lateness penalties
Get penalized 10% per day
No late submission later than 3 days after due date
Today

Fundamentals of
Image Processing
What is image processing?
➢ What does it mean, to see?
➢ Vision as a computational problem
➢ Sample image processing problems
What does it mean, to see?
• vision is the process of discovering from images what is
present in the world, and where it is.” David Marr, Vision, 1982
• Our brain is able to use an image as an input, and interpret it
in terms of objects and scene structures.
Why does vision appear easy to humans?
• Our brains are specialized to do vision.
• Nearly half of the cortex in a human brain is devoted to doing
vision (motor control ~20-30%, language ~10-20%)
Visual Modules and the Information Flow
• Vision modules can be categorized into three groups according
to their functionality:
➢ Low-level vision: filtering out irrelevant image data
➢ Mid-level vision: grouping pixels or boundary fragments together
➢ High-level vision: complex cognitive processes
Fundamentals of Image Processing
• What is a digital image, how it is formed?
• How images are represented in computers?
• Why we process images?
• How we process images?
Image Formation
• What is measured in an image location?
• – brightness
• – color
Image Formation

• An image is a 2-D function


– f(x, y)
– x and y - spatial coordinates
– f - amplitude (intensity, graylevel) at a point with coordinates (x, y)
• All values finite and discrete - digital image
– Digital image processing - computers involved
• Each value - pixel (picture element)
Image Formation
• Discretization
➢ in image space - sampling
➢ In image brightness - quantization
Image Formation

• The output of a sensor is in most cases a continuous voltage


waveform
– Needs to be digitized
– Sampling - digitizing the coordinate values
• Usually M = 2m steps in x-direction and N = 2n steps in y-
direction
– Quantization . digitizing the amplitude values
• L = 2k gray values
– Image (storage) size = M×N×K/8 bytes
Image Representation
• Digital image: 2D discrete function f
• Pixel: Smallest element of an image f(x,y)
Image Representation
• Digital image: 2D discrete function f
• Pixel: Smallest element of an image f(x,y)
Human Eye
• Two types of receptor cells in retina:
• Cone Receptor cells: 6-7 million → function in bright light,
color sensitive, fine detail
• Rod receptor cells: 75-150 million → function in dim light,
color insensitive, coarse detail
Image Filtering
• Filtering out the irrelevant information

• Image denoising, image sharpening, image smoothing, image


deblurring, etc.
• Edge detection required for many other image manipulation
tasks
Edge Detection
• Edges: abrupt changes in the intensity
➢ Uniformity of intensity or color
• Edges to object boundaries
Image Filtering
• Difficulty: Some of the irrelevant image information have
characteristics similar to those of important image features
Image Smoothing - A Little Bit of History
• Gaussian Filtering / linear diffusion
➢ the most widely used method
Image Denoising
• Images are corrupted with 70% salt-and-pepper noise
Contrast Adjustment
Context-Guided Smoothing
• Use local image context to steer filtering

Preserve main image


structures during filtering
Structure-Preserving Smoothing
Structure-Preserving Smoothing
Image Abstraction
Image Segmentation
• Partition an image into meaningful regions that are likely to
correspond to objects exist in the image

Grouping of pixels
according to what
criteria?

• Boundary-based segmentation
• Region-based segmentation
• Unified formulations
Image Segmentation
• From contours to regions
Image Segmentation
Image Resizing
• Resize an image to arbitrary aspect ratios
Image Retargetting
• Resize an image to arbitrary aspect ratios
Image Retargetting
Image Compression
Face and Gesture recognition
Image processing and Relationship with other
Fields
Components in Digital Image Processing

light green boxes -→ Image processing and analysis.


Yellow boxes belong to “computer vision” and “pattern recognition”
Image Formation
• Light source (λ: wavelength of the source)
➢ E(x, y, z, λ): incident light on a point (x, y, z world coordinates of the
point)
• Each point of the scene has a reflectivity function.
➢ r(x, y, z, λ): reflectivity function
• Light reflects from a point and the reflected light is captured by
an imaging device.
➢ c(x, y, z, λ) = E(x, y, z, λ) * r(x, y, z, λ): reflected light.
Light is part of the Electromagnetic wave
• Light is electromagnetic radiation
➢ exists as oscillations of different frequency (or, wavelength)
Light is part of the Electromagnetic wave

Ultraviolet (UV) light


Light is part of the Electromagnetic wave
Ultraviolet (UV) light
Detecting fungal disease in crops
Ultraviolet Reflectance Imaging
Light is part of the Electromagnetic wave

isible camera
nfrared camera

InfraRed (IR) light

eam plitter
nput scene
Light is part of the Electromagnetic wave
Combined spectra
• Different bands give totally different images of the same object

• Astronomic images of the same region but in different bands


Color spaces: RGB
Color mixing
• Tri-chromatic color mixing theory
➢ Any color can be obtained by mixing three primary colors with a right
proportion
Three Attributes of Color
• Hue
➢ the “kind” of color, regardless of attributes
➢ colorimetric correlate: dominant wavelength
➢ artist’s correlate: the chosen pigment color
• Saturation
➢ the “colorfulness”
➢ colorimetric correlate: purity
➢ artist’s correlate: fraction of paint from the colored tube
• Lightness (or value)
➢ the overall amount of light
➢ colorimetric correlate: luminance
➢ artist’s correlate: tints are lighter, shades are darker
Color spaces: HSV
• Hue, Saturation, Value
• Nonlinear – reflects topology of colors by coding hue as an angle
• Matlab: hsv2rgb, rgb2hsv.
Color spaces: HSV
• Intuitive color space
Color spaces: YCbCr
• Fast to compute, good for
compression, used by TV
Color spaces: YCbCr
• Fast to compute, good for
compression, used by TV
Color spaces: L*a*b*
• “Perceptually uniform”* color space
Gray and Color Image Capture
• Gray images are captured by a single sensor, sensitive to the
entire visible spectrum, similar to the rods in retina
• Color images are captured by having three sensors, each
sensitive to a different primary color, similar to the cones in
retina
Gray and Color Image Display/Printing
• Gray images are displayed by a single light sensitive diode, with
intensity proportional to gray level.
• LCD monitors display color images are displayed by having three
phosphors at each pixel, each generating a different primary
color (red, green, blue)
• Color images are printed by having three color inks (cyan,
magenta, yellow)
Eye Anatomy
The visual system

Optic
Nerve

Lateral
Geniculate
Nucleus
(LGN)

Optic
Nerve

Visual Cortex
Basic retinal processing

Image capture

Smoothing, Gain
control

Centre surround
processing

Spike coding
Hierarchy of Visual Areas
• There are many different neural connections between different
visual areas.

Figures: Nikos K. Logothetis, Vision: A Window on Consciousness, SciAm, Nov 1999F (on the left) Felleman & van Essen, 1991 (on the right)
Photoreceptors
Rod M - cone
S - cone

L - cone
Photoreceptors
• Rods
➢ night vision
➢ Low acuity
➢ Achromatic

• Cones
➢ Day vision
➢ High acuity
➢ Chromatic
➢ Three sets, with different sensitivity functions
700nm (R), 546nm (G), 435nm (B)
Eye vs. Camera
Color Representation
• Specify three primary colors directly
➢ Red, Green, Blue (RGB)
➢ Cyan, Magenta, Yellow (CMY)
• Specify the luminance and chrominance
➢ HSB or HSI (Hue, saturation, and brightness or intensity)
➢ YCbCr (used in digital color TV)
• Amplitude specification:
➢ 8 bits per color component, or 24 bits per pixel
➢ Total of 16 million colors
➢ 1kx1k true RGB color requires 3 MB memory
Digital Image Capture by CCD Array
• Continuous Scene -> Digital image
➢ Each CCD sensor averages the light intensity in a small region and output
a discretized value
Grayscale Image Specification
• Each pixel value represents the brightness of the pixel. With 8-
bit image, the pixel value of each pixel is 0 ~ 255
• Matrix representation: An image of MxN pixels is represented by
an MxN array, each element being an unsigned integer of 8 bits
Color Image Specification

• Three components
➢M = {R, G, B}
Images in Matlab
• Images represented as a matrix
• Suppose we have a NxM RGB image called “im”
➢ im(1,1,1) = top-left pixel value in R-channel
➢ im(y,x,b) = y pixels down, x pixels to right in the bth channel
➢ im(N,M,3) = bottom-right pixel in B-channel
• imread(filename) returns a uint8 image (values 0 to 255)
➢ Convert to double format (values 0 to 1) with im2double
A Brief Matrix Tutorial
• A matrix is an NxM array of numbers
➢ If M=N, A is a square matrix
➢ If N = 1, A is a row vector
➢ If M = 1, A is a column vector
➢ If N=M=1, A is a scalar
➢ aij is the element of A at row i and column j.
• Special Matrix
➢ Identity (unit) matrix I

➢ Diagonal matrix
Matrix Operations
• Addition / Subtraction of matrices.
➢ Matrices A and B are of the same order (NxM)j

• Multiplication of two matrices


➢ A is an NxM matrix, B is an MxL matrix, note that the column number of
A should be the same as the row number of B.
➢ C=A*B, an NxL matrix
Matrix Operations
• Multiplication of a matrix by a scalar
• Transpose of a matrix
➢ Interchange of rows and columns
• If 𝐴 = 𝐴𝑇 , A is symmetric
• Matrix inverse
➢ A must be a square matrix
➢ Some matrices are invertible (singular)
• Trace of a square matrix
• Determinate of a square matrix
A Brief Matlab Tutorial

• An interactive program from The MathWorks for high-


performance numeric computation and visualization.
• Refer to Matlab Primer for general use
• Type “help plot” to see help information of function plot.
• Type “help image” to see functions in image processing toolkit
Matrix, Vector, and Scalar in Matlab
• A matrix is a two dimensional array

• A vector is a 1xN or Nx1 matrix


• A scalar is a 1x1 matrix
Colon Operator in Matlab
• If two integer numbers are separated by
a colon, Matlab will generate all of the
integers between these two integers.
• If three numbers, integer or non integer,
are separated by two colons, the middle
number is interpreted to be a step" and
the first and third are interpreted to be
"limits”
• The colon operator is useful in
extracting smaller matrices from larger
matrices.
Plotting figures in Matlab
Image Toolbox in Matlab
Homework (Due Next Lecture)
1. If you do not have a copy of MATLAB, get one installed.
2. Get a picture of yourself taken in full colors. You could take the picture with a
digital camera, and save it in the JPEG format.
3. Write a matlab program that can i) read your color image into a matrix (you can
use imread() function in MATLAB); ii) convert it to a 8-bit grayscale image (you can
use rgb2gray() in MATLAB), iii) generate a digital negative version of your image,
and iv) display and print both the color image, the original gray scale and the
negative image.
4. If you have not used Matlab before, go through Matlab getting started guide at
http://www.mathworks.com/help/pdf_doc/matlab/getstart.pdf. Go through all
exercises step by step. Make sure that you know basic operations and how to write
m-files (scripts or functions).
5. If you have forgotten your matrix operations, go through first four chapters of
Introduction to Matrix Algebra. Free chapter texts are available at
http://autarkaw.com/books/matrixalgebra/index.html
Thanks

Questions

You might also like