Sei sulla pagina 1di 55

Digital Image Processing

Unnat Jain
Electrical Engineering, IIT-Kanpur
Indo-European Winter Academy

Agenda

What is an image?

Representation of images

Intuition behind JPEG compression

Understanding JPEG with an example

Practical Image Processing


Image Enhancement using Histogram Manipulation
Image segmentation and edge detection

Agenda

What is an image?

Representation of images

Intuition behind JPEG compression

Understanding JPEG with an example

Practical Image Processing


Image Enhancement using Histogram Manipulation
Image segmentation and edge detection

What is an image?

A grayscale image is a 2D light intensity function


f(x, y)

The value of f at (x, y) is proportional to the brightness


of the scene at that point.

If we have a multispectral image, f(x, y) is a vector,


each component of which indicates the brightness of
the scene at point (x, y) at the corresponding spectral
band. Eg. RGB

How to process continuous function- f(x, y) ?

What is an image?

How to process continuous function- f(x, y) ?

A digital image is an image f(x, y) that has been


discretised both in spatial coordinates
and in brightness.

It is represented by a 2D integer array, or a series of


2D arrays, one for each colour band. The digitised
brightness value is called grey level.

G=Total grey levels

What is an image?

Understanding digital image with an example

Image Processing: The fundamentals-Maria Petrou and Costas Petrou

What is an image?

Understanding digital image with an example

Image Processing: The fundamentals-Maria Petrou and Costas Petrou

What is an image?

Understanding grey levels with an example

Source: Image
Processing: The
fundamentalsMaria Petrou and
Costas Petrou

What is an image?

Understanding grey levels with an example

Source: Image
Processing: The
fundamentalsMaria Petrou and
Costas Petrou

What is an image?

Understanding grey levels with an example

Source: Image
Processing: The
fundamentalsMaria Petrou and
Costas Petrou

Agenda

What is an image?

Representation of images

Intuition behind JPEG compression

Understanding JPEG with an example

Practical Image Processing


Image Enhancement using Histogram Manipulation
Image segmentation and edge detection

Representation of images

Representation in different basis domains


Basis images compose a digital image
Spatial domain

....

....

64 basis images

Representation of images

Representation in different basis domains


Basis images compose a continuous image
Continuous Cosine Transform

Representation of images

Representation in different basis domains


Basis images compose a digital image
Discrete Cosine transform

Representation of images

Representation in different basis domains


Basis images compose a digital image
Discrete Cosine transform

Representation of images

Quick example of DCT (will be useful later)

is a normalizing scale factor to make


the transformation orthonormal

Agenda

What is an image?

Representation of images

Intuition behind JPEG compression

Understanding JPEG with an example

Practical Image Processing


Image Enhancement using Histogram Manipulation
Image segmentation and edge detection

Play time!

Intuition behind JPEG compression


Fact: Joint Photographic Experts Group
Original Image

JPEG Compressed Image

~1% coefficients used


Source: Prof. J. Rombergs lectures [ http://users.ece.gatech.edu/~justin/Tsinghua-Oct13/resources/02-sparsity-overview.pdf ]

Intuition behind JPEG compression


Fact: Joint Photographic Experts Group
Original Image

JPEG Compressed Image

~1% coefficients used


Source: Prof. J. Rombergs lectures [ http://users.ece.gatech.edu/~justin/Tsinghua-Oct13/resources/02-sparsity-overview.pdf ]

Intuition behind JPEG compression

Digital image of (say) 64 pixels

Is any of the 64 pixels less important than the other?


Can I ignore some pixels?

How DCT comes to rescue?


Sparse representation of image in DCT transformed
domain
Lower frequencies (top left): More important
Higher frequencies (bottom right): Less important

JPEG exploits sparse nature of DCT representation


Understanding with an example

Agenda

What is an image?

Representation of images

Intuition behind JPEG compression

Understanding JPEG with an example

Practical Image Processing


Image Enhancement using Histogram Manipulation
Image segmentation and edge detection

Understanding JPEG with an example

JPEG exploits sparse nature of DCT representation


Example

Source: Wikipedia

Understanding JPEG with an example

JPEG exploits sparse nature of DCT representation


Example

Subtract 128

Source: Wikipedia

Understanding JPEG with an example

JPEG exploits sparse nature of DCT representation


Example

Discrete cosine

Source: Wikipedia

transform

Understanding JPEG with an example

Remember!

Discrete cosine

Source: Wikipedia

transform

Understanding JPEG with an example

JPEG exploits sparse nature of DCT representation


Example

Quantization

Source: Wikipedia

Understanding JPEG with an example

JPEG exploits sparse nature of DCT representation


Example

Quantization

DC
coefficient

Source: Wikipedia

AC
coefficient

Understanding JPEG with an example

Encoding AC coefficient by Entropy encoding technique


26

-1

-1

Source: Wikipedia

Understanding JPEG with an example

Encoding AC coefficient by Entropy encoding technique


Symbol 1

Symbol 2

(Runlength,
Size)

(Amplitude)

(0, 2)(-3);
(1, 2)(-3);
(0, 2)(-2);
(0, 3)(-6);
(0, 2)(2);
(0, 3)(-4);
(0, 1)(1);
(0, 2)(-3);
(0, 1)(1);
(0, 1)(1);
(0, 3)(5);

(0, 1)(1);
(0, 2)(2);
(0, 1)(-1);
(0, 1)(1);
(0, 1)(-1);
(0, 2)(2);
(5, 1)(-1);
(0, 1)(-1);
(0, 0).

26
3

-1

-1

=Runlength; Allocate 4 bits


Source: Wikipedia

Understanding JPEG with an example

Encoding AC coefficient by Entropy encoding technique


Symbol 1

Symbol 2

(Runlength,
Size)

(Amplitude)

(0, 2)(-3);
(1, 2)(-3);
(0, 2)(-2);
(0, 3)(-6);
(0, 2)(2);
(0, 3)(-4);
(0, 1)(1);
(0, 2)(-3);
(0, 1)(1);
(0, 1)(1);
(0, 3)(5);
Source: Wikipedia

(0, 1)(1);
(0, 2)(2);
(0, 1)(-1);
(0, 1)(1);
(0, 1)(-1);
(0, 2)(2);
(5, 1)(-1);
(0, 1)(-1);
(15, 0);
(15, 0);
(7, 1)(1);
(0,0).

26
3

-1

-1

=Runlength; Allocate 4 bits

Understanding JPEG with an example


Summary:
Exploit inherent sparse nature of images in frequency
domain
Apposite quantization for different frequencies
Use zig-zag scheme to traverse as per increasing
frequency from top-left to bottom-right
Encoding run-length used to effectively transmit
number of zeros Increasing information rate for the
same bitrate
Questions?
What about bigger images?
How to decode?

Agenda

What is an image?

Representation of images

Intuition behind JPEG compression

Understanding JPEG with an example

Practical Image Processing


Image Enhancement using Histogram Manipulation
Image segmentation and edge detection

Practical Image Processing:


Image Enhancement by Histogram Manipulation

What is a histogram of an image?

Counting the number of pixels in the image that have a


certain grey value

Probability density function by normalizing histogram

Why is histogram manipulation required at all?

(a)

Grey value

Number of pixels

Number of pixels

Different objects or parts of objects, have grey values


which are very similar to each other Low contrast!

(b)

Grey value

Practical Image Processing:


Image Enhancement by Histogram Manipulation

What is a histogram of an image?

Counting the number of pixels in the image that have a


certain grey value

Probability density function by normalizing histogram

Why is histogram equalization required at all?

(a)

Grey value

Which is the one


with higher contrast?

Number of pixels

Number of pixels

Different objects or parts of objects, have grey values


which are very similar to each other Low contrast!

(b)

Grey value

Practical Image Processing:


Image Enhancement by Histogram Manipulation

What is a histogram of an image?

Counting the number of pixels in the image that have a


certain grey value

Probability density function by normalizing histogram

Why is histogram equalization required at all?


Different objects or parts of objects, have grey values
which are very similar to each other Low contrast!

Which is the one


with higher contrast?

Practical Image Processing:


Image Enhancement by Histogram Manipulation

Stretched histogram

Uniform stretching

Light toned areas appearing lighter


Dark toned areas appearing darker

Source:
http://hosting.soonet.ca/eliris/re
motesensing/bl130lec10.html

Practical Image Processing:


Image Enhancement by Histogram Manipulation
<Aside>

Stretched histogram

Uniform stretching

Non-Uniform stretching

Light toned areas appearing lighter


Dark toned areas appearing darker

Non-Uniform stretching
Source:
http://hosting.soonet.ca/eliris/re
motesensing/bl130lec10.html

Practical Image Processing:


Image Enhancement by Histogram Manipulation

Can we do better than Stretched histogram?


How can the modified image contain maximum
information?
Can information theory help us?
Uniform distribution is maximum entropy distribution

Histogram equalization
Uniform probability distribution function

Manipulation should try to conserve semantic


information of image

Then, lets understand equalization with an example

Practical Image Processing:


Image Enhancement by Histogram Manipulation

Conserving semantic information of the image


The information content of an image is conveyed by the
relative grey values of its pixels.
Grey values of the pixels do not have meaning in absolute
terms, but only in relative terms.
If the order (ranking) of pixels in terms of their grey value
is destroyed, the information content of the image will be
affected.

Conclusion:
To conserve semantic information the Cumulative
Distribution Function(CDF) shouldnt change when
Probability Distribution Function(PDF) changes!

Source:
Image Processing:
The fundamentalsMaria Petrou and
Costas Petrou

Practical Image Processing:


Image Enhancement by Histogram Manipulation

Understanding Histogram Equalization with an example

T is the unknown to be estimated

for Histogram Equalization

Source:
Image Processing:
The fundamentalsMaria Petrou and
Costas Petrou

Practical Image Processing:


Image Enhancement by Histogram Manipulation

Can we do better than Stretched histogram?

Histogram equalization
DONE!!! SATIATED?
Lets do something different

Histogram Hyperbolization:

Modified histogram:

Source:
Image Processing:
The fundamentalsMaria Petrou and
Costas Petrou

Practical Image Processing:


Image Enhancement by Histogram Manipulation

Why is Histogram Hyperbolization needed, when we


have maximized entropy?
The human eye can discriminate better darker shades
than brighter ones. [Webers law]
So, the brighter the scene, (higher I) the more different
two brightness levels have to be in order for us to be able
to discriminate them.
Histogram hyperbolisation produces enhanced images

Less bright pixels


[hardly
distinguishable]

More dark pixels


[easily
distinguishable]

Source:
1. www.rags-int-inc.com
2. Image Processing: The
fundamentals-Maria Petrou and
Costas Petrou

Practical Image Processing:


Image Enhancement by Histogram Manipulation

Original

Equalized (Most informative)

Hyperbolized
Informative & Pleasant
to the eye

Practical Image Processing:


Image Enhancement by Histogram Manipulation

Lets summarize:

Definition of Histogram and PDF

Semantic information = Same CDF

Stretching -> Equalization -> Hyperbolization


(More contrast)

(Max. Entropy)

(Enhanced visual
distinguishability)

Agenda

What is an image?

Representation of images

Intuition behind JPEG compression

Understanding JPEG with an example

Practical Image Processing


Image Enhancement using Histogram Manipulation
Image segmentation and edge detection

Practical Image Processing:


Image Segmentation & Edge Detection

The purpose of image segmentation and edge


detection:
Extract the outlines of different regions in the image
Divide the image into regions which are made up of pixels
which have something in common

Original Image

Segmentation

Edge map
Image
Processing: The
fundamentalsMaria Petrou and
Costas Petrou

Practical Image Processing:


Image Segmentation & Edge Detection

Basic case: Dark background, one bright object

How to segment? Choose threshold!

Clear and sharp valley


-Clear object/background

If unclear valley:
-Look around the unclear
pixels
Image
Processing: The
fundamentalsMaria Petrou and
Costas Petrou

Practical Image Processing:


Image Segmentation & Edge Detection

Basic case: Dark background, one bright object

How to segment? Choose threshold!

If individual distributions unknown: Otsus method


(too much for today!)

Image
Processing: The
fundamentalsMaria Petrou and
Costas Petrou

Practical Image Processing:


Image Segmentation & Edge Detection

Basics of edge detection

Grey scale values

First derivative maxima


= edge point

For 2-D image: The gradient has a local maxima at the


edge points

How to define gradient in digital images?

Image
Processing: The
fundamentalsMaria Petrou and
Costas Petrou

Practical Image Processing:


Image Segmentation & Edge Detection

How to define gradient in digital images?


Apply masks on each pixel of digital image
or

Gradient calculation (Eg.):


X

Image Processing: The fundamentals-Maria Petrou and Costas Petrou

Practical Image Processing:


Image Segmentation & Edge Detection

How to define gradient in digital images?


Apply masks on each pixel of digital image

Gradient calculation (Eg.):

Maximas denote edge points


Image Processing: The fundamentals-Maria Petrou and Costas Petrou

Practical Image Processing:


Image Segmentation & Edge Detection

Result of applying masks on digital images:

Different masks for different attributes of an image


Could detect line, edge, corner etc.

Image Processing: The fundamentals-Maria Petrou and Costas Petrou

Practical Image Processing

Summary:

Image: Pixel, grey level, representation in DCT domain

JPEG compression:
Inherent low frequency nature of images exploited
Small coefficients of high frequency are neglected
Zig Zag encoding helps club zeros together, reduce
storage bits without compromising much on quality

Enhancement & Segmentation techniques


Manipulation: Stretching, equalization & Hyperbolization
Segmentation: Choose threshold when valley is clear, else
minimize the misclassified pixels
Edge detection: Maxima of discrete gradient

Digital Image Processing

Unnat Jain
Electrical Engineering, IIT-Kanpur
Indo-European Winter Academy

Thank you!

Potrebbero piacerti anche