0% found this document useful (0 votes)
26 views105 pages

Image Processing

The document discusses digital image processing and computer vision, covering theoretical and practical applications, algorithms, and techniques for measuring image quality. It explains the differences between analog and digital images, the processes of sampling and quantization, and various applications in fields such as medicine, agriculture, and law enforcement. Additionally, it addresses image enhancement, restoration, segmentation, and compression, highlighting the importance of resolution and bit depth in digital images.

Uploaded by

fabian mbigili
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views105 pages

Image Processing

The document discusses digital image processing and computer vision, covering theoretical and practical applications, algorithms, and techniques for measuring image quality. It explains the differences between analog and digital images, the processes of sampling and quantization, and various applications in fields such as medicine, agriculture, and law enforcement. Additionally, it addresses image enhancement, restoration, segmentation, and compression, highlighting the importance of resolution and bit depth in digital images.

Uploaded by

fabian mbigili
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 105

DIGITAL IMAGE PROCESSING AND

COMPUTER VISION
7. Sub – enabling Outcomes:
3.1.1Apply theoretical capabilities of computer vision on measuring quality
vision
i. Explain measurement of image quality
ii. Explain calorimetric approach
iii. Explain spatial vision approach
iv. Explain fundamental approach for digital photography
3.1.2Apply practical capabilities of computer vision on measuring quality
vision
v. Performance measurement of image vision
vi. Measure calorimetric of image vision
vii. Perform spatial vision approach
viii.Perform fundamental approach for digital photograph
3.1.3 Formulate solutions to problems in computer vision on measuring quality
vision
i. Solve problems in computer vision
ii. Match models to image data
iii.Perform simple implicit models
iv. Perform shading
3.2.1 Interpret image using computer vision and image using pixel units
v. Explain major capabilities requirements of visual systems
vi.Find and identify things in image and 3D interpretation
vii.Use applications for varying levels of complexity in image computer vision
viii.Explain robot vision in image computer
ix.Explain surveillance in image computer image vision.
3.2.2 Apply spatial vision approach to recognize man-made objects size
using computer image using spatial vision approach
i. Explain spatial vision in image processing
ii. Explain system approach in systems approach
iii. Explain internal scales of image quality
3.2.3 Explain the basic concept algorithmic tools of computer vision on
image
iv. Explain basic concepts tools of computer vision on image
v. Explain 3D technology
vi. Explain image sequencing
vii. Describe practical image compositing
3.3.1 Design algorithm of computer vision and image on visual systems
i. Explain mathematical morphology in computer vision and image on visual
system
ii. Apply mathematical morphology in computer vision and image on visual
system
iii. Explain recovering depth in computer image system
iv. Explain multiresolution approach in computer image system
3.3.2 Design algorithm if computer vision and image on 2D and 3D images or
sequences of images
v. Explain a dynamic 3d scene from 2D images
vi. Describe edge detection techniques
vii. Explain grey level segmentation
viii.Perform high performance computing for vision and image processing
3.3.3 Apply tools and algorithms of computer vision in identifying
expected things in images
i. Explain image restoration
ii. Apply software used in analysis manipulation
iii.Explain stereo image technologies
iv. Explain edge detection technique
v. Explain parameters which can be evaluated when measurement are
made in darkness
vi.Explain parameter which can be evaluated when measurement are
made in light
An analog image can be mathematically
represented as a continuous range of values
representing position and intensity.
An analog image is characterized by a physical
magnitude varying continuously in space.
For example, the image produced on the screen of a
CRT monitor is analog in nature
A digital image is the discrete representation of data
possessing both spatial (layout) and intensity (colour)
information.
An analog image can be mathematically
represented as a continuous range of values
representing position and intensity.
An analog image is characterized by a physical
magnitude varying continuously in space.
For example, the image produced on the screen of a
CRT monitor is analog in nature
A digital image is the discrete representation of data
possessing both spatial (layout) and intensity (colour)
information.
A digital image is composed of picture elements called
pixels.
Pixels are the smallest sample of an image.
Conversion of an analog image into a digital image involves two
important operations, namely, sampling and quantisation, which
are illustrated in Fig. 1.1.

Digital image from analog image

The two-dimensional (2-D) discrete, digital image I(m, n)


represents the response of some sensor.
Discretization occurs naturally with certain types of imaging sensor (such as CCD
cameras) and basically effects a local averaging of the continuous signal over some
small (typically square) region in the receiving domain.
The indices m and n respectively designate the rows and columns of the image.
The individual picture elements or pixels of the image are thus referred to by their
2-D (m, n)
An image contains one or more colour channels that define the
intensity or colour at a particular pixel location I(m, n)

The 2-D Cartesian coordinate space of an M x N digital image


Advantages of Digital Images
 The processing of images is faster and cost-effective.
 Digital images can be effectively stored and efficiently transmitted from one
place to another.
 When shooting a digital image, one can immediately see if the image is good
or not.
 Copying a digital image is easy. The quality of the digital image will not be
degraded even if it is copied for several times.
 Whenever the image is in digital format, the reproduction of the image is both
faster and cheaper.
 Digital technology offers plenty of scope for versatile image manipulation.
Disadvantages of Digital Images
 Misuse of copyright has become easier because images can be copied from
the Internet just by clicking the mouse a couple of times.
 A digital file cannot be enlarged beyond a certain size without compromising
on quality.
 The memory required to store and process good-quality digital images is very
high.
 For real-time implementation of digital-image-processing algorithms, the
processor has to be very fast because the volume of data is very high.
What is image processing?
The processing of an image by means of a computer is generally
termed digital image processing

Image processing involves changing the nature of an image in


order to either
1. Improve its pictorial information for human interpretation, or
2. Make it more suitable for autonomous machine perception.
Resolution and quantization
The size of the 2-D pixel grid together with the data size stored
for each individual image pixel determines
 the spatial resolution and
 colour quantization of the image.
The representational power (or size) of an image is defined by
its resolution.
The resolution of an image source (e.g. a camera) can be
specified in terms of three quantities
 Spatial resolution(the pixel or digital resolution of the image)
 Temporal resolution
 Bit resolution
Spatial resolution
Spatial resolution is the number of pixels used to cover the
visual space captured by the image.
This relates to the sampling of the image signal and is
sometimes referred to as the pixel or digital resolution of the
image.
It is commonly quoted as C X R (e.g. 640 X 480, 800 X 600,
1024 X 768, etc.)
Temporal resolution
Temporal resolution is a continuous capture system such as
video, this is the number of images captured in a given time
period.
It is commonly quoted in frames per second (fps), where each
individual image is referred to as a video frame
(e.g. commonly broadcast TV operates at 25 fps; 25–30 fps is
suitable for most visual surveillance; higher frame-rate cameras
are available for specialist science/engineering capture)
Bit resolution
Bit resolution is the number of possible intensity/colour values that a pixel
may have and relates to the quantization of the image information.
For instance a binary image has just two colours (black or white), a grey-scale
image commonly has 256 different grey levels ranging from black to white whilst
for a colour image it depends on the colour range in use.

The bit resolution is commonly quoted as the number of binary


bits required for storage at a given quantization level, e.g.
 binary is 2 bit,
 grey-scale is 8 bit and
 colour (most commonly) is 24 bit.
Image processing applications.
1.Medicine
 Inspection and interpretation of images obtained from X-
rays, MRI or CAT scans,
 analysis of cell images, of chromosome karyotypes.
 Have been used to detect cancerous tumors and diseases of
the eye
2. Agriculture
 Satellite/aerial views of land, for example to determine how
much land is being used for different purposes, or to
investigate the suitability of different regions for different
crops,
 inspection of fruit and vegetables—distinguishing good and
Image processing applications.
3. Industry
 Automatic inspection of items on a production line,
 inspection of paper samples.

4. Law enforcement
 Fingerprint analysis,
 sharpening or de-blurring of speed-camera images.
 Iris recognition

5. Driverless car and pilotless planes will soon be reality to


image processing
Applications of image processing
Character recognition:
The process of scanning a page of text creates an image file.
It will be very convenient if individual characters can be recognized within a page of text.
This will help us to convert the image file into a text file, which can then be edited

Object recognition:
Robotics has developed tremendously in recent times and the automatic processing of images and recognition of objects is
essential to further progress.

Unmanned vehicles:
Unmanned vehicles are being used extensively by the military (many countries use pilotless drones). Unmanned civilian vehicles
may also soon be a reality if one goes by the progress of Google’s driverless car project.

Remote sensing.
Remote sensing satellites have been launched by many countries.
Remote sensing can be used for a variety of military and civilian applications.
It can be used for detecting and monitoring movement of vehicles and also for calculating areas under cultivation or covered by
forests.
Applications of image processing
Image processing in the field of entertainment and
electronic/ print media
Images are manipulated or entirely fabricated to
create the ‘special effects’ seen in movies.
Involve the creation of artificial images using computer graphics,
sometimes existing images are also ‘processed’ or manipulated to
create the desired effect.
Image formats
A SIMPLE IMAGE FORMATION MODEL
 Consider images by two-dimensional functions of the
form f ( x,y ).
 The value of f at spatial coordinates (x ,y ) is a scalar
quantity whose physical meaning is determined by the
source of the image, and whose values are proportional
to energy radiated by a physical source (e.g.,
electromagnetic waves).
An example of digital image
 As a consequence, f (x,y ) must be nonnegative and
acquisition.
finite; that is,
(a)Illumination (energy) source.
(b)A scene.
(c)Imaging system.
(d) Projection of the scene onto the
image plane.
A SIMPLE IMAGE FORMATION MODEL
 Function f x y ( , ) is characterized
by two components:
 the amount of source
illumination incident on the
scene being viewed, and
 the amount of illumination
reflected by the objects in the
scene.
These are called the illumination
and reflectance components,
and are denoted by i ( x,y ) and r (
x, y ), respectively.
A SIMPLE IMAGE FORMATION MODEL
These are called the illumination
and reflectance components,
and are denoted by i ( x,y ) and r (
x, y ), respectively.
The two functions combine as a
product
to form f ( x, y ): Thus, reflectance is
bounded by 0 (total
absorption) and 1 (total
reflectance).
The nature of i ( x, y ) is
determined by the
illumination source, and r
( x, y) is determined by the
A SIMPLE IMAGE FORMATION MODEL
EXAMPLE : Some typical values of illumination and reflectance.
The following numerical quantities illustrate some typical values of
illumination and reflectance for visible light. On a clear day, the sun may
produce in excess of 90 000 , lm/m2 of illumination on the surface of the
earth. This value decreases to less than 10 000 , lm/m2 on a cloudy day. On
a clear evening, a full moon yields about 0 1 . lm/m 2 of illumination. The
typical illumination level in a commercial office is about 1 000 , lm/m 2.
Similarly, the following are typical values of r (x, y): 0.01 for black velvet,
0.65 for stainless steel, 0.80 for flat-white wall paint, 0.90 for silver-plated
metal, and 0.93 for snow
IMAGE SAMPLING AND QUANTIZATION
BASIC CONCEPTS IN SAMPLING AND
QUANTIZATION
 to generate digital
images from sensed data.
 The output of most
sensors is a continuous
voltage waveform whose
amplitude and spatial
behavior are related to
the physical phenomenon
being sensed.
 To create a digital image,
we need to convert the
continuous sensed data
into a digital format. This
requires two processes:
sampling and
quantization.
IMAGE SAMPLING AND QUANTIZATION
A continuous image f that we
want to convert to digital form.
 An image may be continuous
with respect to the x- and y-
coordinates, and also in
amplitude.
To digitize it, sampling the
function is required in both
coordinates and in amplitude.
Digitizing the coordinate values
is called sampling.
Digitizing the amplitude values
is called quantization.
The Hue, Saturation and Value (HSV) colour space popular in
image analysis applications
Three parameters can be interpreted as follows:
 H (hue) is the dominant wavelength of the colour, e.g. red, blue,
green.
 S (saturation) is the ‘purity’ of colour (in the sense of the amount
of white light mixed with it)
 V (value) is the brightness of the colour (also known as
luminance).
Image enhancement. This refers to processing an image so that
the result is more suitable for a particular application.
It occurs as result of taking the photography in hurry.
Insufficient lighting or the scene being lit from wrong direction.
Especially in wildlife photography it desirable to take photography at
night.
Question is it possible to process such image and enhance their
contrast?
Example include:
Sharpening or de-blurring an out of focus image,
Highlighting edges,
Improving image contrast, or brightening an image,
Removing noise.
Image restoration. This may be considered as reversing the
damage done to an image by a known cause,
Photographing an object which is in high speed with respect to
photographer can cause the image to be blurred.
This happens in sporting events and satellite photograph.
Blurring can occur due to atmospheric turbulence or improper
focusing
for example:
 Removing of blur caused by linear motion,
 Removal of optical distortions,
 Removing periodic interference.
Image segmentation. This involves subdividing an image into
constituent parts, or isolating certain aspects of an image.
for example:
 finding lines, circles, or particular shapes in an image,
 in an aerial photograph, identifying cars, trees, buildings,
or roads.
Image compression.
Most of the image files (.*bmp) occupy a large space on the
hard disc and may take long time to transmit over the
internet.
Can we compress ? Without compromising the information they
convey? Is there any theoretical limits to the amount of
compression we can achieve?
Image recognition and classification
Can computer or robot recognize and classify millions of
image?
Image recognition is used extensively in unmanned vehicles.
Example the development of Google’s self driving car
Digital image

The grayscale values are stored in binary


format and if we use k bits to store each
pixel of an M × N image
The total number of bits used to store the
entire image will be M × N × k.

A simple 2-D image and the gray levels of each pixel, shown as a 2-D array.
Digital image

The grayscale values are stored in binary


format and if we use k bits to store each
The 2-D Cartesian coordinate space of an M x N pixel of an M × N image
digital image
The total number of bits used to store the
entire image will be M × N × k.
Digital image

The grayscale values are stored in binary


format and if we use k bits to store each
pixel of an M × N image
The total number of bits used to store the
entire image will be M × N × k.

A simple 2-D image and the gray levels of each pixel, shown as a 2-D array.
Types of digital images
Binary. Each pixel is just black or white.

Greyscale.
Each pixel is a shade of grey, normally
from 0 (black) to 255(white).
This range means that each pixel can be A binary
represented by eight bits, or exactly one image
byte
Digital image
True colour, or RGB.
Each pixel has a particular colour; that colour
being described by the amount of red, green
and blue in it.
If each of these components has a range 0 –
255 , this gives a total of 2553 = 16,777,216
different possible colours in the image. This is
enough colours for any image.
Since the total number of bits required for each
pixel is 24 , such images are also called 24 -bit
colour images.
A true color image
Digital image
True colour, or RGB.
Such an image may be considered as consisting of
a “stack” of three matrices; representing the red,
green and blue values for each pixel.
This means that for every pixel there correspond
three values.

A true color image


Image File Sizes
For example, suppose we consider a 512 x 512 binary image.
The number of bits used in this image (assuming no compression, and neglecting,
for the sake of discussion, any header information) is
512 512 1 262,144 bit
262144 / 8 32768 bytes
32.768 Kb
0.033Mb
We consider a 512 x 512 a greyscale image of the same size requires:
512 512 1 262,144 bytes
262.14 Kb
0.262Mb
Image File Sizes
For colour images, each pixel is associated with 3 bytes of colour information.
A image thus requires
512 512 3 786, 432 bytes
786.43 Kb
0.786 Mb
“A picture is worth one thousand words”
Assuming a word to contain 10 ASCII characters (on average), and that each
character requires 8 bits of storage, then 1000 words contain
1000 * 10 * 8 = 80,000 bits of information.
This is roughly equivalent to the information in a
283 283 binary image
100 100 greyscale image
58 58 RGB colour image
How many bits are required to store a 1024 × 1024, 12 bit image?
Processes involved in image processing and recognition
These disturbances can give rise to a
‘noisy’ image.
Noise is also intrinsic to all electronic
circuits. Hence, noise reduction techniques
are essential in the case of many images.
Images may suffer from noise or
blurring
Enhancing the contrast and/or
brightness of the acquired image.
Involves enhancing the ‘quality’ of
the image for the benefit of a human
viewer
To separate an image into its
constituent parts, so that the process
of recognizing an object becomes
An image processing task.
Acquiring the image. Ie can be done by using either a CCD
camera, or a scanner.
Preprocessing. This is the step taken before the “major” image
processing task.
In this case it may involve enhancing the contrast, removing
noise, or identifying regions likely to contain the postcode,
Segmentation. Here is where we actually “get” the postcode; in other
words we extract from the image that part of it which contains just the
postcode.
Representation and description. These terms refer to
extracting the particular features which allow us to
differentiate between objects. Here we will be looking for
curves, holes and corners which allow us to distinguish
the different digits which constitute a postcode.
Recognition and interpretation. This means assigning labels to
objects based on their descriptors (from the previous step), and
assigning meanings to those labels. So we identify particular
digits, and we interpret a string of four digits at the end of the
address as the postcode.
Image acquisition process which converts an analog
image to electrical signals and then to digital data. Two
types of acquisition devices, also called input devices,
are commonly used: the scanner and the digital
camera.
A scanner is usually used to digitize printed documents and
printed photographs.
It consists of a glass panel on which the document is placed
face down and a scan head below it containing a source of
white light.
As the scan head moves from left to right and top to bottom,
the light is reflected from all parts of the document and falls on
an array of electronic sensors called charge coupled device
The CCD converts the light from the document into
electrical signals with amplitudes proportional to the
intensity of light.
The electrical signals are then fed to an analog-to-digital
converter (ADC), which converts them to digital data
Ausing
software
the interface canprocess.
digitization be used to specify parameters
associated with digitization.
The spacing between pixels called the image resolution,
measured in dots per inch (dps), and
The number of bits for representing the pixel values called bit-
depth.
Grayscale images usually have a bit-depth of 8 while
An image is represented in digital form i.e. as a collection o
pixels, editing and programming software tools can be used
to change the pixel values and hence modify the image in
variety of ways.
A collective term used to denote all these various operation
for modifying images is called image processing.
Image processing operations can be categorized into a
number of types.
Geometrical transformation of the image like
cropping, translation, rotation, and scaling
without actual modification of pixel values.
Involves changing the pixel values using input–output
relationships called gamma curves.
 Involves changing pixel values using probability
density functions like histograms.
 Involves using kernel operations which modify pixel
values based on local neighborhoods.
 Involves modification using arithmetic-, logical-,and
morphological-operations.
 Involves color modification and conversion. Color
models enable us to represent and communicate color
information.
Studies have shown that all colors we can see can be
represented as combinations in different proportions of
three primary colors viz. red (R), green (G), and blue (B).
This has led to the development of the RGB color model
which defines how composite colors can be
Images in Matlab
Reading, writing and querying images
Reading and writing images is accomplished very simply
via the imread and imwrite functions.
The function imfinfo can be used to query an image and establish all its
important properties, including its type, format, size and bit depth.
Images in Matlab
Language Fundamentals hex2dec: convert
 ceil: round toward hexadecimal to decimal
positive infinity length: length of largest
 clc: clear command
window
array dimension
double: convert to double linspace: generate vector
precision data type of evenly spaced values
 eps: epsilon, a very small meshgrid: generates 2-D
value equal to 2-52 or 2.22 grid coordinates
× 10-16 NaN: not a number, output
 fnd: fnd indices and
from operations which have
values of nonzero
elements
undefined numerical results
 format: set display
Images in Matlab
num2str: convert numbers to strings
numel: number of array elements
ones: create array of all ones
prod: product of array elements
strcat: concatenate strings horizontally
uint8: unsigned integer 8-bit (0 to 255)
unique: unique values in array
whos: list variables in workspace, with
sizes and types
zeros: create array of all zeros
Images in Matlab
Basic display of images
Matlab provides two basic functions for image display:
imshow and imagesc.
Whilst imshow requires that the 2-D array specified for
display conforms to an image data type (e.g.
intensity/colour images with value range 0–1 or 0–255),
imagesc accepts input arrays of any Matlab storage type
(uint 8, uint 16 or double) and any numerical range.
Imagesc function scales the input range of the data and
displays it using the current/default colour map.
It is controlled by display feature using the colormap
function
Basic display of
images
clc;
clear all;
close all;
imfinfo('cameraman.tif’) %Query the cameraman
image that
I1= imread('cameraman.tif' ); %Read in the TIF format
cameraman image
%Write the resulting array I1 to
%disk as a JPEG image
Y= imwrite(I1,'cameraman.jpg','jpg’);
imfinfo('cameraman.jpg') %Query the resulting disk
image
Basic display of
Example.
imagesWrite a program to
read an image, display
information about it and write
it back in a different file figure,
format. subplot(221), imshow(a);
clear; clc;
x = uint8(1000) % returns 255
title('original PNG');
a = imread('peppers.png'); subplot(222), imshow(b); title('JPG
whos quality 10');
imfinfo('peppers.png') subplot(223), imshow(c); title('JPG
quality
imwrite(a, 'p10.jpg', 'quality', 10); 5');
imwrite(a, 'p5.jpg', 'quality',subplot(224),
5); imshow(d); title('JPG
imwrite(a, 'p0.jpg', 'quality',quality
0); 0');
b = imread('p10.jpg');
Basic display of
images 2: Write a program to
Example
display a 2-D matrix as an image by
specifying a colormap.
clear; clc;
a = [1, 3, 4 ; 2, 6.4, 0 ; 0.5, 5, 5.5];
colormap jet
subplot(121), image(a); colorbar; axis
square;
The BM function
subplot(122), colormap
imagesc(a); specifes
colorbar; axis the name
of a colormap called jet containing 64 colors.
square;
The BM function colorbar displays all the colors
in the current colormap
Basic display of
images 3: Write a program to read a color
Example
image
and display its color channels separately
clear; clc;
a = imread('peppers.png');
a_red = a(:,:,1); % red channel
a_green = a(:,:,2); % green channel
a_blue = a(:,:,3); % blue channel
subplot(221), imshow(a); title('RGB');
subplot(222), imshow(ar); title('R');
subplot(223), imshow(ag); title('G');
subplot(224), imshow(ab); title('B');
Basic display of
images
Comments
. Matlab functions: imshow, imagesc and colormap
Note the automatic display scaling of imagesc.
B=rand(256).*1000; %Generate random image array in
range 0–1000
imshow(B); %Poor contrast results using imshow because
data %exceeds expected range
imagesc(B); %imagesc automatically scales colourmap to
data
axis image;
axis off; %range
colormap(gray); colorbar;
Basic display of
images
To display multiple images together, this is best achieved by the subplot
function.
This function creates a mosaic of axes into which multiple images or plots can be
displayed.
B = imread('cell.tif'); %Read in 8-bit intensity image of cell
C=imread('spine.tif'); %Read in 8-bit intensity image of spine
D=imread('onion.png'); %Read in 8-bit colour image
subplot(3,1,1); imagesc(B); axis image; %Creates a 3 1 mosaic of plots
axis off; colormap(gray); %and display first image
subplot(3,1,2); imagesc(C); axis image; %Display second image
axis off; colormap(jet); %Set colourmap to jet (false colour)
subplot(3,1,3); imshow(D); %Display third (colour) image
Accessing pixel values
Matlab also contains a built-in interactive image viewer which can be launched using the imtool
function.
Its purpose is slightly different from the other two: it is a graphical, image tool which is intended
primarily for the inspection of images and sub-regions within
them. clc;
close all;
B=imread('cell.tif'); %Read in 8-bit intensity image of cell
imtool(B); %Examine grey-scale image in interactive viewer
D=imread('onion.png'); %Read in 8-bit colour image.
imtool(B); %Examine RGB image in interactive viewer
B(25,50) %Print pixel value at location (25,50)
B(25,50)= 255; %Set pixel value at (25,50) to white
imshow(B); %View resulting changes in image
D(25,50,:) %Print RGB pixel value at location (25,50)
D(25,50, 1) %Print only the red value at (25,50)
D(25,50,:)= [255, 255, 255]; %Set pixel value to RGB white
imshow(D); %View resulting changes in image
Converting image
types
Matlab functions: rgb2gray

clc;
close all;
D=imread('onion.png'); %Read in 8-bit RGB
colour image
Dgray=rgb2gray(D); %Convert it to a grey-
scale image
subplot(2,1,1);
imshow(D);
axis image; %Display both side by side
Converting image
types
Matlab functions: imabsdiff,
rgb2hsv.
clc;
close all;
D=imread('onion.png'); %Read in 8-bit RGB colour
image.
Dred=D(:,:,1); %Extract red channel (first channel)
Dgreen=D(:,:,2); %Extract green channel (second
channel)
Dblue=D(:,:,3); %Extract blue channel (third channel)
subplot(2,2,1); imshow(D); axis image; %Display all in 2
2 plot
subplot(2,2,2); imshow(Dred); title('red'); %Display and
Exercise 1
Using the examples presented for displaying an image in Matlab together with
those for accessing pixel locations, investigate adding and subtracting a scalar
value from an individual location, i.e. I i, j  I i, j   25 or I i, j  I i, j   25
Start by using the
grey-scale ‘cell.tif’ example image and pixel location (100; 20).What is the
effect on the greyscale colour of adding and subtracting?
Expand your technique to RGB colour images by adding and subtracting to all
three of the colour channels in a suitable example image. Also try just adding to
one of the individual colour channels whilst leaving the others unchanged. What
is the effect on the pixel colour of each of these operations?
Image Enhancement in Spatial
Domain
Image enhancement is the process of editing an image
in order to make it ‘better’ for a human viewer for a
particular application.
 This involves smoothing or sharpening image contents.
 Spatial domain refers to the two-dimensional image
plane in terms of pixel intensities.
 In spatial domain image enhancement methods, the
image is processed by operating on the pixel intensities
directly in the image plane itself.
 The other category of image enhancement methods is
transform domain methods.
 Transform domain methods operate on the Fourier
Image Enhancement in Spatial
Domain
Spatial domain transformations are of the
form:
g  x, y  T  f  x, y 
where f(x,y) is the input image, T is transformation to be
applied on the image and g(x,y) is the transformed
image
Point Processing
Each pixel is operated independently.
Only the intensity of the pixel being processed is
considered.
The neighboring pixels are not considered in the
processing, i.e., the neighborhood size is 1x1, which is
smallest possible.
In point processing, every pixel with the same gray level
value in the input image maps to the same value in the
output image.
Point operations require very little memory.

Point processing.
Point Processing
a) Brightness Manipulation
b) Inverse Transformation
c) Contrast Manipulation
d) Log Transformations
e) Power-law Transformations
f) Piecewise-Linear Transformations
Intensity-level slicing
Thresholding
a)Brightness Manipulation
 Point processing is very useful in the brightness manipulation of an image.
 The brightness is associated with each pixel in an image. To increase or
decrease the brightness of an image, a constant value can be added or
subtracted from each and every pixel of the image.
 To increase the brightness of an image f(x,y), the operation is:
g  x, y   f  x, y   c
 To decrease the brightness of an image f(x,y), the operation is:

g  x, y   f  x, y   c
where c is a constant and represents the value to be added or subtracted to
change the brightness of an image.
a)Brightness
ThisManipulation
operation can be performed in MATLAB®, using functions similar to:

a = imread(‘filename’);
b = a + 30; (to increase the brightness by a factor of 30)
b = a – 30; (to decrease the brightness by a factor of 30)
figure,
imshow (b);
a)Inverse
Transformation
This transformation is also known as Image negative.
This transformation reverses the intensity levels of an
image at all pixels.
Dark is converted into bright and bright is converted
into dark.
This transformation is obtained by subtracting the value
at each pixel from the maximum pixel value and is
g  x , y 
represented as: max . pixel value  f  x , y 
Inverse transformation is useful in those applications
where there is a need to highlight image details
embedded into dark regions of an image, in particular
In MATLAB, an image negative can be obtained
using a function sequence for a maximum
image intensity value of 256:

a = imread(‘filename’);
b = 256-a;
figure,
imshow (b);
Contrast Manipulation
Point processing operations can also be used to
manipulate the contrast information of an image.
In this process, the range of pixel luminance values is
changed.
Contrast manipulation of an image f(x,y) can be
g  x, y   f  x, y   c
represented as:

where c is the contrast manipulation factor.

A value greater than 1 increases the contrast and


expands the range of luminance
Contrast Manipulation
In MATLAB, it can be done using a function
sequence:
a=imread(filename);
b=rgb2gray(a);
c=b*.20;
figure, imshow(c);
d=b*5;
figure, imshow(d)
Log
 These transformations are non-linear gray level
Transformations
transformations and are of the form:

g  x, y  c log 1  f  x, y 
where c is the
 This transformation increases the range of gray level
values in the output image.
 The lower grey level values are spread out.
 The input image, having a narrow range of low
intensity values, is converted into an image that has
a wider range of output
levels.
 To achieve the opposite effect, an inverse log
Power-law
Power-law transformation is given by:
Transformations
 
g  x, y  
Power-law c  f  x, y 
transformations are also known as gamma
transformation, due to exponent γ.
 By changing the values of γ, a family of
transformations is obtained.
 When the value of γ is less than 1, the image appears
to be dark and when it is greater than 1, the image
appears bright.
 If c = γ = 1, the power-law transformation is converted
into an identity transformation.
 Many devices, e.g., a monitor used for input and
Power-law
Transformations
 The process used in order to reduce the effect of
power-law response
phenomena is called gamma correction.
 For example, on some monitors, the image displayed
is darker than the actual input image.
 In such cases, there is a need to correct this effect
before displaying the image.
 Gamma correction changes the intensity of the
displayed image as well as the ratios of red to green to
blue in a color image.
 Gamma correction is very important in the case of the
images used
Piecewise-linear
 Piecewise-linear transformations are those non-linear
transformations
transformations which are applied to input image
pixels based on some criteria.
 For the same image pixels, the transformation applied
can be different.
 There are various piecewise linear image
transformations.

Some are:
 Intensity-level slicing
 Thresholding
Intensity-level slicing
 To highlight a specific range of gray values, intensity level
slicing can be
used.
 If in any application there is a need to emphasize on a set
of a particular
range of intensities, instead of the all values, then
intensity-level slicing is very useful.
 Although intensity-level slicing can be applied in various
ways, the most frequently used ways are
(i) Highlighting the intensities in a defined range [A,B]
and reducing
all other intensities to a lower level
(ii) Highlighting the intensities in a defined range [A,B]
Thresholding
 A thresholding transformation is used to extract a
part of an image based on an intensity value.
 In this transformation a threshold value has to be
defined.
 The pixels having intensity greater than the
defined threshold value are set to a particular
value and others are left unchanged, or vice-versa.
0 ;if f x,y  >threshold value
g  x, y  
 255 ;otherwise
where f(x,y) is the input image and g(x,y) is the
transformed image.
Mask Processing
 If neighbors are also considered in processing the
value of the pixel, the processing is called Mask
Processing.
 The pixels having intensity greater than the value
of the pixel, the processing is called Mask
Processing
Mask Processing
 The pixel, being processed along with the neighbors
considered, defines a mask.
 This mask is moved from pixel to pixel over the whole
image in order to generate the processed image.
 This mask in spatial domain is also called window,
kernel or template.
 In general, the mask is taken of size nxn, where n is an
odd number.
 The center pixel of the mask, called the origin,
coincides with the pixel being operated at a particular
instance, while processing.
 For a non-symmetric mask, any pixel of the mask can
Mask Processing
 The processed value is calculated as follows:

(a) A mask of size 3x3. (b) During processing the


dark shaded pixel of the mask coincides with the
pixel being processed.
In general, spatial filtering can be defined as:

where for a mask of size mxn, m = 2a + 1 and n = 2b +


1, a and b are positive integers. x and y are varied so
that each pixel in w visits every pixel in f.
Mask processing filters can be divided into two
categories:
 Smoothing filters (Low pass filters) and
 Sharpening filters (High pass filters).
a) Smoothing filters remove small details of an image and
bridge small gaps in lines or curves.
b) Smoothing is used for blurring and for noise reduction in an
image.
c) Smoothing filters are also known as averaging filters, because
these filters
The smoothing filterreplace the weight
assigns more pixel intensity bypixel
to the center theinaverage of to its
comparison
otherintensity
neighbors.values of its neighbors.
And among neighbors, a higher weight is assigned to top, down, left and right
neighbors than to diagonal neighbors.

A smoothing box filter of size


a) A spatial averaging filter is the filter with all the same
coefficients is called box filter.
b) In a box filter, equal weight is assigned to all pixel intensities.

MATLAB function for this is imboxfilt.


The size of the mask can be
described in the function. The
MATLAB code is of the form:
clc
A weighted average filter of size 3x3. clear all
close all
a=imread(‘jordan.png’);
b=rgb2gray(a);
c=imboxfilt(b,9);
figure, imshow(c)
a) Smoothing Non-Linear Filters
 In smoothing non-linear filters, the intensity value of a pixel
is replaced by the value of the pixel of the filter area
selected by some ranking.
 A very common non-linear smoothing filter is the median
filter, in which the value of a pixel is replaced by the median
intensity value of all pixels’ intensity in the neighborhood of
the pixel.
 To implement a median filter, initially all the values on the
defined neighborhood, including the pixel being processed,
are sorted.
 The median value is selected, and the pixel being processed
is assigned this median intensity value.
 Median filters are very useful in removing salt-and-pepper
noise, in which the intensity of certain pixels is very different
a) Smoothing Non-Linear Filters
 By applying median filters, these noisy isolated pixels are
replaced by the value more like the neighbors, as extreme
values are not considered in this filter.
 In a 3x3 neighborhood, the 5th largest value is the median
and that value will be used for replacement at the pixel
being processed.
 These filters are very useful in those applications, where the
brightest low
Gaussian or darkest pixels in
pass filter: the imagelow
A Gaussian arepass
required
filter to
is be
filtered as:
described
where σ is standard
deviation of the distribution
Arithmetic Operations
 Various simple arithmetic operations, such as addition, subtraction
and multiplication, can be performed on the images.
Image Addition
Using simple addition,two images f(x,y) and g(x,y) can be combined
in order to get a new image h(x,y):
h(x,y) = f(x,y)+g(x,y)

Image subtraction
The difference in two images f(x, y) and g(x, y) can be found by
image subtraction, that can be performed as:
h(x, y) = f(x, y)–g(x, y)
Image Multiplication
Image multiplication is used to extract a region of interest from
an image.
If a user is interested in a specific part of an image, then it can be
isolated by multiplying the region of interest by 1 and the
remaining part by 0.
As a result, only the region of interest will contain image
information and the remaining part will become 0 or black
Logical Operations
Logical operations AND, OR and NOT can be applied on binary images.
AND and OR operations are binary operations, so two images are
required in order to perform these operations, while the NOT operation is
a unary operation and, hence, can be performed on a single image.
These logical operations are similar to set operations.
 The AND operation corresponds to Intersection,
 The OR operation corresponds to Union and
 The NOT operation corresponds to Complement set operation

If A and B are two sets, then logical operations are defined as:
A AND B = set of all elements which are common to set A and set B
A OR B = set of all elements which are either in set A or in set B
NOT A = set of all elements which are not in A
Geometric Operations
There are a number of geometric transformations that can be applied to a digital
image.
These transformations are unary transformations, i.e., these transformations
are applied on a single image.
These transformations are:
 Translation
 Rotation
 Cropping
Translation
Translation of an input image f (x, y) with respect to its Cartesian origin,
producing an output image g(x`, y`), is defined as:
g(x`, y` ) = f(x + ∆x, y + ∆y),
where ∆x and ∆y are displacements in x and y directions, respectively.
Translation is an affine transformation, i.e., it preserves straight lines and planes.
MATLAB uses the imtransform function for translation of an image.

Rotation
Rotation of an image is a spatial transformation in which an image is rotated at a
specified angle. Rotation is also an affine geometric transformation
Cropping
An image can be cropped to a specified angle, i.e., the part of an image can be cut.
In MATLAB, the imcrop tool facilitates cropping of an image to a specified
rectangle interactively.
Translation
Translation is used to improve visualization of an image, but
Applied as a preprocessor in applications where registration of two or more images
is required.

Rotation
Rotation is most commonly used to improve the visual appearance of an image,
Applied as a preprocessor in applications where directional operators are involved.

Scaling: Performs a geometric transformation that can be used to


shrink or zoom the size of an image.
Image reduction, commonly known as subsampling, is performed by
replacement (of a group of pixel values by one arbitrarily chosen
pixel, a11 or a22, value from within this group) or by interpolating
between pixel values in a local neighborhood.
Image zooming is achieved by pixel replication or by interpolation
% Image Rotation
y=imrotate(x,45);
figure ; imshow(y)
z = imrotate(y,-45) ;
figure ; imshow(z)
[size(x) ; size(y) ; size(z) ]

% Image Scaling (resizing)


zz = imresize(x,[r/2 c/2]);
figure ; imshow(zz)
axis on
zz = imresize(x,[r/4 c/4]);
figure ; imshow(zz)
axis on
clear all; close all
x=imread('jordan Hosseaa.png');
imshow(x)
[r,c,s] = size(x) ;
% Image Translation
y1 = x(1:r,1:c,:) ;
y2 = x(1:r,c+1:c,:) ;
y3 = x(r+1:r,1:c,:) ;
y4 = x(r+1:r,c+1:c,:) ;
yy = [ y4 y3 ; y2 y1 ];
figure ; imshow(yy)
axis on
clear all; close all
x=imread('jordan Hosseaa.png');
imshow(x)
[r,c,s] = size(x) ;
% Gaussian Noise
xn1 =
imnoise(x,'gaussian',0,0.1);
figure ; imshow(xn1)
xn2 = imnoise(x,'gaussian',0,1);
figure ; imshow(xn2)
%Salt & Pepper Noise
xn3 = imnoise(x,'salt &
pepper',0.05);
figure ; imshow(xn3)
xn4 = imnoise(x,'salt &
clear all;
close all
x=imread('jordan
Hosseaa.png');
imshow(x)
[r,c,s] = size(x) ;
% Motion Blur
f1 = fspecial('motion',15,45)
;
%figure ; surfl(f1)
xb1 = imfilter(x,f1);
figure ; imshow(xb1)
Mathematical tool for image analysis
In objective analysis, the original image is considered as perfect and all changes are
considered as occurrences of distortion, irrespective of
their appearance.
The most commonly used measures for assessing image distortion
due to noise distortion are the
i)Mean Absolute Error (MAE),
ii)Mean Square Error (MSE) and
iii)Signal to Noise Ratio (SNR).
Mathematical tool for image analysis

Mean Absolute Error can be defined as:

Here, P(m, n) represents the original image and


P’(m, n) is the distorted image

Mean Square Error (MSE). It can be defined as:


Mathematical tool for image analysis

SNR is another popular distortion measure. It is defined as:

where, σ2 represents the variance of the image having M × N


pixels. It is defined as:
What is the value of the central pixel(marked by a round) if it is smoother by a 3
X 3 box filter
 1 2 3  
 2 4 5  3
3 box filter
    ? 
   
 3 4 3  
Input Output
image image
Justify the statement “median filter is an effective tool to minimize salt and
pepper noise” through simple illustration
Salt refers to high gray level value and pepper refers to low gray-level value.
Random occurrence of white and black values is generally termed salt and
pepper noise.
Consider image corrupted by salt- and pepper noise is given below
Justify the statement “median filter is an effective tool to minimize salt and
pepper noise” through simple illustration
Salt refers to high gray level value and pepper refers to low gray-level value.
Random occurrence of white and black values is generally termed salt and pepper
noise.
Consider image corrupted by salt- and pepper noise is given below

24 22 33 25 32 24 255 is equivalent to salt noise


34 255 24 0 26 23
0 is equivalent to pepper noise
Then a 3 x3 median filter is applied to the input
23 21 32 31 28 26
image
Step 1 Apply 3 × 3 median filter to the pixel value
255.

Step 1a Arrange the pixel values in the ascending order:

21, 22, 23, 24, 24, 32, 33,


34, 255
Step 1b Compute the median of the pixel value
255:

The median value is computed to be 24.


Step 2 Apply a 3 × 3 median filter to the pixel value ‘24’.

You might also like