Title: CIS303 Advanced Forensic Computing
1CIS303Advanced Forensic Computing
2Image Analysis
- Introduction
- Greyscale images
- Colour images (RGB, HSV, indexed)
- Image representation in MatLab
3Useful texts
- Digital Image Processing
- Rafael Gonzalez Richard Woods, Prentice Hall,
(2e) 2002. - ISBN 0-13-094650-8
- Covers the material in some depth, with
significant mathematical content. - There is also a Matlab-specific version Digital
Image Processing Using Matlab - Digital Image Processing, a practical
introduction using Java - Nick Efford, Addison Wesley, 2000. ISBN
0-201-59623-7 - A very readable introduction which covers most of
the material in a non-mathematical way.
4Image Basics The pixel
- The basic unit of a digital image is the the
pixel. - The pixel shape in computer images is normally
square or rectangular but, in principle, any
cross section or size is possible. For example
newspaper images are base on a variable sized
pixel. - The variable size is to compensate for having
only two colours !
5Digital image representation
- An image can be defined as a 2D finction f(x, y),
where x and y are spatial coordinates, and the
amplitude of f at any pair of coordinates (x, y)
is called the intensity of the image at that
point. - An image is said to be of size (M x N), where
(0,0) is the top left hand corner, (0,1) the next
pixel in the top row etc. - In Matlabs IPT, however, we denote (x, y) by (r,
c) and coordinates start at (1,1) (r ranges from
1 to M, c from 1 to N)
6Greyscale images
- The standard greyscale image uses 256 shades of
grey from 0 (black) to 255 (white).
7Images as matrices
- The coordinate system given on a previous slide
lead to the following representation of a digital
image in Matlab - The following data classes are used in Matlab to
represent images
8Colour images
- With colour images the situation is more complex.
For a given number of pixels, considerably more
data is required to represent the image and more
than one colour model is used. - We will consider only three of the more common
colour models - RGB (Red Green Blue)
- HSV (Hue Saturation Value)
- Indexed
- The other type of image we will frequently use is
the binary image. This consists of two colours
only black (0) and white (1).
9Red Green Blue (RGB) model
- This can be thought of as a simple extension of
the grey scale model where each pixel is composed
of three colours red, green and blue each
represented by a digital range of 0 to 255
leading to 16,777,216 (16 million) colours. - All available colours can be represented on the
colour cube - Instead of a single array of numbers we can now
think of three array planes or for an m x n image
an m x n x 3 array
10Hue Saturation Value (HSV) model
- Whilst the RGB model is very simple it does not
correspond very well with our intuitive
understanding of colour. It is more natural to
think in terms of - Hue The colour starting with Red (0 degrees)
- Saturation The purity of the colour. A
saturation of 1 is the pure colour and 0 is
white. - Value Is a measure of intensity with 0 as black
and 1 as white. - The combination of saturation value are often
referred to as the tint of the colour. - A simple transform will convert colour
specification from RGB to HSV and vice versa
(rgb2hsv, hsv2rgb)
11Indexed colour maps
- Both RGB and HSV colour specifications are very
memory intensive. For example a 768 x 1024 RGB
image requires 2.36 Mbytes. Often double
precision numbers are used in place of single
byte values in which case the above image
requires 9.44 Mbytes. - An alternative is to use a small fixed range of
colours (e.g. 256) and make the entries in the
image array simply single byte pointers to the
colour table.
Abstract from the image array
Abstract from the colour table
12Machine vision
- Machine vision - giving robots sight
- Potentially the most powerful sensor is
artificial vision - Also called computer vision and machine vision.
- Machine vision is already used for both robotic
non-robotic applications. - Machine vision is a complex subject encompassing
a number of different fields including optical
engineering, analogue video processing, digital
image processing, pattern recognition and
artificial intelligence and computer graphics. - The basic process is modelled on the mammalian
eye/brain interaction.
13Image processing stages
- Once an image has been captured we need to make
some sense of it. Image processing involves three
main actions - image enhancement,
- image analysis
- image understanding.
- Image processing can be a complex and difficult
operation and is still very much a research
field.
14Description of stages
- Image enhancement To remove unwanted artefacts
such as noise, distortion, and non-uniform
illumination from the image. - Image analysis Converts the input image data
into a description of the scene. - Image understanding Classify each object and
attempt to generate a logical decision based on
the content of the image (e.g. the red object is
at location x,y,z, or reject the component, or
this is not a sheep, or there is an
intruder"). - Examples of successful machine vision in
industrial robotics - Parts location
- Pick and place
- Parts recognition
- Parts inspection
- We will be more concerned in this module with
image processing as applied to AI robotics
(localisation and navigation).
15Applications of machine vision
16MatLab image formats 1
- MatLab uses the following main data
representations for its image classes - uint8 Unsigned 8-bit integers in the range 0
to 255. - uint16 Unsigned 16-bit integers in the range 0
to 65,535. - double Double precision numbers, by convention
in the range 0 to 1 for images. Requires 4 bytes
per pixel. - logical values are 0 or 1, used in binary
images. - Only a very limited amount of data processing can
be done with the UINT image classes. In fact with
UINT16 you are virtually limited to displaying
the image. Their function is to store images more
efficiently on disk files. Almost all your work
will be done with double precision images.
17MatLab image formats 2
- Working with images almost always requires using
double precision arithmetic. The following MatLab
IPT functions convert between image classes and
types - im2uint8, im2uint16 convert input to uint8,
uint16 - mat2gray converts any class double to double in
range 0,1 - im2double converts data to double in range 0,1
- im2bw converts input to logical.
- Example
- h uint8(25 50 128 200)
- Performing the conversion g im2double(h)
yields the result - g
- 0.0980 0.1961
- 0.4706 0.7843
18Loading displaying an images
- We can load an image with the imread function and
display an image with the imshow function. - imread
- A imread(filename, fmt)
- X,map imread(filename, fmt)
- In the first form the image is read into the
array A and the format of the image fmt is
optional. - In the second form the image is read into the
array X and the associated indexed map into map
scaled 0 to 1 as double. - imshow
- imshow(A)
- imshow(X,map)
- imshow has many other formats
19Displaying the individual colours
function colourdisplay To demonstrate the
splitting of an image into its primary colours A
imread('monar.jpg') subplot(2,2,1)
imshow(A) title('RGB image') Redimage
A(,,1) subplot(2,2,2) imshow(Redimage) title(
'Red image') Greenimage A(,,2) subplot(2,2,3
) imshow(Greenimage) title('Green
image') Blueimage A(,,3) subplot(2,2,4)
imshow(Blueimage) title('Blue image')
20Splitting an RGB image
21Images types supported by MatLab
- The image processing toolbox supports four basic
image types - Indexed images
- Intensity images (MatLabs name for greyscale
images) - Binary images
- RGB full colour images
- MatLab allows easy conversion between image types
using - rgb2hsv to convert to a HSV image
- rgb2gray to convert to a grey scale image (note
American spelling). - rgb2ind to convert to an indexed image
- You should check the details in the MatLab help
files. - With the addition of the following line (and a
variable name change) the previous example can be
used to display the HSV components. - B rgb2hsv(A)
22HSV image components
23Inspecting and recording image colours
- improfile which will reveal the colour intensity
profile along a line defined on the image. - Simply placing improfile on a line will allow you
to interactively explore the colour profile
alternatively using - c improfile(I,xi,yi,n)
- will record in the array c the RGB values from
image I with line segment end points defined by
xi yi using n equally spaced points - pixval which will interactively record the
location and colour components of each pixel as
you move a cursor across the image. - impixel returns the RGB values for a specified
pixel.
24Example of using pixval
25Example of using improfile
26Tutorial
- Familiarise yourself with the machines log on,
run Matlab, have a look at the Matlab Help
information for the Image Processing Toolbox
(IPT) and the Matlab demos. - Re-create the M-files and Matlab code shown as
part of this lecture. - Load the image flower.jpg. Note what happens when
you try and display it. Now re-size it by an
appropriate amount and display it again. Save it
to disk (flower2.jpg) and compare the size of the
saved file with the original. - Load the image bean.jpg. Look at the various
colour channels and consider which channel would
be most appropriate if you were about to create
an image processing pipeline which could separate
the beans from the background. Write an M-file to
display the RGB image and each of its (R-, G-,
B-) components, and the HSV image and each of its
(H-, S-, V-) components. Repeat with flower.jpg. - (From a previous assignment, in which students
were asked to write a program to automatically
count the numbers of large and small beans).