Title: CIS303 Advanced Forensic Computing
1CIS303Advanced Forensic Computing
2Point Operations
- Point operations are operations performed on
individual pixels in an image. These operations
are often based on the image histogram For this
course we are interested in point operations for
improving image quality and basic segmentation by
thresholding, and image arithmetic. - Sub topics
- Linear point operations
- Non linear point operations
- The grey level histogram.
- Histogram operations
- Thresholding
- Colour thresholding
- Image arithmetic
3The point operation
- A point operation uses a function f to map each
pixel in the input image to the corresponding
pixel in the output image. - A linear point operation uses a simple linear
mapping function
Pout(x,y) a.Pin(x,y) b
4Consequences of the choice of a and b
Pout(x,y) a.Pin(x,y) b
- If a 1 and b 0 the image is simply copied
- If agt1 the contrast is increased and if a lt 1 the
contrast is decreased. - If a 1 and b is non zero then the output image
has the grey levels moved up or down. Thus the
entire image becomes darker or lighter. - If a lt 0 then light areas become dark and dark
areas become light. In effect the image is
complemented.
5Examples
6Non linear point operations
- In terms of improving the visible information
content in an image a non linear point operation
is often more effective. - On of the most useful is the gamma correction.
- If gamma (?) lt 1, the mapping is weighted towards
higher (brighter) output values and if it is gt 1,
it is weighted towards lower (darker) values. - See the imadjust function in the IPT.
7gamma correction example
8Logarithmic transformation
- Logarithmic and contrast-stretching
transformations are basic tools for dynamic range
manipulation. - Logarithmic transformations can be implemented
using the expression - g c log(1 double(f))
- Where c is a constant
- One of the principal aims is to compress dynamic
range e.g. a Fourier spectrum might have values
in the range 0 106 or higher. - When displayed on a monitor linearly scaled to 8
bits, the high values dominate the display,
resulting in lost visual detail for the lower
intensity values in the spectrum - By computing the log, a dynamic range of 106 is
reduced to approximately 14. - This is illustrated in the next slide.
9Logarithmic plot of Fourier spectrum (taken from
DIPUM)
10Contrast stretching
- The function compresses the input levels lower
than m into a narrow range of dark levels in the
output image. - Similarly, it compresses the values above m into
a narrow band of light levels in the output. - The result is an image of higher contrast. The
limiting case is shown above right the output
is a binary image and the function is called
thresholding (used for image segmentation). - An example is shown on the next slide.
11Contrast-stretching of bone scan image (taken
from DIPUM)
12The grey level histogram
- An image histogram records the frequency of each
grey level in an image. - MatLab provides the imhist function to
accomplish this - imhist(J,n)
- where J is the image and n is the number of
bins. For a greyscale image if n is omitted the
value 256 (0 to 255) is assumed. - If you need to work with the actual values of the
histogram you can use the extended format - counts,x imhist(J,n)
- where counts is the number of counts in each bin
whose value is given in the vector x
13Displaying histograms in MatLab
- function ShowHistogram
- To demonstrate image histograms
- P imread(house.jpg')
- figure('color','w')
- subplot(2,2,1), imshow(P)
- subplot(2,2,2), imhist(P,256)
- Q imread(house_gamma.jpg')
- subplot(2,2,3), imshow(Q)
- subplot(2,2,4), imhist(Q,256)
14Example
15Other ways of displaying a histogram (DIPUM)
16Histogram equalisation
- A very effective and simple way of bringing out
detail in an image is carry out histogram
equalisation. The objective is to produce an
equal number of pixels in all grey levels.
Mathematically the operation can be characterised
by - Thus the output image is obtained by mapping each
pixel with level rj into the corresponding pixel
with level sk, by calculating the cumulative sum
of the probability density function (PDF) of the
input image up to each level. - Note that the above equation assumes black
white is in the range 0 1. Multiply by a scale
factor of 255 to make the range 0 255. - See Gonzalez and Woods for a more mathematical
explanation.
17Example of histogram equalisation
18MatLab implementation
- MatLab provides the histeq function to perform
the histogram equalisation operation. We can
modify the previous version of ShowHistogram to
demonstrate this - Additional code is to show the cumulative
histograms.
- function ShowHistogram
- To demonstrate image histograms
- P imread(house.jpg')
- figure('color','w')
- subplot(2,2,1), imshow(P)
- Q T histeq(P)
- subplot(2,2,2), plot(0255,T)
- subplot(2,2,3), imshow(Q)
- C X imhist(Q)
- subplot(2,2,4), plot(0255,cumsum(C)/sum(C))
19Illustration of the cumulative sum
20Further example of equalisation (DIPUM)
21The histeq function
- In the demonstration programme I have used the
function in the form - Q,T histeq(P)
- where P is the input image, Q the output image
and T the cumulative histogram of P used in the
equalisation process that is the term - Histogram equalisation is not always successful
in revealing image content and more subtle
variants can be invoked such as histogram
matching where the histogram profile of the
input image is matched to either a standard
profile (user defined) or to the profile of a
second image. MatLab allows this through a simple
extension of the syntax above - Q,T histeq(P,hgram)
22Histogram matching example (DIPUM)
Specified histogram (top)
Histogram equalisation
23Contrast-Limited Adaptive Histogram Equalization
(CLAHE).
- Histogram equalisation does generally improve the
information visibility but it applies the same
equalisation function to the whole image. - CLAHE breaks the image into tiles and
determines the best function to use for each
tile. - The result will be an image which shows
artificial boundaries between tiles and so an
interpolation scheme is used to smooth the pixel
intensities between tiles. - The MatLab function that performs CLAHE is
adapthisteq - Two of the simpler forma of the function are
- Q adapthisteq(P)
- which defaults all parameters and
- Q adapthisteq(P,numTiles,m n)
- which declares an analysis using m by n tiles.
COMM2J Vision Intelligent Robots 2005
24Result of using CLAHE
25Grey level thresholding
- If the histogram of a grey level image shows
distinct features which can be associated with an
object in the scene we can threshold the scene
by picking out the pixels which represent the
feature. - The process is known as segmentation in which a
logical test is applied to each pixel of the
input image and the output image is binary with
1 representing true and 0 a false. - Typical test conditions on the image pixel p(x,y)
might be - p(x,y)gt160
- 50ltp(x,y)lt100
26Example of grey level thresholding
27Colour thresholding
- The concept of thresholding can easily be
extended to colour images where we can adopt one
of the strategies - Select the colour plane with the greatest
contrast between the object and the rest of the
scene and then apply grey level thresholding. - Select a region of the colour space which
differentiates the object. This is easiest if the
region has the same volume geometry as the space
(e.g. a cube in RGB colour space). However any
volume shape can be used if appropriate.
28Example of best plane selection using RGB
colours
29Example of best plane selection using HSV
colours
30Example of region selection in RGB space
31Image arithmetic - subtraction
-
32Image subtraction code
- function vansubtract
- function vansubtract Takes an RGB image and
- segments out the vehicle content
- 1. Read images
- a imread('whitevan.jpg')
- b imread('street.jpg')
- 2. Make sure 2 images are the same size
- m,n size(a)
- b imresize(b,m,n)
- 3. Subtract images, resize and display
- cimsubtract(a,b)
- imresize(c,0.75)
- imshow(c)
33Tutorial
- Investigate the following Matlab commands (use
the Matlab Help information) imadjust imhist
histeq adapthisteq. - Create M-files to demonstrate the Matlab code
given on these slides. Try playing altering the
gamma correction of the house.jpg image and
adjust the gamma parameter to see what happens. - Write an M-file to demonstrate region selection
in RGB space, using the lego.jpg image. - Write an M-file to theshold the image bean.jpg.
To do this you should first convert the image to
greyscale (for example by selecting the best
colour channel can this be done
automatically?). - Then manipulate the histogram data returned using
the imhist IPT function. Now investigate the
built-in function graythresh. Find out how it
works (by looking on the web) and compare its
performance with your algorithm.
34Links
- Try the following links with some interesting
Java Applets - http//www.s2.chalmers.se/research/image/Java/appl
ets_list.htm - http//homepages.inf.ed.ac.uk/rbf/HIPR2/
COMM2J Vision Intelligent Robots 2005