You are on page 1of 50

Steganography & Pixel neighbors

Dr Khurram Khurshid

Digital Image Processing


Steganography

The science of writing hidden messages in


such a way that no one, apart from the
sender and intended recipient, suspects
the existence of the message

2
Steganography

wBefore Moving On ….
wRecall – Logical Shift Operators

Logical left shift one bit Logical right shift one bit

3
Steganography

Two least significant bits are 0


8-bit Image 6-bit Image
If an image is quantized, say from 8 bits to 6 bits and
redisplayed it can be all but impossible to tell the difference
between the two.
Steganography

If the 6-bit version That other information could


is displayed as an be a message, perhaps
8-bit image then the encrypted, or even another
8-bit pixels all have image.
zeros in the lower 2 Image 1 Image 2
bits:
b b b b b b 0 0 R-Shift 2 R-Shift 6

b = 0 or 1 always 0
L-Shift 2
This introduces the
possibility of logical
Image Out
OR
encoding other
information in the X-Shift n = logical left or right shift by n
low-order bits. bits.
5
Steganography

182
1 0 1 1 0 1 1 0
220
R-Shift 2 1 1 0 1 1 1 0 0
0 0 1 0 1 1 0 1
R-Shift 6
L-Shift 2 03
180 0 0 0 0 0 0 1 1
1 0 1 1 0 1 0 0

183

1 0 1 1 0 1 1 1
Steganography

183
1 0 1 1 0 1 1 1

L-Shift 6
How to get the second image

192
1 1 0 0 0 0 0 0

Extracted Second Image


Steganography

If we have only 4 colors (2-bits)


and we put them in the lower
order bits
182
1 0 1 1 0 1 1 0
03
R-Shift 2 0 0 0 0 0 0 1 1
0 0 1 0 1 1 0 1
R-Shift 6
L-Shift 2 03
180 0 0 0 0 0 0 1 1
1 0 1 1 0 1 0 0

183
⊕ No need to shift right

1 0 1 1 0 1 1 1
What would you
do to get back
original data?
Steganography

8-bit-per-band, 3-band,
“original” image

9
Steganography

6-bit-per-band, 3-band,
quantized image

10
Steganography

green-band histogram of 8-bit image green-band histogram of 6-bit image

The histograms of the two versions indicate which is which. If the 6-bit
version is displayed as an 8-bit image it has only pixels with values 0, 4,
8, … , 252.
11
Steganography

The second image is invisible because the value of each pixel is between 0
and 3. For any given pixel, its value is added to the to the collocated pixel in
the first image that has a value from the set {0, 4, 8, … , 252}. The 2nd image
is noise on the 1st .
12
L-Shift 6
Steganography

?
To recover the second image (which is 2 bits per
pixel per band) simply left shift the combined image
by 6 bits.
13
L-Shift 6
Steganography

image

To recover the second image (which is 2 bits per


pixel per band) simply left shift the combined image
by 6 bits.
14
Steganography

Images 1 and 2 each


This is so effective that two have 4-bits per pixel
4-bit-per-pixel images can when combined.
be superimposed with only
the image in the high-order
bits visible. Both images Image 1 Image 2
contain the same amount of
information but the image in R-Shift 4 R-Shift 4
the low-order bits is
effectively invisible
L-Shift 4

Image Out

15
Steganography

Original Image

16
Steganography

Image quantized to
4-bits per pixel.

17
Steganography

Image 1 in upper 4-bits.


Image 2 in lower 4-bits.

18
Steganography

Extracted Image
19
Steganography

http://mozaiq.org/encrypt/

20
Relationships between pixels

wNeighbors of pixel are the pixels that are


adjacent pixels of an identified pixel
x-1 x x+1

y-1

y+1

21
4- Neighbors of a Pixel –N4(p)

What are the coordinates


of each of the blue pixels x-1 x x+1

y-1

y-1

(x-1,y), (x+1,y), (x, y-1), (x,


y+1)

22
Diagonal Neighbors of a Pixel –
ND(p)

x-1 x x+1

y-1

y-1

(x-1,y-1), (x+1,y-1), (x-1, y+1), (x+1,


y+1)

23
8- Neighbors of a Pixel –N8(p)

x-1 x x+1

y-1

y-1

N8 ( p ) = N 4 ( p ) ∪ N D ( p )
(x-1,y), (x+1,y), (x, y-1), (x,
y +1 )
(x-1,y-1), (x+1,y-1), (x-1, y+1), (x+1,
y +1 )
24
Determine different regions in
the image

25
Connectivity

wEstablishing boundaries of objects and components in an image


wGroup the same region by assumption that the pixels being the same color or
equal intensity
wTwo pixels p & q are connected if
n They are adjacent in some sense
If their gray levels satisfy a specified criterion of
n

similarity
n

26
Connectivity
V: Set of gray levels used to define the criterion of similarity

4-connectivity

If gray level ( p, q ) ∈ V , and q ∈ N 4 ( p )

Set of gray levels V = {1}

27
Connectivity
V: Set of gray levels used to define the criterion of similarity

8-connectivity

If gray level ( p, q ) ∈ V , and q ∈ N8 ( p )

Set of gray levels V = {1}

28
Connectivity
V: Set of gray levels used to define the criterion of similarity

m-connectivity (Mixed Connectivity)

If gray level

( p, q ) ∈ V , and q satisfies one of the following:


a. q ∈ N ( p ) or
4
b. q ∈ N D ( p ) And N 4 ( p ) ∩ N 4 ( q ) has no pixels
whose values are from V

29
Example: m – Connectivity

wSet of gray levels V = {1}

Note: Mixed connectivity can eliminate the multiple path connections that often
occurs in 8-connectivity

30
Paths

wPath: Let coordinates of pixel p: (x, y), and of pixel q: (s, t)

wA path from p to q is a sequence of distinct pixels with


coordinates: (x0, y0), (x1, y1), ......, (xn,yn)

where (x0, y0) = (x, y) & (xn,yn) = (s, t), and (xi,yi) is
adjacent to (xi-1 ,yi-1 ) 1≤i ≤n

31
CC labeling – 4 Connectivity
wProcess the image from left to
right, top to bottom:
1.) If the next pixel to process is 1
i.) If only one of its neighbors
(top or left) is 1, copy its
label.

ii.) If both are 1 and have the


same label , copy it.

iii.) If they have different


labels Pass 1
 Copy the label from the
left.
 Update the equivalence
table.

iv.) Otherwise, assign a new label.

Pass
wRe-label with the smallest of equivalent 2
labels

32
CC labeling – 4 Connectivity

33
CC labeling – 4 Connectivity

34
CC labeling – 8 Connectivity

Same algorithm but examine also the upper diagonal neighbors of p

35
CC labeling – 8 Connectivity

Background pixel
Background pixel
Unlabeled Pixel
Unlabeled Pixel
Label 1

36
CC labeling – 8 Connectivity

Background pixel Background pixel


Unlabeled Pixel Unlabeled Pixel
Label 1 Label 1
Label 2 Label 2

Label 3

37
CC labeling – 8 Connectivity

Background pixel Background pixel

Unlabeled Pixel Unlabeled Pixel


Label 1 Label 1
Label 2 Label 2
Label 3 Label 3

38
CC labeling – 8 Connectivity

Background pixel Background pixel

Unlabeled pixel Unlabeled pixel

Label 1 Label 1

Label 2 Label 2

Label 3 Label 3

39
CC labeling – 8 Connectivity

Background pixel Background pixel


Unlabeled pixel Unlabeled pixel
Label 1 Label 1
Label 2 Label 2
Label 3 Label 3
Label 4 Label 4

40
Distance Metrics

wLet pixels p, q and z have coordinates (x,y),


(s,t) and (u,v) respectively.
w
wD is a distance function or metric if
nD(p,q) ≥ 0 and
nD(p,q) = 0 iff p = q and

nD(p,q) = D(q,p) and

nD(p,z) ≤ D(p,q) + D(q,z)

41
City block distance (D4
distance)

D4 ( p, q ) = x − s + y − t

wDiamond with center at


(x,y)
wD4 = 1 are the 4 neighbors
of pixel p(x,y)

42
Chessboard distance (D8
distance)

D8 ( p, q ) = max( x − s , y − t )

wSquare centered at p(x,y)


wD8 = 1 are the 8 neighbors
of pixel p(x,y)

43
Euclidean Distance
w
w De ( p, q ) = ( x − s )2 + ( y − t )2
w
q(s,t)
w
r
w
w
p(x,y)

A circle with radius r centered at (x,y)

44
Arithmetic Operations

wCarried out between corresponding pixel


pairs
n
s ( x, y ) = f ( x, y ) + g ( x, y )
d ( x, y ) = f ( x, y ) − g ( x, y )
p ( x, y ) = f ( x , y ) × g ( x , y )
d ( x , y ) = f ( x, y ) ÷ g ( x, y )

45
Arithmetic Operations

wConversion to range 0 – 255


wDifference of two 8-bit images: -255 to 255
wSum of two 8-bit images: 0 to 510
wSolution?
n

Set all values < 0 to 0

Set all values > 255 to 255

Full range of arithmetic operation not captured

46
Arithmetic Operations

wFirst perform the operation


Creates an image whose minimum value is 0
w
w f m = f − min( f )
wThen perform Creates a scaled image f with values in the r
s

f s = K [ f m max( f m )]

47
Logical Operations (Binary
Images)

48
Acknowledgements
wDigital Image Processing”, Rafael C. Gonzalez & Richard E. Woods, Addison-Wesley, 2002
wPeters, Richard Alan, II, Lectures on Image Processing, Vanderbilt University, Nashville,
TN, April 2008
Material in these slides has been taken from the following

wBrian Mac Namee, Digitial Image Processing, School of Computing, Dublin Institute of
Technology
wComputer Vision for Computer Graphics, Mark Borg
resources

49
Acknowledgements
wStatistical Pattern Recognition: A Review – A.K Jain et al., PAMI (22) 2000
wPattern Recognition and Analysis Course – A.K. Jain, MSU
Material in these slides has been taken from, the following

wPattern Classification” by Duda et al., John Wiley & Sons.


wDigital Image Processing”, Rafael C. Gonzalez & Richard E. Woods, Addison-Wesley, 2002
wMachine Vision: Automated Visual Inspection and Robot Vision”, David Vernon, Prentice
Hall, 1991
wwww.eu.aibo.com/
wAdvances in Human Computer Interaction, Shane Pinder, InTech, Austria, October 2008
resources

w
w

50

You might also like