digital image processing...wavelet transform of the image, not directly process the intensity values...
TRANSCRIPT
Xiangyu Yu
School of Electronic and Information Engineering,
South China University of Technology, P. R. China
DIGITAL IMAGE PROCESSING(IN THE AI ERA)
LECTURE 5INTENSITY TRANSFORMATION
INTRODUCTION
Images may suffer from the following degradations: Poor contrast due to poor illumination or finite sensitivity of the imaging device
Electronic sensor noise or atmospheric disturbances leading to broad band noise
Aliasing effects due to inadequate sampling
Finite aperture effects or motion leading to spatial
3/17/2020 DIGITAL IMAGE PROCESSING 3
IMAGE ENHANCEMENT DEFINITION
Image Enhancement: is the process that improves the quality of the image for a specific application
Enhancement : To “improve” the usefulness of an image by using some transformation on the image.
Often the improvement is to help make the image “better” looking, such as increasing the intensity or contrast.
The principal objective of enhancement is to process an image so that the result more suitable than the original image for a specific application
–Image enhancement is subjective (problem/application oriented)
3/17/2020 DIGITAL IMAGE PROCESSING 4
IMAGE ENHANCEMENT
3/17/2020 DIGITAL IMAGE PROCESSING 5
The reasons for doing this include:
Highlighting interesting detail in images
Making images more visually appealing
Enhance otherwise hidden information
Filter important image features
Removing noise from images
Discard unimportant image features
PREPROCESSING
Why we need image enhancement? Un-necessary noises
Defects caused by image acquisition
Uneven illumination: non-uniform
Lens: blurring object or background
Motion : blurring
Distortion: geometric distortion caused by lens
registration
3/17/2020 DIGITAL IMAGE PROCESSING 6
7
INTUITIVELY
3/17/2020 DIGITAL IMAGE PROCESSING
IMAGE ENHANCEMENT EXAMPLES
Ima
ges ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2002)
3/17/2020 DIGITAL IMAGE PROCESSING 8
IMAGE ENHANCEMENT EXAMPLES (CONT…)
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2002)
3/17/2020 DIGITAL IMAGE PROCESSING 9
IMAGE ENHANCEMENT EXAMPLES (CONT…)
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2002)
3/17/2020 DIGITAL IMAGE PROCESSING 10
IMAGE ENHANCEMENT EXAMPLES (CONT…)
Ima
ges ta
ken
fro
m G
on
zale
z &
Wo
od
s,
Dig
ita
l Im
ag
e P
rocessin
g (
20
02
)
3/17/2020 DIGITAL IMAGE PROCESSING 11
IMAGE ENHANCEMENT METHODS
There are two broad categories of image enhancement techniques
Spatial Domain Methods (Image Plane)Techniques are based on direct manipulation of pixel(the intensity values) in an image(on the image plane itself)
Point-based processing
Mask-based processing (neighbor-based processing) (spatial filters)
Frequency Domain MethodsTechniques are based on modifying the transform coefficients of the Fourier transform or wavelet transform of the image, not directly process the intensity values of the image plane
Frequency domain filters
Combination MethodsThere are many enhancement techniques based on various combinations of methods from the first two categories
For the moment we will concentrate on techniques that operate in the spatial domain
3/17/2020 DIGITAL IMAGE PROCESSING 12
13
IMAGE ENHANCEMENT
Two main categories: Point operations: pixel’s gray value is changed without the knowledge of its
surroundings. E.g. thresholding.
Neighborhood processing: The new gray value of a pixel is affected by its small neighborhood. E.g. smoothing.
The intensity (or gray-level) transformations & spatial filtering approaches for neighborhood processing, or spatial convolution.
We start with point operations.
3/17/2020 DIGITAL IMAGE PROCESSING
CONTENTS
In this lecture we will look at image enhancement point processing techniques: What is point processing?
Negative images
Thresholding
Logarithmic transformation
Power law transforms
Grey level slicing
Bit plane slicing
3/17/2020 DIGITAL IMAGE PROCESSING 14
A NOTE ABOUT GRAY LEVELS
So far when we have spoken about image gray level values we have said they are in the range [0, 255]
Where 0 is black and 255 is white
There is no reason why we have to use this range
The range [0,255] stems from display technologies
For many of the image processing operations grey levels are assumed to be given in the range [0.0, 1.0]
3/17/2020 DIGITAL IMAGE PROCESSING 15
IMAGE TRANSFORMATIONS
Transformation is a function. It maps one set to another set after performing some operations.
• Digital Image Processing system performs
the transformation.3/17/2020 DIGITAL IMAGE PROCESSING 16
SPATIAL DOMAIN METHODS
As indicated previously, the term spatial domain refersto the aggregate of pixels composing an image. Spatialdomain methods are procedures that operate directlyon these pixels. Spatial domain processes will bedenoted by the expression:
g(x,y) = T [f(x,y)]
Where f(x,y) in the input image, g(x,y) is the processedimage and T is as operator on f, defined over someneighborhood of (x,y)
In addition, T can operate on a set of input images.
G3E-P.1273/17/2020 DIGITAL IMAGE PROCESSING 17
G3C-P.62
The principal approach for defining spatial neighborhoods about a point (x, y) is to use a square or rectangular region centered at (x, y).
The center of the pixel is moved from pixel to pixel starting, say , at the top, left, corner, and, it moves, it encompasses different neighborhoods. Operator T is applied at each location (x, y) to yield the output, g, at that location. Only the pixels in the neighborhood computing the values of g at (x, y).
3/17/2020 DIGITAL IMAGE PROCESSING 18
POINT PROCESSING(INTENSITY TRANSFORMATION)
s(x,y) = T{ r(x,y)}
Transformed
Gray LevelOriginal
Gray Level
Transformation
Function
>>imadjdemo
>>imadjust
3/17/2020 DIGITAL IMAGE PROCESSING 19
BASIC CONCEPTS
Pixel/point operation: Neighborhood of size 1x1: g depends only on f at (x,y)
T: a gray-level/intensity transformation/mapping function
Let r = f(x,y) s = g(x,y)
r and s represent gray levels of f and g at (x,y)
Then s = T(r)
Local operations:g depends on the predefined number of neighbors of f at (x,y)
Implemented by using mask processing or filtering
Masks (filters, windows, kernels, templates) :
a small (e.g. 3×3) 2-D array, in which the values of the
coefficients determine the nature of the process
3/17/2020 DIGITAL IMAGE PROCESSING 20
NEIGHBORHOOD ABOUT A POINT
3/17/2020 DIGITAL IMAGE PROCESSING 21
Ima
ges ta
ken
fro
m G
on
zale
z &
Wo
od
s,
Dig
ita
l Im
ag
e P
rocessin
g (
2018)
neighbourhood about a point (x0,y0)in an image. The neighborhoodis moved from pixel to pixel in the image to generate an output image.
0 0x ,y
G3E-P.127G3C-P.63
EXAMPLES OF ENHANCEMENT TECHNIQUES
Larger neighborhoods allow considerable more flexibility. The general approach isto use a function of the values of f in a predefined neighborhood of (x,y) todetermine the value of g at (x,y).
One of the principal approaches in this formulation is based on the use of so-calledmasks (also referred to as filters)
So, a mask/filter: is a small (say 3X3) 2-D
array, such as the one shown in the
figure, in which the values of the mask
coefficients determine the nature of the
process, such as image sharpening.
Enhancement techniques based on this
type of approach often are referred to as
mask processing or filtering.3/17/2020 DIGITAL IMAGE PROCESSING 22
MASK PROCESSING FILTERING
3/17/2020 DIGITAL IMAGE PROCESSING 23
g(x,y) = T [ f(x,y) ]
f(x,y) g(x,y)
1
0
0
-1
0
0
0
0
0
T
OPERATION ON THE SET OF IMAGE-PIXELS
3/17/2020 DIGITAL IMAGE PROCESSING 24
6 8 2 0
12 200 20 10
3 4 1 0
6 100 10 5
(Operator: Div. by 2)
OPERATION ON THE SET OF ‘NEIGHBORHOODS’ N(X,Y) OF EACH PIXEL
3/17/2020 DIGITAL IMAGE PROCESSING 25
6 8 2 0
12 200 20 10
226
6 8
12 200
(Operator: sum)
OPERATION ON A SET OF IMAGES F1,F2,…
3/17/2020 DIGITAL IMAGE PROCESSING 26
6 8 2 0
12 200 20 10
5 5 1 0
2 20 3 4
11 13 3 0
14 220 23 14
(Operator: sum)
-27-
INTENSITY TRANSFORMATION / POINT OPERATION
Map a given gray or color level u to a new level v
Memory-less, direction-less operation
output at (x, y) only depend on the input intensity at the same point
Pixels of the same intensity gets the same transformation
Does not bring in new information, may cause loss of information
But can improve visual appearance or make features easier to detect
input gray level u
outp
ut
gra
y le
ve
l
v
3/17/2020 DIGITAL IMAGE PROCESSING
INTENSITY TRANSFORMATION / POINT OPERATION
Two examples we already saw
Color space transformation
Scalar quantization
3/17/2020 DIGITAL IMAGE PROCESSING
Grey-level transformation functions (also called, intensity functions), are considered the simplest of all image enhancement techniques.
Point processes are the simplest of basic image processing operations.
A point operation takes a single input image into a single output image in such a way that each output pixel's gray level depends only upon the gray level of the corresponding input pixel.
Thus, a point operation cannot modify the spatial relationships within an image.
Point operations transform the gray scale of an image.
POINT PROCESSING
DIGITAL IMAGE PROCESSING 293/17/2020
POINT PROCESSING
The simplest spatial domain operations occur when the neighbourhood is simply the pixel itself(when the neighborhood in of the smallest possible size 1 x 1)
In this case, the value of g at (x, y) depends only on the intensity of f at that point, and T is referred to as a intensity(gray-level transformation)function or a point processing operation (or mapping)
Point processing operations take the form
s = T (r)
where s refers to the processed image pixel value and r refers to the original image pixel value(before processing), both at any corresponding point (x, y) in the images.
When dealing with color images, the term intensity is used to denote a color image component in certain color spaces.
G3E-P.1283/17/2020 DIGITAL IMAGE PROCESSING
G3C-P.63
Linear and nonlinear point operations
Examples:
Contrast Stretching
Image Negatives
Intensity-level Slicing
Bit-plane Slicing
Other Intensity Transformations
POINT OPERATIONS
DIGITAL IMAGE PROCESSING
POINT OPERATIONS
Point operations affect the way images occupy greyscale.
A point operation transforms an input image, producing an output image in which each pixel grey level is related in a systematic way to that of the corresponding input pixel.
Unchanged Stretch
Compress
Output
grey level
Inputgrey level
A point operation will
never alter the spatial
relationships within an
image.
3/17/2020 DIGITAL IMAGE PROCESSING 32
EXAMPLES OF POINT OPERATIONS
Input
Output
t Input
Output
t t1 2
(a) Threshold (b) Window Threshold
Input
Output
(c) Contrast Stretch
Input
Output
(d) Contrast Compression
Input
Output
(e) Combination
Input
Output
(f) Contouring
3/17/2020 DIGITAL IMAGE PROCESSING 33
POINT PROCESSING,GRAY-LEVEL TRANSFORMATION FUNCTION
Point processing techniques (e.g. contrast stretching, thresholding)
3/17/2020 DIGITAL IMAGE PROCESSING 34
Contrast Stretching Thresholding
G3E-P.128
The function shown in fig. (a) is called contrast stretching transformation. Because
it compresses the input levels lower than m, into narrow range of dark levels in
output image. Similarly greater than m into a narrow band of light levels in the
output. And fig. (b) is thresholding transformation for binary image.
Ima
ges ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
G3C-P.64
EXAMPLES OF ENHANCEMENT TECHNIQUES
Contrast Stretching:
If T(r) has the form as shown in the figure below, the effect of applying thetransformation to every pixel of f to generate the corresponding pixels in g would:
Produce higher contrast than the original image, by:
Darkening the levels below m in the original
image
Brightening the levels above m in the
original image
So, Contrast Stretching: is a simple image
enhancement technique that improves the contrast
in an image by ‘stretching’ the range of intensity values it contains to span adesired range of values. Typically, it uses a linear function
3/17/2020 DIGITAL IMAGE PROCESSING 35
MATLAB IMPLEMENT FOR CONTRAST STRETCHING
The notation introduced here for fig (a) has the form:
Where r represents the intensities of the input image, s thecorresponding intensity value in the output image, and E controls theslope of the function. The equation is implemented in MATLAB foran entire image as:
g = 1./(1+(m./(double(f)+eps)).^E)
3/17/2020 36DIGITAL IMAGE PROCESSING
EXAMPLE CODE IN MATLAB FOR CONTRAST STRETCHING
I=imread('tire.tif'); I2=im2double(I); m=mean2(I2) contrast1=1./(1+(m./(I2+eps)).^4); contrast2=1./(1+(m./(I2+eps)).^5); contrast3=1./(1+(m./(I2+eps)).^10); imshow(I2) figure,imshow(contrast1) figure,imshow(contrast2) figure,imshow(contrast3)
3/17/2020 37DIGITAL IMAGE PROCESSING
3/17/2020 DIGITAL IMAGE PROCESSING 38
Umbaugh2E-P.397
Gray-Level Stretching with Clipping. (a) The mapping equation, stretches between 80
and 180, and clips at both ends, (b) the original image, (c) the modified image with the
stretched gray levels
Images
take
n fr
om
Sco
tt E
Um
baug
h, D
igital Im
age P
roce
ssin
g a
nd A
naly
sis:
Hum
an
and
Com
put
er
Vis
ion
Applic
ations
with
CV
IPto
ols
(3e) (2
017)
3/17/2020 DIGITAL IMAGE PROCESSING 39
Gray-Scale Modification. Hidden in the dark, in brightness values between 28 and
75, are image details that appear when that particular gray-level range is stretched
Umbaugh3E-P.396
Images
take
n fr
om
Sco
tt E
Um
baug
h, D
igital Im
age P
roce
ssin
g a
nd A
naly
sis:
Hum
an
and
Com
put
er
Vis
ion
Applic
ations
with
CV
IPto
ols
(3e) (2
017)
EXAMPLES OF ENHANCEMENT TECHNIQUES
Thresholding
Is a limited case of contrast stretching, it produces a two-level (binary) image.
Some fairly simple, yet powerful, processing approaches can beformulated with grey-level transformations. Because enhancement atany point in an image depends only on the gray level at that point,techniques in this category often are referred to as point processing.
g(x,y) =L if f(x,y) > t,
0 else
t = ‘threshold level’
3/17/2020 DIGITAL IMAGE PROCESSING 40
POINT PROCESSING EXAMPLE: THRESHOLDING
Thresholding transformations are particularly useful for segmentation in which we want to isolate an object of interest from a background or contrast enhancement.
s = 1.0
0.0 r <= threshold
r > threshold
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2002)
3/17/2020 DIGITAL IMAGE PROCESSING 41
3/17/2020 DIGITAL IMAGE PROCESSING 42
Original
image
3/17/2020 DIGITAL IMAGE PROCESSING 43
SOME BASIC INTENSITY TRANSFORMATION FUNCTIONS
There are many different kinds of grey level transformations
Three of the most common are shown here Linear function
Negative/Identity transformation
Logarithmic function
Log/Inverse log transformation
Power-law function
nth power/nth root transformation
3/17/2020 DIGITAL IMAGE PROCESSING 44
-45-
BASIC INTENSITY TRANSFORM FUNCTIONS
monotonic, reversible
compress or stretch certain range of gray-levels
3/17/2020 DIGITAL IMAGE PROCESSING
Some basic intensity transformation functions. Each curve was scaled independently so that all curves would fit in the same graph. Our interest here is on the shapes of the curves, not on their relative values.
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
G3E-P.130
G3C-P.65
3/17/2020 DIGITAL IMAGE PROCESSING 46
R6E-P.274R6C-P.176Im
ag
es ta
ken fro
m R
uss, T
he I
mage P
rocessin
g H
andbook(6
e)
(2011)
LINEAR FUNCTIONS
Identity Function
Output intensities are identical to input intensities
This function doesn’t have an effect on an image, it was included in the graph only for completeness
Its expression:
s = r
3/17/2020 DIGITAL IMAGE PROCESSING 47
LINEAR FUNCTIONS
Image Negatives (Negative Transformation) The negative of an image with gray level in the range [0, L-1], where L = Largest value in an image, is obtained by using the negative transformation’s expression:
s = L – 1 – r
Which reverses the intensity levels of an input image, in this manner produces the equivalent of a photographic negative.
The negative transformation is suitable for enhancing white or gray detail embedded in dark regions of an image, especially when the black area are dominant in size
G3E-P.130-1313/17/2020 DIGITAL IMAGE PROCESSING
G3C-P.64
IMAGE NEGATIVES
Let the range of gray level be [0, L-1], then
s =T(r) = (L - 1) - r
Function reverses the order from black to white so that the intensity of the output image decreases as the intensity of the input increases.
Used mainly in medical images and to produce slides of the screen.
3/17/2020 DIGITAL IMAGE PROCESSING 49
Input gray level
Out
put
gra
y leve
l
T(f)= L-1-r
POINT PROCESSING EXAMPLE: NEGATIVE IMAGES
Negative images are useful for enhancing white or grey detail embedded in dark regions of an image, esp. when black areas are dominant in size Note how much clearer the tissue is in the negative image of the mammogram below
s = L-1 - rOriginal
Image
Negative
Image
Imag
es ta
ken fro
m G
on
zale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
3/17/2020 DIGITAL IMAGE PROCESSING 50
G3E-P.131
Small
lesion
(a) A digital mammogram. (b) Negative image obtained (Image (a) Courtesy of General Electric Medical Systems.)
G3C-P.65
NEGATIVE TRANSFORMATION
Original Negative
s = (L – 1) – r
3/17/2020 DIGITAL IMAGE PROCESSING 51
IMAGE NEGATIVES EXAMPLES
52
3/17/2020 DIGITAL IMAGE PROCESSING
the appearance of photographic negatives
Gray Scale (256 levels) Negative
IMAGE NEGATIVES EXAMPLES(CONT..)
3/17/2020 DIGITAL IMAGE PROCESSING 53
IMAGE NEGATIVES EXAMPLES(CONT..)
3/17/2020 DIGITAL IMAGE PROCESSING
R6E-P.274R6C-P.175
Figure X-ray image of a human hand, viewed as a positive and a negative.
Imag
es ta
ken fro
m R
uss, T
he I
mage P
rocessin
g H
andbook(6
e)
(2011)
IMAGE NEGATIVES EXAMPLES(CONT..)
3/17/2020 DIGITAL IMAGE PROCESSING
IMAGE NEGATIVES EXAMPLES(CONT..)
3/17/2020 56DIGITAL IMAGE PROCESSING
PYTHON CODE FOR THE IMAGE INVERSE
import math
import scipy.misc
import numpy as np
from scipy.misc.pilutil import Image
# opening the image and converting it to grayscale
im = Image.
open('../Figures/imageinverse_input.png').
convert('L')
# im is converted to an ndarray
im1 = scipy.misc.fromimage(im)
# performing the inversion operation
im2 = 255 - im1
# im2 is converted from an ndarray to an image
im3 = scipy.misc.toimage(im2)
# saving the image as imageinverse_output.png in
# Figures folder
im3.save('../Figures/imageinverse_output.png')
3/17/2020 DIGITAL IMAGE PROCESSING 57
Chityala-P.92
IMAGE SCALING
3/17/2020 DIGITAL IMAGE PROCESSING 58
s =T(r) = a.r (a is a constant)
LOGARITHMIC TRANSFORMATIONS
The general form of the log transformation:
s = c log (1+r)
Where c is a constant, and r ≥ 0 Log curve maps a narrow range of low intensity values in theinput image into a wider range of the output levels. The oppositeis true for higher values of input levels.
Used to expand the values of dark pixels in an image whilecompressing the higher-level values.
It compresses the dynamic range of images with large variationsin pixel values.
The inverse log transformation performs the oppositetransformation
G3E-P.1313/17/2020 DIGITAL IMAGE PROCESSING 59
G3C-P.64-65
Properties of log transformations
–For lower amplitudes of input image the range of gray levels is expanded
–For higher amplitudes of input image the range of gray levels is compressed
Application:
This transformation is suitable for the case when the dynamic range of a processed image far exceeds the capability of the display device (e.g. display of the Fourier spectrum of an image)
Also called “dynamic-range compression / expansion”
3/17/2020 DIGITAL IMAGE PROCESSING
LOGARITHMIC TRANSFORMATIONS
LOGARITHMIC TRANSFORMATIONS (CONT…)
Log functions are particularly useful when the input grey level values may have an extremely large range of values
In the following example the Fourier transform of an image is put through a log transform to reveal more detail
s = log(1 + r)
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
3/17/2020 DIGITAL IMAGE PROCESSING 61
G3E-P.132
Pixel
values
dynamic
range=[
0 -
1.5×106
]
From the
range 0-
to the
range 0
to 6.2
6105.1
(a) Fourier spectrum displayed as a grayscale image. (b) Result of applying the log transformation with c = 1. Both images are scaled to the range [0, 255].
G3C-P.65-66
LOGARITHMIC & CONTRAST-STRETCHING TRANSFORMATIONS:
Logarithmic & contrast-stretching transformations are basic tools for dynamic range manipulations. Logarithmic transformations are implemented using the expression:
g = c * log(1+double(f))
where c is a constant. The shape of this transformation is similar to the gamma curve with the low values set at 0 and the high values set to 1 on both scales. Note, however, that the shape of gamma curve is variable, whereas the shape of the log function is fixed.
mat2gray(g) function brings the values to the range [0,1]
im2uint8 brings them to the range [0, 255]
3/17/2020 DIGITAL IMAGE PROCESSING 62
One of the basic principal uses of the log transformations is to compress dynamic range. When performing a logarithmic transformation, it is often desirable to bring the resulting compressed values back to the full range of display. For 8 bits, the easiest way to do this in MATLAB is with the statement:
gs = mat2gray(g);
If image is of double data class:
gs = im2uint8(mat2gray(f));
Log Transformation g=mat2gray(log(1+double(f)));
g=im2uint8(mat2gray(log(1+double(f)));
imshow(g)
3/17/2020 DIGITAL IMAGE PROCESSING 63
DIGITAL IMAGE PROCESSING3/17/2020 64
Figure Applying exponential and logarithmic point operators.
Images
take
n fr
om
Nix
on
& A
gua
do, Featu
re E
xtr
act
ion
& Im
age P
roce
ssin
g f
or
Com
put
er
Vis
ion(3
e) (2
012)
N3E-P.89
LOG TRANSFORM
im = imread(‘lena.png’)
a = abs(fftshift(fft2(double(im))));
c = log(1+double(im)); c = range_normalize(c);
b = log(1+a); b=b/max(b(:));
lena
FFT(lena)stretch:
u 2 [0, .5] v 2 [0, .59]
compress:u 2 [.5, 1] v 2 [.59, 1]
3/17/2020 DIGITAL IMAGE PROCESSING
I=imread('tire.tif');
imshow(I)
I2=im2double(I);
J=1*log(1+I2);
J2=2*log(1+I2);
J3=5*log(1+I2);
figure, imshow(J) figure, imshow(J2) figure, imshow(J3)
3/17/2020 DIGITAL IMAGE PROCESSING 66
PYTHON CODE FOR LOG TRANSFORMATION
import scipy.misc
import numpy, math
from scipy.misc.pilutil import Image
# opening the image and converting it to grayscale
a = Image.open('../Figures/bse.png').convert('L')
# a is converted to an ndarray
b = scipy.misc.fromimage(a)
# b is converted to type float
b1 = b.astype(float)
# maximum value in b1 is determined
b2 = numpy.max(b1)
# performing the log transformation
c = (255.0*numpy.log(1+b1))/numpy.log(1+b2)
# c is converted to type int
c1 = c.astype(int)
# c1 is converted from ndarray to image
d = scipy.misc.toimage(c1)
# saving d as logtransform_output.png
# in Figures folder
d.save('../Figures/logtransform_output.png')
3/17/2020 DIGITAL IMAGE PROCESSING 67
Chityala-P.49
INVERSE LOG TRANSFORMATIONS
Do opposite to the Log Transformations
Used to expand the values of high pixels in an image while compressing the darker-level values.
3/17/2020 DIGITAL IMAGE PROCESSING 68
G3E-P.131
LOG TRANSFORMATIONS
69
InvLog Log
3/17/2020 DIGITAL IMAGE PROCESSING
POWER-LAW TRANSFORMATIONS
Power-law transformations have the basic form of:
s = c.rᵞ
Where c and ᵞ are positive constants
Map a narrow range of dark input values into a wider range of output values or vice versa.
G3E-P.1323/17/2020 DIGITAL IMAGE PROCESSING 70
G3C-P.66
POWER-LAW(GAMMA)TRANSFORMATIONS
Varying γ gives a whole family of curves
Different transformation curves are obtained by varying ᵞ (gamma)
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
3/17/2020 DIGITAL IMAGE PROCESSING 71
G3E-P.132-133
Plots of the gamma equation γs = cr for various values of g (c = 1 in all
cases). Each curve was scaled independently so that all curves would fit in the same graph. Our interest here is on the shapes of the curves, not on their relative values. G3C-P.66
WHAT GAMMA TO USE?
>1
<1?
3/17/2020 DIGITAL IMAGE PROCESSING
POWER-LAW (GAMMA) TRANSFORMATIONS
For γ < 1: Expands values of dark pixels, compress values of brighter pixels
For γ > 1: Compresses values of dark pixels,expand values of brighter pixels
If γ=1 & c=1: Identity transformation (s = r)
A variety of devices (image capture, printing, display) respond according to power law and need to be corrected
Gamma (γ) correction
The process used to correct the power-law response phenomena
3/17/2020 DIGITAL IMAGE PROCESSING 73
POWER-LAW TRANSFORMATION
power-law response functions in practice
CRT Intensity-to-voltage function has
¼ 1.8~2.5
Camera capturing distortion with c = 1.0-1.7
Similar device curves in scanners, printers, …
power-law transformations are also useful for general purpose contrast manipulation
3/17/2020 DIGITAL IMAGE PROCESSING
POWER-LAW TRANSFORMATION
3/17/2020 DIGITAL IMAGE PROCESSING 75
GAMMA CORRECTION
Many of you might be familiar with gamma correction of computer monitors
Problem is thatdisplay devices do not respond linearly to different intensities
Can be corrected using a log transform
Ima
ges ta
ken fro
m G
on
zale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2002)
4.0
3/17/2020 DIGITAL IMAGE PROCESSING 76
Monitor5.2
G3E-P.134G3C-P.67
POWER-LAW TRANSFORMATIONS
Variety of devices used for image capture, printing and display respond according to apower law. The process used to correct this power-law response phenomena is calledgamma correction.
For example, cathode ray tube (CRT) devices have an intensity-to-voltage response thatis a power function, with exponents varying from approximately 1.8 to 2.5. Withreference to the curve for g=2.5 in Fig. 3.6, we see that such display systems wouldtend to produce images that are darker than intended. This effect is illustrated in Fig.3.7. Figure 3.7(a) shows a simple gray-scale linear wedge input into a CRT monitor. Asexpected, the output of the monitor appears darker than the input, as shown in Fig.3.7(b).
Is important if displaying an image accurately on a computer screen
in this case is straightforward. All we need to do is preprocess the input image beforeinputting it into the monitor by performing the transformation. The result is shown in Fig.3.7(c).When input into the same monitor, this gamma-corrected input produces an outputthat is close in appearance to the original image, as shown in Fig. 3.7(d).
G3E-P.1333/17/2020 DIGITAL IMAGE PROCESSING 77
G3C-P.67
POWER-LAW TRANSFORMATIONS
make linear input appear linear on displays
method: calibration pattern + interactive adjustment
3/17/2020 DIGITAL IMAGE PROCESSING 78
s = r2.5
r = [1 10 20 30 40 210 220 230 240 250 255]
s( = 2.5) = [0 0 0 1 2 157 176 197 219 243 255]
s( =.4) = [28 70 92 108 122 236 240 245 249 253 255]
example calibration chart
• Cathode ray tube (CRT) devices have an intensity-to-voltage response that is a power function, with varying from 1.8 to 2.5
• The picture will become darker.
• Gamma correction is done by preprocessing the image before inputting it to the monitor with s = cr1/
Monitor
Monitor
Gammacorrection
= 2.5
=1/2.5 = 0.4
3/17/2020 DIGITAL IMAGE PROCESSING
G3E-P.13379
G3C-P.67
Figure (a) Image of a human retina. (b) Image as it appears on a monitor with a gamma setting of 2.5 (note the darkness). (c) Gamma-corrected image. (d) Corrected image, as it appears on the same monitor (compare with the original image). (Image (a) courtesy of the National Eye Institute, NIH)
Ima
ges ta
ken fro
m G
on
zale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
3/17/2020 DIGITAL IMAGE PROCESSING 80
POWER-LAW TRANSFORMATIONS
3/17/2020 DIGITAL IMAGE PROCESSING 81
Automatic Selection
EXAMPLE: GAMMA TRANSFORMATIONS
G3E-P.135
c=1
= 0.4 c=1
= 0.3
c=1
= 0.6
4.0 3.0
6.01
DIGITAL IMAGE PROCESSING
The images to the right show a magnetic resonance (MR) image of a fractured human spine
Different curves highlight different detail
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
s = r 0.6
s = r 0
.4
3/17/2020G3C-P.68
POWER LAW EXAMPLE
3/17/2020 DIGITAL IMAGE PROCESSING 83
G3E-P.135
In addition to gamma correction, power-law transformations re useful for general-purposecontrast manipulation.
See figure 3.8
Low r: wash-out in the background (Fig. 3.8r=0.3)High r: enhance a wash-out appearance (Fig. 3.9 r=0.5 areas are too dark)
(a) Magnetic resonance image (MRI) of a fractured human spine (the region of the fracture is enclosed by the circle). (b)–(d) Results of applying the transformation in Eq. (3-5) with c = 1and γ = 0.6, 0.4,
and 0.3, respectively. (Original image courtesy of Dr. David R. Pickens, Department of Radiology and Radiological Sciences, Vanderbilt University Medical Center.)
POWER LAW EXAMPLE (CONT…)γ = 0.6
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0 0.2 0.4 0.6 0.8 1
Old Intensities
Tra
nsfo
rmed
In
ten
sit
ies
3/17/2020 DIGITAL IMAGE PROCESSING 84
POWER LAW EXAMPLE (CONT…)γ = 0.4
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0 0.2 0.4 0.6 0.8 1
Original Intensities
Tra
nsfo
rmed
In
ten
sit
ies
3/17/2020 DIGITAL IMAGE PROCESSING 85
POWER LAW EXAMPLE (CONT…)γ = 0.3
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0 0.2 0.4 0.6 0.8 1
Original Intensities
Tra
nsfo
rmed
In
ten
sit
ies
3/17/2020 DIGITAL IMAGE PROCESSING 86
EXAMPLE: GAMMA TRANSFORMATIONS
G3E-P.136
c=1
= 3
c=1
= 5
c=1
= 4
0.3
0.50.4
1
DIGITAL IMAGE PROCESSING
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
An aerial photo of a runway is shown
This time power law transforms are used to darken the image
Different curves highlight different detail
s = r 3.0
s = r 4
.0
3/17/2020G3C-P.68
POWER LAW EXAMPLE
3/17/2020 DIGITAL IMAGE PROCESSING 88
G3E-P.136
Another illustration of Power-law transformation
Figure (a) Aerial image. (b)–(d) Results of applying the transformation in Eq. (3-5) with γ=3.0,4.0 and 5.0 respectively. (c=1 in all cases.) (Original image courtesy of NASA.)G3C-P.68
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2008)
POWER LAW EXAMPLE (CONT…)
γ = 5.0
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0 0.2 0.4 0.6 0.8 1
Original Intensities
Tra
nsfo
rmed
In
ten
sit
ies
3/17/2020 DIGITAL IMAGE PROCESSING 89
EFFECT OF GAMMA ON CONSUMER PHOTOSL0
2.2L0
1/2.2L0
3/17/2020 DIGITAL IMAGE PROCESSING
PYTHON CODE FOR POWER LAW TRANSFORMATION
import math, numpyimport scipy.miscfrom scipy.misc.pilutil import Image# opening the image and converting it to grayscalea = Image.open('../Figures/angiogram1.png').convert('L')# a is converted to an ndarrayb = scipy.misc.fromimage(a)# gamma is initializedgamma = 0.5# b is converted to type floatb1 = b.astype(float)# maximum value in b1 is determinedb3 = numpy.max(b1)# b1 is normalizedb2 = b1/b3# gamma-correction exponent is computedb3 = numpy.log(b2)*gamma# gamma-correction is performedc = numpy.exp(b3)*255.0# c is converted to type intc1 = c.astype(int)# c1 is converted from ndarray to imaged = scipy.misc.toimage(c1)# displaying the image d.show()
3/17/2020 DIGITAL IMAGE PROCESSING 91
Chityala-P.95-96
POINT PROCESSING
0 L-1
L-1
0
0 L-1
L-1
0r
s
r
s
r1 r2
s1
s2
>>imadjdemo
>>imadjust
3/17/2020 DIGITAL IMAGE PROCESSING 92
FUNCTION IMADJUST
Function imadjust is the basic IPT tool for intensity transformations of gray scale images, it has the following syntax:
g= imadjust(f, [low_in high_in, low_out high_out], gamma)
This function maps the intensity values in image f to new values in g, such that values between low_in and high_in map to values between low_out and high_out.
3/17/2020 DIGITAL IMAGE PROCESSING 93
GME-P.66-67
The parameter gamma specifies the shape of the curve that maps the intensity values in f to create g. If gamma is less than 1, the mapping is weighted towards higher (brighter) output values. If gamma greater than 1, the mapping is weighted towards lower (darker) output values. If it is omitted from the function argument, gamma defaults to 1.
3/17/2020 DIGITAL IMAGE PROCESSING 94
GME-P.67
Negative image, obtained using the command
>>g1=imadjust(f,[0,1],[1,0]);
This process, which is the digital equivalent of obtaining a photographic negative, is
particularly useful for enhancing white or gray detail embedded in a large, predominantly
dark region.
3/17/2020 DIGITAL IMAGE PROCESSING 95
GME-P.67
The negative of an image can be obtained also with IPT function imcomplement
>> g=imcomplement(f)
Expanding the gray scale region between 0.5 and 0.75 to the full [0,1] range:
>> g2=imadjust(f,[0.5 0.75], [0 1]);
This type of processing is useful for highlighting an intensity band of interest.
>> g3=imadjust(f,[ ],[ ],2);
produces a similar result by compressing the low end and expanding the high end of the gray scale.
3/17/2020 DIGITAL IMAGE PROCESSING 96
GME-P.67-68
PIECEWISE LINEAR TRANSFORMATION FUNCTIONS
log, gamma … closed-form functions on [0,L] can be more flexible
Rather than using a well defined mathematical function we can use arbitrary user-defined transforms
The images below show a contrast stretching linear transform to add contrast to a poor quality image
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
3/17/2020 DIGITAL IMAGE PROCESSING 97
G3E-P.138G3C-P.68-69
PIECEWISE-LINEAR TRANSFORMATION FUNCTIONS
Principle Advantage: Some important transformations can be formulated only as a piecewise function.
Principle Disadvantage: Their specification requires more user input that previous transformations
•Advantage The form of piecewise functions can be arbitrary complex over the previous
functions
•Disadvantage• Require considerably more user input
G3E-P.1373/17/2020 DIGITAL IMAGE PROCESSING 98
PIECEWISE-LINEAR TRANSFORMATIONS
•Type of Transformations•Contrast stretching
• Expands the range of intensity levels in an image so that it spans the full intensity range of the recording medium or display device.
• Intensity-level slicing
• Highlighting a specific range of intensities in an image often is of interest.
•Bit-plane slicing
3/17/2020 99
G3E-P.137-139DIGITAL IMAGE PROCESSING
One of the simplest piecewise linear functions is a contrast-stretching transformation, which is used to enhance the low contrast images.
Goal: Increase the dynamic range of the gray levels for low contrast images
Low-contrast images can result from–poor illumination
–lack of dynamic range in the imaging sensor
–wrong setting of a lens aperture during image acquisition
–wrong shutter speed
3/17/2020 DIGITAL IMAGE PROCESSING
G3E-P.137
CONTRAST STRETCHING
-101-
CONTRAST STRETCHING
)( T
21
2
1
0 L-1
1s
2s
3sL-1
Contrast stretching is a process that
expands the range of intensity levels in
an image
so that it spans the full intensity range of
the recording medium or display
device.
Contrast-stretching transformations
increase the contrast between the
darks and the lights
Stretch the over-concentrated gray-levels
Piece-wise linear function, where the slope
in the stretching region is greater than 1.
3/17/2020 DIGITAL IMAGE PROCESSING
G3E-P.137G3C-P.69
CONTRAST STRETCHING
Figure shows a typical transformation used for contrast stretching.
The locations of (r1,s1) and (r2,s2) control the shape of the transformation function. If r1= s1 and r2= s2 the transformation is a linear function and produces no changes in gray levels.
If r1=r2, s1=0 and s2=L-1, the transformation becomes a thresholding function that creates a binary image.
Intermediate values of (r1,s1) and (r2,s2) produce various degrees of spread in the gray levels of the output image, thus affecting its contrast.In general, r1≤r2 and s1≤s2 is assumed, so the function is always increasing.
3/17/2020 DIGITAL IMAGE PROCESSING 102
G3E-P.137
G3C-P.69
CONTRAST STRETCHING
Figure 3.10(b) shows an 8-bit image with low contrast.
Fig. 3.10(c) shows the result of contrast stretching, obtained by setting (r1, s1) = (rmin, 0) and (r2, s2) = (rmax,L-1) where rmin and rmax denote the minimum and maximum gray levels in the image, respectively. Thus, the transformation function stretched the levels linearly from their original range to the full range [0, L-1].
Finally, Fig. 3.10(d) shows the result of using the thresholding function defined previously, with r1=r2=m, the mean gray level in the image.
3/17/2020 DIGITAL IMAGE PROCESSING 103
G3E-P.138DIGITAL IMAGE PROCESSING
G3C-P.69
CONTRAST STRETCHING EXAMPLE
3/17/2020 DIGITAL IMAGE PROCESSING
G3E-P.138
Contrast stretching. (a) Piecewise linear transformation function. (b) A low-contrast electron microscope image of pollen, magnified 700 times. (c) Result of contrast stretching. (d) Result of thresholding. (Original image courtesy of Dr.Roger Heady, Research School of Biological Sciences, Australian National University, Canberra, Australia.)
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
105G3C-P.69
3/17/2020 DIGITAL IMAGE PROCESSING 106
CONTRAST STRETCHING
Example 1
For image with intensity range [50 - 150]
What should (r1,s1) and (r2,s2) be to increase the dynamic range of the image to [0 - 255]?
3/17/2020 DIGITAL IMAGE PROCESSING 107
r
s
PYTHON CODE FOR CONTRAST STRETCHING TRANSFORMATION
import math, numpyimport scipy.miscfrom scipy.misc.pilutil import Image# opening the image and converting it to grayscaleim = Image.open('../Figures/hequalization_input.png').convert('L')# im is converted to an ndarrayim1 = scipy.misc.fromimage(im)# finding the maximum and minimum pixel valuesb = im1.max()a = im1.min()print a,b# converting im1 to floatc = im1.astype(float)# contrast stretching transformationim2 = 255*(c-a)/(b-a)# im2 is converted from an ndarray to an imageim3 = scipy.misc.toimage(im2)# saving im3 as contrast_output.png in# Figures folderim3.save('../Figures/contrast_output2.png')
3/17/2020 DIGITAL IMAGE PROCESSING 108
Chityala-P.105
INTENSITY-LEVEL SLICING
Purpose: To highlight a specific range of intensities in an image (e.g. to enhance certain features).
Display a high value of all gray levels in the range of interest and a low value for all other gray levels : produce a binary image
Two approaches:
Display high value for range of interest, low value else(binary image) (‘discard background’)
Display high value for range of interest(brighten the desired range of gray levels), original value else (‘preserve background’)
Applications:
Enhancing specific features, s.t. masses of water in satellite images
Enhancing flows in X-ray images
3/17/2020 DIGITAL IMAGE PROCESSING 109
G3E-P.137-138
INTENSITY-LEVEL SLICING
This technique is used to highlight a specific range of gray levels in a givenimage. It can be implemented in several ways, but the two basic themes are:
One approach is to display a high value for all gray levels in the range ofinterest and a low value for all other gray levels. This transformation, shown inFig 3.11 (a), produces a binary image.
The second approach, based on the transformation shown in Fig 3.11 (b),brightens the desired range of gray levels but preserves gray levelsunchanged.
Fig 3.11 (c) shows a gray scale image, and fig 3.11 (d) shows the result ofusing the transformation in Fig 3.11 (a).
3/17/2020 DIGITAL IMAGE PROCESSING 110
Brighten the desired range of gray levels, but preserves the background and gray level tonalities (Fig. 3.11)
The higher order bits (especially the top four) contain the majority of the visually significant data
(a) This transformation function highlights range [A,B] and reduces all other intensities to a lower level. (b) This function highlights range [A,B] and leaves other intensities unchanged.Im
ag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
G3E-P.138
INTENSITY-LEVEL SLICING
3/17/2020 DIGITAL IMAGE PROCESSINGG3C-P.69
3/17/2020
Highlight the major blood
vessels and study the
shape of the flow of the
contrast medium (to detect
blockages, etc.)
Measuring the actual flow
of the contrast medium as
a function of time in a
series of images
G3E-P.138-139DIGITAL IMAGE PROCESSING
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
(a) Aortic angiogram. (b) Result of using a slicing transformation of the type illustrated in Fig. 3.11(a), with the range of intensities of interest selected in the upper end of the gray scale. (c) Result of using the transformation in Fig. 3.11(b), with the selected range set near black, so that the grays in the area of the blood vessels and kidneys were preserved. (Original image courtesy of Dr. Thomas R. Gest, University of Michigan Medical School.)
G3C-P.70
• (a) transformation highlights range [A,B] of gray level and reduces all others to a constant level
• (b) transformation highlights range [A,B] but preserves all other levels
3/17/2020 DIGITAL IMAGE PROCESSING 113
g2=imadjust(f,[0.5 0.75], [0.8 0.8]);
An image Result of using the
transformation in (a)
INTENSITY-LEVEL SLICING
DIGITAL IMAGE PROCESSING3/17/2020 114
Figure Intensity mappings.
Images
take
n fr
om
Nix
on
& A
gua
do, Featu
re E
xtr
act
ion
& Im
age P
roce
ssin
g f
or
Com
put
er
Vis
ion(3
e) (2
012)
N3E-P.87
DIGITAL IMAGE PROCESSING3/17/2020 115
Figure Applying the sawtooth operator.
N3E-P.88Images
take
n fr
om
Nix
on
& A
gua
do, Featu
re E
xtr
act
ion
& Im
age P
roce
ssin
g f
or
Com
put
er
Vis
ion(3
e) (2
012)
3/17/2020 DIGITAL IMAGE PROCESSING 116
Figure An original image with a full range of
brightness values and several examples of arbitrary
display transfer functions which expand or alter the
contrast in various parts of the range. The plot with
each image shows the stored pixel brightness values
on the horizontal axis and the displayed brightness on
the vertical axis. The histogram of each resulting
image is also shown. (a) The original image has a
transfer function that is the identity function, so that
actual stored brightnesses are displayed; (b) inverted
(negative) image; (c) increasing gamma brightens
middle grays, shows increased detail in shadows; (d)
reducing gamma darkens middle grays, shows
increased detail in bright areas; (e) increased contrast;
(f) decreased contrast; (g) banded or wrap-around;
(h) solarization.
R6E-P.272-273R6C-P.175Im
ag
es ta
ken fro
m R
uss, T
he I
mage P
rocessin
g H
andbook(6
e)
(2011)
BIT-PLANE SLICING
3/17/2020 DIGITAL IMAGE PROCESSING 117
Bit-plane slicing : Pixels are digital numbers composed of bits. For
example, the intensity of each pixel in an 256-level gray-scale image is
composed of 8 bits (i.e., one byte).
Instead of highlighting intensity-level ranges, we could highlight the
contribution made to total image appearance by specific bits.
This method is useful and used in image compression.
Bit-plane 7(most significant)
Bit-plane 0(least significant)
One 8-bit byte
G3E-P.139-140Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
G3C-P.70
BIT PLANE SLICING
Highlighting the contribution made to total image appearance by specific bits Assuming that each pixel is represented by 8 bits, the image is composed of 8 1-bit
planes.
Image is composed of eight 1-bit planes, ranging from bit-plane 0 for the least significant bit to bit plane 7 for the most significant bit.
Bit-plane 0 is the least significant bit, containing all the lowest order bits.
Bit-plane 7 is the most significant bit, containing all the highest order bits.
Plane 7 corresponds exactly with an image thresholded at gray level 128.
Each bit-plane is a binary image
Higher-order bits bits (top four) contain the majority of the visually significant data
Useful for analyzing the relative importance played by each bit of the image
3/17/2020 DIGITAL IMAGE PROCESSING 118
BIT PLANE SLICING
Often by isolating particular bits of the pixel values in an image we can highlight interesting aspects of that image
Higher-order bits usually contain most of the significant visual information
Lower-order bits containsubtle details
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
3/17/2020 DIGITAL IMAGE PROCESSING 119
G3E-P.140
Extracts the information of a single bitplane
G3C-P.70
BIT-PLANE SLICING
3/17/2020 DIGITAL IMAGE PROCESSING 120
255
138
30
65
12
201
183
111
85
1 1 1 1 1 1 1 1
0 1 0 1 0 0 0 1
1 1 1 1 1 0 0 0
1 0 0 0 0 0 1 0
0 0 1 1 0 0 0 0
1 0 0 1 0 0 1 1
1 1 1 0 1 1 0 1
1 1 1 1 0 1 1 0
1 0 1 0 1 0 1 0
MSBLSB
DIGITAL IMAGE PROCESSING
Bit-plane Slicing
3/17/2020 121
DEMO: A FRACTAL IMAGEIm
ag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2002)
BIT PLANE SLICING (CONT…)
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2002)
[10000000] [01000000]
[00100000] [00001000]
[00000100] [00000001]
2
7 6
45 3
1 0
3/17/2020 DIGITAL IMAGE PROCESSING 122
EIGHT BIT PLANES OF THE IMAGE
EXAMPLE
3/17/2020 123
G3E-P.140DIGITAL IMAGE PROCESSING
Ima
ges ta
ken
fro
m G
on
zale
z &
Wo
od
s,
Dig
ita
l Im
ag
e P
rocessin
g (
2008)
G3C-P.71
BIT PLANE SLICING (CONT…)
Ima
ges ta
ken
fro
m G
on
zale
z &
Wo
od
s,
Dig
ita
l Im
ag
e P
rocessin
g (
2008)
3/17/2020 DIGITAL IMAGE PROCESSING 124
G3E-P.140G3C-P.71
BIT PLANE SLICING (CONT…)
3/17/2020 DIGITAL IMAGE PROCESSING 125
G3E-P.140Ima
ges ta
ken
fro
m G
on
zale
z &
Wo
od
s,
Dig
ita
l Im
ag
e P
rocessin
g (
2008)
G3C-P.71
BIT PLANE SLICING (CONT…)
3/17/2020 DIGITAL IMAGE PROCESSING 126
G3E-P.140Ima
ges ta
ken
fro
m G
on
zale
z &
Wo
od
s,
Dig
ita
l Im
ag
e P
rocessin
g (
2008)
G3C-P.71
BIT PLANE SLICING (CONT…)
3/17/2020 DIGITAL IMAGE PROCESSING 127
G3E-P.140Ima
ges ta
ken
fro
m G
on
zale
z &
Wo
od
s,
Dig
ita
l Im
ag
e P
rocessin
g (
2008)
G3C-P.71
BIT PLANE SLICING (CONT…)
3/17/2020 DIGITAL IMAGE PROCESSING 128
G3E-P.140Ima
ges ta
ken
fro
m G
on
zale
z &
Wo
od
s,
Dig
ita
l Im
ag
e P
rocessin
g (
2008)
G3C-P.71
BIT PLANE SLICING (CONT…)
3/17/2020 DIGITAL IMAGE PROCESSING 129
G3E-P.140Ima
ges ta
ken
fro
m G
on
zale
z &
Wo
od
s,
Dig
ita
l Im
ag
e P
rocessin
g (
2008)
G3C-P.71
BIT PLANE SLICING (CONT…)
3/17/2020 DIGITAL IMAGE PROCESSING 130
G3E-P.140Ima
ges ta
ken
fro
m G
on
zale
z &
Wo
od
s,
Dig
ita
l Im
ag
e P
rocessin
g (
2008)
G3C-P.71
BIT PLANE SLICING (CONT…)
3/17/2020 DIGITAL IMAGE PROCESSING 131
G3E-P.140Ima
ges ta
ken
fro
m G
on
zale
z &
Wo
od
s,
Dig
ita
l Im
ag
e P
rocessin
g (
2008)
G3C-P.71
BIT PLANE SLICING (CONT…)
3/17/2020 DIGITAL IMAGE PROCESSING 132
G3E-P.140Ima
ges ta
ken
fro
m G
on
zale
z &
Wo
od
s,
Dig
ita
l Im
ag
e P
rocessin
g (
2008)
G3C-P.71
(a) An 8-bit grayscale image of size 837? 88 pixels. (b) through (i) Bit
planes 8 through 1, respectively, where plane 1 contains the least significant bit. Each bit plane is a binary image. Figure (a) is an SEM image of a trophozoite that causes a disease called giardiasis. (Courtesy of Dr. Stan Erlandsen, U.S. Center for Disease Control and Prevention.)
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
3/17/2020
DIGITAL IMAGE PROCESSING
133
Figure Image reconstructed from bit planes: (a) 8 and 7; (b) 8, 7, and 6; (c) 8, 7, 6, and 5.
Imag
es ta
ken fro
m G
onzale
z &
Woods,
Dig
ital Im
age P
rocessin
g (
2018)
3/17/2020 DIGITAL IMAGE PROCESSING 134
3/17/2020 DIGITAL IMAGE PROCESSING 135
Figure Decomposing an image into its bits
Images
take
n fr
om
Nix
on
& A
gua
do, Featu
re E
xtr
act
ion
& Im
age P
roce
ssin
g f
or
Com
put
er
Vis
ion(3
e) (2
012)
N3E-P.39
3/17/2020 DIGITAL IMAGE PROCESSING 136
3/17/2020 DIGITAL IMAGE PROCESSING 137
BP 7
BP 5
BP 0
3/17/2020 DIGITAL IMAGE PROCESSING 138
-139-
SLICING BITPLANES
Depend on relative importance of bits
How much to slice depend on image content
Useful in image compression, e.g. JPEG2000
3/17/2020 DIGITAL IMAGE PROCESSING
G3E-P.141
EXAMPLE
3/17/2020
G3E-P.141
Useful for compression.
Reconstruction is obtained by:
1
1
( , ) 2 ( , )N
n
n
n
I i j I i j
DIGITAL IMAGE PROCESSING
APPLICATION: CAMOUFLAGE
Pixels are digital numbers composed of bits.
The intensity of each pixel in an 256-level gray-scale image is composed of 8 bits.
Higher-order bits(top four) contain the majority of the visually significant data.
Lower-order bits(bottom four) contain a small minority of the visually significant data or contain random noise,we can consider they are redundant part of the image simply.
We can conduct image compression and data hiding in the lower-order bits(bottom four).
3/17/2020 DIGITAL IMAGE PROCESSING 141
THE 8-BIT PLANE OF A GRAYSCALE IMAGE
3/17/2020 DIGITAL IMAGE PROCESSING 142
Bit Plane 7 Bit Plane 6 Bit Plane 5 Bit Plane 4
Bit Plane 3 Bit Plane 2 Bit Plane 1 Bit Plane 0
IMAGE DISPLAY AFTER REMOVING BIT PLANE
3/17/2020 DIGITAL IMAGE PROCESSING 143
Original Removing 0 Removing 0,1 Removing 0-2
Removing 0-3 Removing 0-4 Removing 0-5 Removing 0-6
INFORMATION HIDING
A multidisciplinary theory and technology in one of the emerging technology.
Makes use of the senses of human sense organs on the digital signal redundancy, and image, voice source digital redundancy feature.
A message (called stay hidden messages or secret) hidden in another message (called cover message or carrier) in the transmission.
The carrier of information can be text such as TXT, HTML, PDF, voice, image, IP packet, etc.
3/17/2020 DIGITAL IMAGE PROCESSING 144
DISCUSS IMAGE REDUNDANCY SPACE
Below are the woman image and its partial matrix:
3/17/2020 DIGITAL IMAGE PROCESSING 145
DISCUSS IMAGE REDUNDANCY SPACE
The woman image and its partial matrix
after lower 4 bit plane removing:
3/17/2020 DIGITAL IMAGE PROCESSING 146
DISCUSS IMAGE REDUNDANCY SPACE
By contrast can be seen above:
Although every pixel values of the original image matrix has remove lower 4 bit plane (e.g., the first (1, 1) pixels), the image after removing bit plane in the visual gives a person not much change.
So what we can think is that lower 4 bit plane is redundant space of an image, we can try to hide a secret image in the lower 4 bit plane of original image, this is the basic theory of embedded images can be in disguise.
3/17/2020 DIGITAL IMAGE PROCESSING 147
DISCUSS IMAGE REDUNDANCY SPACE
To do:
Directly replace the lower 4 bit plane of the carrier image pixel value with the higher 4 bit plane of the secret image pixel value.
We select the lenna image (24-bit true color) as the carrier image and the woman image (gray scale) as the secret information image.
3/17/2020 DIGITAL IMAGE PROCESSING 148
149
EXTRACT IMAGE INFORMATION AND LAYER
%Extract woman and lenna image:
cover = imread(‘lenna.bmp');
data=cover;
msg=imread('woman.bmp' );
[row,col]=size(cover);
cover1=cover(:,:,1);
PS:
After layering, the R layer of
lenna image is used as carrier image.
lenna original image woman original image
lenna 's R layer image
Processing of Secret Image and Carrier Image
150
HANDLING 4 BIT PLANE IN CARRIER/SECRET IMAGE
%Zero setting of carrier image:
cover1=bitand(cover1,240);
%Zero setting of secret image:
takemsg4=bitand(msg,240);
%Move secret image's higher
4 bit plane to the right by 4 bits:
shiftmsg4=bitshift(takemsg4,-4);
lenna image removing woman image removing
lower 4 bit plane lower 4 bit plane
Move woman image's higher 4 bit plane
to the right by 4 bits
IMAGE HIDING AND SAVING
%Image hiding:
cover1=bitor(cover1,shiftmsg4);
%Image write and save:
data(:,:,1)=cover1;
imwrite(data, 'mix.bmp'');
151
Image of woman hidden behind the R layer of lenna
Final hidden image
152
EXTRACT SECRET IMAGE
%Extraction of secret image:
data=imread('mix.bmp');
[row,col]=size(data);
A=data(:,:,1);
%Extract the lower 4 bit plane
of the hidden:
imageA=bitand(A,15);
%Move the extracted 4 bit plane
left by 4 bits:
A=bitshift(A,4);
The extracted secret image
Effect Test
153
REVIEW OF ROBUSTNESS AND SECURITY
Disadvantage:weak robustness and poor security!
154
IMAGE SCRAMBLING
Scramble the information of image, for example,move pixel A to the position of pixel B, and pixel B to the position of pixel C...Transform it into a chaotic and unrecognizable image.
Scrambling is actually image encryption, scrambling images hidden as secret information can greatly improve the robustness of hidden carriers while improving system security.
Use hash scrambling for secret image before image hidden,this algorithm has the character of collision free and strong key control,while it is complex and slow.
Improvement
155
THE EFFECT OF HASH SCRABLING
Hash function generates a unique, fixed-length Hash code
for any length of information,the code can be viewed as the
"digital fingerprint" of the information.
156
ANTI - MALICIOUS ATTACK PERFORMANCE
157
LSB SUBSTITUTION
To do:
Replace the LSB of the carrier image with the secret information to be embedded.
Select l(m) pixels in carrier image according to the key k, if its LSB is the same as the information bit to be embedded, no change will be made.
Otherwise, replace the LSB of the original gray value with the secret information bit, while the high 7 bits remain unchanged, and the modified image is the secret image.
158
ALGORITHM PRINCIPLE
The seven high order planes of the original image and the LSB plane representing the secret information constitute the hidden image.
159
READ SECRET TEXT AND CARRIER IMAGE
%Read image and text:
cover = imread(‘lenna_gray.bmp');
ste_cover=cover;
ste_cover=double(ste_cover);
f_id=fopen(file,'r');
[msg,len_total]=fread(f_id,'ubit1');
PS:
msg represents the ASCII code of
secret text, (a→01100001)
while len_total represents bit length
of msg. (24 in this demo)
lenna gray image
secret text
Processing of
Secret Text and Carrier Image
160
GET SIZE OF CARRIER IMAGE
%Carrier image size:
[m,n]=size(ste_cover);
%Determine capacity:
if len_total>m*n
error('Embedded msg too large');
end
Determine Whether The Number of
Embedded Messages Is Too Large
161
EMBED INFORMATION IN LSB
Writes the secret information sequentially to the LSB
of the carrier image.
Embed Information in LSB
162
EMBED INFORMATION IN LSB
Disadvantage:poor security, can't resist superimposed
noise, lossy compression and other damage!
Final hidden imageEmbedded sequence diagram
163
RANDOM INTERVAL EMBEDDING
Using the camouflage key k as the seed of the pseudo-random number generator, by which the embedded interval length is determined.
Better security,the secret information is embedded into the carrier image at random intervals.
Random interval embedding diagram
Improvement
164
DIFFERENCE
The methods of embedding location selection are:
continuous embedding and random intervals embedding.
Continuous embedding:
Random intervals embedding:
THE END OF LECTURE 5
3/17/2020 DIGITAL IMAGE PROCESSING 165