Exercise 6 - Ee Oulu Fi

advertisement
Digital Image Processing
Exercise 6
FALL 2002
Answers
1.
When a binary image is coded with ordinary binary code one bit per pixel is needed. In this question
image size is 16 x 16 and therefore 256 bits are needed for the representation.
a) run-length coding
-
possible run-lengths vary from one to sixteen => 4 bits per run are needed
gray level (black/white) can be coded with one bit. In addition, we have to know only the
gray level of the first pixel in the row (when we have only two values and the value changes
we always know what the next value will be).
row
0
1
2
3
4
…
7
-
value
0
0
0
0
0
..
0
run-lengths
16
16
16
7, 1, 8
7, 2, 7
…
16
binary code
0 1111
0 1111
0 1111
0 0110 0000 0111
0 0110 0001 0110
…
0 1111
Bits needed:
There are 34 runs and 16 rows in the image => bits needed: 16 + 34  4 = 152 (against 256
bits for uncompressed image) or 0.59 bits/pixel (against 1 bit/pixel for uncompressed
image).
b) chain code
-
Eight directions are represented with 3 bits
Upper left corner of the object (7,3) is selected to be the
starting point (upper left corner of the image is (0,0))
The edge of the object is followed clockwise until we
get back to the starting point.
We get the following chain code for the object: 7, 6, 7, 7, 6, 6, 5, 6, 3, 3, 3, 3, 4, 1, 1, 1, 2.
Because we have a binary image, we don’t need gray level information.
Binary code:
Starting point
0111 0011
directions
111 110 111 111 110 … 010
Bits needed: 2  4 + 17  3 = 59 (against 256 for uncompressed image) => 0.23 bits/pixel
(against 1 bit/pixel for uncompressed image).
1/3
Digital Image Processing, Exercise 6, answers
2.
a) It is not. Variable-length coding is based on the principle that most probable symbols (gray levels)
are coded with the shortest code words and the least probable symbols are coded with the longest
code words. In ideal case, the image after histogram equalization has the equal number of every pixel
value (flat histogram). Though in reality there can be variations, the compression achieved by using
variable-length method is unlikely worth the effort.
b) Yes. For example, psycho visual, spatial and geometric redundancy.
3.
Spot detection
3 x 3 masks response is
9
R  w1 z1  w2 z 2  ...  w9 z 9   wí z i  wT z
i 1
 w1

when the mask is w4
w
 7
w2
w5
w8
w3 

w6  and zi are the corresponding gray levels in the image
w9 
The pixel differs from its neighbors if the response: R  T
The given mask R = -(z1 + z2 + z3 + z4 + z6 + z7 + z8 + z9 ) + 8 z5
1. pixel: R = -( 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 ) + 8  3 = 0
2. pixel: R = -( 3 + 3 + 4 + 3 + 0 + 3 + 3 + 3 ) + 8  3 = 2
3. pixel: R = -( 3 + 4 + 4 + 3 + 4 + 3 + 3 + 4 ) + 8  0 = -28
…..
Resulting image
0
2
-28
-4
-5
-9
-4
-1
-1
-7
35
-9
-6
-11
39
There are three pixels whose response is large or small enough (bold). Therefore there are 3 spots.
4. Line detection
The size of the given image is 4x4. The responses for first two masks can be calculated in only one
position. The responses for the last two masks can be calculated in two positions.
First mask: (+45 line)
R = 2  ( 5 + 8 + 6 + 4 ) – ( 7 + 3 + 7 +1 + 9 + 0 + 3 + 5 + 3 + 8 + 5 + 3 ) = -8
2/3
Digital Image Processing, Exercise 6, answers
Second mask: (-45 line)
R = 2  ( 7 + 9 + 5 + 3 ) – ( 3 + 7 + 4 + 1 + 6 + 0 + 3 + 8 + 3 + 5 + 8 + 5 ) = -5
Third mask: (vertical line)
R = 2  ( 3 + 9 + 8 + 8 ) – ( 7 + 1 + 3 + 5 + 7 + 6 + 5 + 5 ) = 17
R=2(7+6+5+5)–(3+9+8+8+4+0+3+3)=8
Forth mask: (horizontal line)
R = 2  ( 1 + 9 + 6 + 0 ) – ( 7 + 3 + 7 + 4 + 3 + 8 + 5 + 3 ) = -8
R=2(3+8+5+3)–(1+9+6+0+5+8+5+3)=1
There is one vertical line in the image (R = 17). The line is in the second column of the image.
3/3
Download