Chapter 4- Introduction to Pattern Recognition &
Image processing Pattern Recognition
Introduction to
pattern recognition
and Applications
Introduction: Definition
• Pattern recognition is the theory or algorithm concerned with the
automatic detection (recognition) and later classification of objects or
events using a machine/computer.
• Applications of Pattern Recognition
• Some examples of the problems to which pattern recognition techniques
have been applied are:
• Automatic inspection of parts of an assembly line
• Human speech recognition
• Character recognition
• Automatic grading of plywood, steel, and other sheet material
• Identification of people from
• finger prints,
• hand shape and size,
• Retinal scans
• voice characteristics,
• Typing patterns and
• handwriting
• Automatic inspection of printed circuits and printed characters
• Automatic analysis of satellite picture to determine the type and
condition of agricultural crops, weather conditions, snow and water
reserves and mineral prospects.
• Classification and analysis in medical images. : to detect a disease
Linear discriminant
functions
• A linear discriminant function divides the feature space
by a hyperplane decision surface.
Linear discriminant • The orientation of the surface is determined by the
functions normal vector w, and the location of the surface is
determined by the bias w0.
Features and classes
• Properties or attributes used to classify the objects are called
features.
• A collection of “similar” (not necessarily same) objects are grouped
together as one “class”.
• For
All the example:
above are classified as character T
Classes are identified by a label.
Most of the pattern recognition tasks are first done by humans and automated later.
Automating the classification of objects using the same features as those used by the people can be difficult.
Some times features that would be impossible or difficult for humans to estimate are useful in automated system. For example satellite images use
wavelengths of light that are invisible to humans.
Two broad types of
classification
• Supervised classification
• Guided by the humans
• It is called supervised learning because the process of an algorithm
learning from the training dataset can be thought of as a
teacher supervising the learning process.
• We know the correct answers, the algorithm iteratively makes
predictions on the training data and is corrected by the teacher.
• Classify the mails as spam or non spam based on redecided
parameters.
• Unsupervised classification
• Not guided by the humans.
• Unsupervised Classification is called clustering.
Another
classifier :
Semi
supervised
learning It makes use of a small number of labeled data and
a large number of unlabeled data to learn
Samples or patterns
• The individual items or objects or situations to be classified will be referred as
samples or patterns or data.
• The set of data is called “Data Set”.
Training and Testing data
• Two types of data set in supervised classifier.
• Training set : 70 to 80% of the available data will be used for training the system.
• In Supervised classification Training data is the data you use to train an algorithm or
machine learning model to predict the outcome you design your model to predict.
• Testing set : around 20-30% will be used for testing the system. Test data is used to measure
the performance, such as accuracy or efficiency, of the algorithm you are using to train the
machine.
• Testing is the measure of quality of your algorithm.
• Many a times even after 80% testing, failures can be see during testing,reason being not
good representation of the test data in the training set.
• Unsupervised classifier does not use training data
Introduction to
Statistical Theory
Statistical
Decision Theory
• Decision theory, in statistics, a set of
quantitative methods for reaching
optimal decisions.
Example for Statistical
Decision Theory
• Consider Hypothetical Basket ball Association:
• The prediction could be based on the difference between the
home team’s average number of points per game (apg) and the
visiting team’s ‘apg’ for previous games.
• The training set consists of scores of previously played games, with
each home team is classified as winner or loser
• Now the prediction problem is : given a game to be played, predict
the home team to be a winner or loser using the feature ‘dapg’,
• Where dapg = Home team apg – Visiting team apg
•Data set of games showing outcomes,
differences between average numbers of
points scored and differences between
winning percentages for the participating
teams in previous games
• The figure shown in the previous slide, lists 30 games and gives the value of dapg for each
game and tells whether the home team won or lost.
• Notice that in this data set the team with the larger apg usually wins.
• For example in the 9thgame the home team on average, scored 10.8 fewer points in previous
games than the visiting team, on average and also the home team lost.
• When the teams have about the same apg’s the outcome is less certain. For example, in the
10th game , the home team on average scored 0.4 fewer points than the visiting team, on
average, but the home team won the match.
• Similarly 12th game, the home team had an apg 1.1. less than the visiting team on average and
the team lost.
Histogram of dapg
• Histogram is a convenient way to describe the data.
• To form a histogram, the data from a single class are grouped
into intervals.
• Over each interval rectangle is drawn, with height proportional
to number of data points falling in that interval. In the
example interval is chosen to have width of two units.
• General observation is that, the prediction is not accurate with
single feature ‘dgpa’
Lost
Won
Predicti
on normally a threshold value T is used.
• To predict
• ‘dgpa’ > T consider to be won
• ‘dgpa’ < T consider to be lost
• T is called decision boundary or threshold.
• If T=-1, four samples in the original data are misclassified.
• Here 3 winners are called losers and one loser is called winner.
• If T=0.8, results in no samples from the loser class being misclassified as winner, but 5 samples
from the winner class would be misclassified as loser.
• IF T=-6.5, results no samples from the winner class being misclassified as losers, but 7 samples
from the loser would be misclassified as winners.
• By inspection, we see that when a decision boundary is used to classify the samples the
minimum number of samples that are misclassified is four.
• In the above observations, the minimum number of samples misclassified is 4 when T=-1
• To make it more accurate let us consider two features.
• Additional features often increases the accuracy of classification.
• Along with ‘dapg’ another feature ‘dwp’ is considered.
• wp= winning percentage of a team in previous games
• dwp = difference in winning percentage between teams
• dwp = Home team wp – visiting team wp
•Data set of games showing outcomes,
differences between average number of
points scored and differences between
winning percentages for the participating
teams in previous games.
Now observe the results
on a scatterplot
• Each sample has a corresponding feature vector
(dapg, dwp), which determines its position in the
plot.
• Note that the feature space can be classified into two
decision regions by a straight line, called a linear
decision boundary. (refer line equation). Prediction of
this line is logistic regression.
• If the sample lies above the decision boundary, the
home team would be classified as the winner and it
is below the decision boundary it is classified as
loser.
Prediction with two parameters.
• Consider the following : springfield (Home team)
• dapg= home team apg – visiting team apg = 98.3-102.9 = -4.6
• dwp = Home team wp – visiting team wp = -21.4-58.1 = -36.7
• Since the point (dapg, dwp) = (-4.6,-36.7) lies below the decision
boundary, we predict that the home team will lose the game.
• If the feature space cannot be perfectly separated by a straight line, a more complex
boundary might be used. (non-linear)
• Alternatively a simple decision boundary such as straight line might be used even if it did not
perfectly separate the classes, provided that the error rates were acceptably low.
Simple illustration of Pattern
Classification
• A pattern/object can be identified by set of features.
• Collection of features for a pattern forms feature vector.
• Example : (in next slide)
• P1 and P2 are two patterns with 3 features, so 3 Dimensional
feature vector.
• There are two classes C1 and C2.
• P1 belongs to C1 and P2 belongs to C2
• Given P, a new pattern with feature vector, it has to be
classified into one of the class based on the similarity value.
• If d1 is the distance between (p and p1) and d2 is the
distance between (p and p2) then p will be classified into the
class having least difference.
Block diagram of Pattern recognition and Recognition
•Input to our pattern recognition
system will be feature vectors and
output will be decision about selecting
the classes
• Having the model shown in previous
slide, we can use it for any type
of recognition and classification.
• It can be
• speaker recognition
• Speech recognition
• Image classification
• Video recognition and so on…
• It is now very important to learn:
• Different techniques to extract the features
• Then in the second stage, different methods to recognize the
pattern and classify
• Some of them use statistical approach
• Few uses probabilistic model using mean and variance etc.
• Other methods are - neural network, deep neural networks
• Hyper box classifier
• Fuzzy measure
• And mixture of some of the above
Examples for
pattern recognition
and classification
Handwriting
Recognition
34
License Plate
Recognition
35
Biometric
Recognition
36
Face Detection/Recognition
Detection
Matching
Recognition
37
Fingerprint
Classification
Important step for speeding up identification
38
Autonomous Systems
Obstacle detection and avoidance
Object recognition
39
Medical
Applications
Skin Cancer Detection Breast Cancer Detection
40
Land Cover
Classification
(using
Manyaerial or satellite
applications images) “precision”
including agriculture.
41
Bayes decision rule
Bayes Theorem
• When the joint probability, P(A∩B), is hard
to calculate or if the inverse or Bayes probability, P(B|
A), is easier to calculate then Bayes theorem can be applied.
• Bayesian Decision Theory is a fundamental statistical approach to the
problem of pattern classification.
• It is considered as the ideal pattern classifier and often used as the
benchmark for other algorithms because its decision rule
automatically minimizes its loss function.
• Bayes's law states that the posterior probability is proportional to the
product of the likelihood and the prior probability. The likelihood
encompasses the information contained in the new data.
• The prior expresses the degree of certainty concerning the situation
before the data are taken.
Bayes Theorem
Bayes Theorem:
The goal is to measure: P(wi |X)
Measured-conditioned or posteriori probability, from the above
three values.
P(X|w)
P(w) Bayes Rule P(wi|X)
X, P(X)
This is the Prob. of any vector X being assigned to class wi.
Example for Bayes Rule/ Theorem
• Given Bayes' Rule :
Example1:
• Compute : Probability in the deck of cards (52 excluding jokers)
• Probability of (King/Face)
• It is given by P(King/Face) = P(Face/King) * P(King)/ P(Face)
= 1*
(4/52) / (12/52)
= 1/3
Example2:
Cold (C) and not-cold (C’). Feature is fever (f).
Prior probability of a person having a cold, P(C) = 0.01.
Prob. of having a fever, given that a person has a cold is, P(f|C) = 0.4. Overall
prob. of fever P(f) = 0.02.
Then using Bayes Th., the Prob. that a person has a cold, given that she (or he)
has a fever is:
P(f|C) P(C )
0.4∗0.01
P(C|f) = ==
= 0.2
P(f ) 0.02
Digital Image
Representation
Digital Image Representation
• Digital Image Processing means processing digital image by
means of a digital computer.
• We can also say that it is a use of computer algorithms, in order
to get enhanced image either to extract some useful
information.
• Digital image processing is the use of algorithms and
mathematical models to process and analyze digital images.
• The goal of digital image processing is to enhance the quality of
images, extract meaningful information from images, and
automate image-based tasks.
The basic 1. Image acquisition: This involves capturing an image
using a digital camera or scanner, or importing an
steps existing image into a computer.
involved in 2. Image enhancement: This involves improving the
visual quality of an image, such as increasing
digital image 3.
contrast, reducing noise, and removing artifacts.
Image restoration: This involves removing
processing degradation from an image, such as blurring, noise,
and distortion.
are: 4. Color Image Processing: Color image processing is a
famous area because it has increased the use of
digital images on the internet. This includes color
modeling, processing in a digital domain, etc....
5. Wavelets and Multi-Resolution Processing:In this stage, an
image is represented in various degrees of resolution. Image
The basic is divided into smaller regions for data compression and for
the pyramidal representation.
steps 6. Compression: Compression is a technique which is used for
reducing the requirement of storing an image. It is a very
involved in important stage because it is very necessary to compress
data for internet use.
digital image 7. Morphological Processing:This stage deals with tools which
are used for extracting the components of the image, which
processing 8.
is useful in the representation and description of shape.
Segmentation:In this stage, an image is a partitioned into its
are: objects. Segmentation is the most difficult tasks in DIP. It is a
process which takes a lot of time for the successful solution
of imaging problems which requires objects to identify
individually.
9. Representation and Description: Representation and
The basic description follow the output of the segmentation
stage. The output is a raw pixel data which has all
steps points of the region itself. To transform the raw data,
involved in representation is the only solution. Whereas
description is used for extracting information's to
digital image differentiate one class of objects from another.
10. Object recognition: In this stage, the label is
processing assigned to the object, which is based on descriptors.
11. Knowledge Base: Knowledge is the last stage in DIP.
are: In this stage, important information of the image is
located, which limits the searching processes. The
knowledge base is very complex when the image
database has a high-resolution satellite.
Elements of Visual
Perception
Elements of Visual Perception
• The field of digital image processing is built on the foundation of mathematical
and probabilistic formulation, but human intuition and analysis play the main role
to make the selection between various techniques, and the choice or selection is
basically made on subjective, visual judgments.
• In human visual perception, the eyes act as the sensor or camera, neurons act as
the connecting cable and the brain acts as the processor.
The basic elements of
visual perceptions are:
1. Structure of Eye
• The human eye is a slightly asymmetrical sphere with an
average diameter of the length of 20mm to 25mm. It has a
volume of about 6.5cc.
• The eye is just like a camera. The external object is seen as
the camera take the picture of any object.
2. Image Formation in the Eye
• When the lens of the eye focus an image of the outside world
onto a light-sensitive membrane in the back of the eye, called
retina the image is formed.
3. Brightness Adaptation and Discrimination
• Digital images are displayed as a discrete set of intensities.
• The eyes ability to discriminate black and white at different
intensity levels is an important consideration in presenting
image processing result.
Sampling &
Quantization in
Digital Image
Processing
Sampling & Quantization in Digital
Image Processing
• In Digital Image Processing, signals captured from the physical
world need to be translated into digital form by “Digitization”
Process.
• In order to become suitable for digital processing, an image
function f(x,y) must be digitized both spatially and in amplitude.
• This digitization process involves two main processes called
• Sampling: Digitizing the co-ordinate value is called sampling.
• Quantization: Digitizing the amplitude value is called
quantization
Sampling
• Since an analogue image is continuous not just in its co-ordinates (x axis), but also in its amplitude (y
axis), so the part that deals with the digitizing of co-ordinates is known as sampling.
• In sampling we reduce this noise by taking samples.
• It is obvious that more samples we take, the quality of the image would be more better, the noise
would be more removed and same happens vice versa.
• Sampling has a relationship with image pixels. The total number of pixels in an image can be calculated
as Pixels = total no of rows * total no of columns.
For example, let’s say we have total of 36 pixels, that means
we have a square image of 6X 6
Quantization
Quantization is opposite to sampling because it is done on “y axis” while sampling is done on “x axis”.
Quantization is a process of transforming a real valued sampled image to one taking only a finite number of distinct values(i.e., dividing a signal into
quanta(partitions)).
In the image shown below, these vertically ranging values have been quantized into 5 different levels or partitions.
Ranging from 0 black to 4 white.
This level could vary according to the type of image you want.
Quantization
When we want to improve the quality of image, we can increase the levels assign to the sampled image.
Most digital IP devices uses quantization into k equal intervals. If b-bits per pixel are used,
The number of quantization levels should be high enough for human perception of fine shading details in the image.
The occurrence of false contours is the main problem in image which has been quantized with insufficient brightness levels.
Here is an example for image quantization process.
Image
Transformation
Image Transformation
• An image is obtained in spatial coordinates (x, y) or (x, y, z).
• There are many advantages if the spatial domain image is
transformed into another domain.
• In which solution of any problem can be found easily.
• Following are two types of transformations:
• Fourier Transform
• Discrete Cosine Transformation (DCT)
Fourier Transform
• Fourier transform is mainly used for image processing.
• In the Fourier transform, the intensity of the image is transformed into frequency variation
and then to the frequency domain
• It is used for slow varying intensity images such as the background of a passport size photo
can be represented as low-frequency components and the edges can be represented as high-
frequency components.
• Low-frequency components can be removed using filters of FT domain.
Applications of image transforms are as follows:
• Fourier transform is used for Edge Detection.
Discrete Cosine Transformation (DCT)
• In Discrete Cosine Transformation, coefficients carry information about the pixels of the image.
• Also, much information is contained using very few coefficients, and the remaining coefficient
contains minimal information.
• These coefficients can be removed without losing information.
• By doing this, the file size is reduced in the DCT domain.
• DCT is used for lossy compression.
Applications of image transforms are as follows:
• Discrete Cosine Transform is used for image compression.
Image
enhancement &
Image Restoration
Image Restoration
• Image restoration attempts to reconstruct or recover an image that has been
degraded by a degradation phenomenon.
• Thus, restoration techniques are oriented toward modeling the degradation and
applying the inverse process in order to recover the original image.
IMAGE ENHANCEMENT
• Image enhancement refers to the process of improving the visual appearance
of an image to make it more suitable for analysis or presentation.
• Image enhancement techniques are widely used in various fields, including
medical imaging, satellite imaging, computer vision, and photography.
Image restoration vs. image enhancement
Image restoration Image enhancement
1. It is an objective process(recovering It is a subjective process(making an
the original image) image looks better)
It formulates a criterion of goodness It involves heuristic procedures designed
2. that will yield an optimal estimate of to manipulate an image in order to
the desired result satisfy the human visual system
Techniques include noise removal Techniques include contrast stretching
3. and deblurring (removal of image
blur)
Image compression
What is image compression?
• Image compression is a process applied to a graphics file to minimize its size in bytes without
degrading image quality below an acceptable threshold.
• By reducing the file size, more images can be stored in a given amount of disk or memory
space.
• The image also requires less bandwidth when being transmitted over the internet or
downloaded from a webpage, reducing network congestion and speeding up content delivery.
What are the two types of image compression?
• The methods used to compress image files typically fall into one of two categories: lossy and lossless.
Lossy Compression
• Lossy compression reduces an image file size by permanently removing less critical information, particularly
redundant data.
• Lossy compression can significantly reduce file size, but it can also reduce image quality to the point of distortion,
especially if the image is overly compressed.
• However, quality can be maintained when compression is carefully applied.
• One of the challenges with lossy compression is that it's irreversible.
• Once it has been applied to an image, that image can never be restored to its original state.
• The most common example of lossy compression is JPEG, an image compression format used extensively on the web
and in digital photography.
Lossless Compression:
• This method applies compression without removing critical data or reducing image quality and results in
a compressed image that can be restored to its original state with no degradation or distortion.
• However, lossless compression doesn't reduce the file size nearly as much as lossy compression, offering
little advantage in terms of storage space, network bandwidth or download speeds.
• One of the most common lossless formats is PNG, a widely used format that reduces file size by
identifying patterns and compressing those patterns together.