MS works in computer science in the Open University.
Efficient realization for geometric transformation of digital images in
run length encoding.
By Shlomo Pongratz.
Instructor: Dr Jack Weinstein.
Seven by six pixels digital image of the letter A.
0 0 0 0 0 0 6(0)0 0 1 0 0 0 2(0)1(1)3(0)0 1 0 1 0 0 1(0)1(1)1(0)1(1)2(0)0 1 0 1 0 0 1(0)1(1)1(0)1(1)2(0)0 1 1 1 0 0 1(0)3(1)2(0)0 1 0 1 0 0 1(0)1(1)1(0)1(1)2(0)0 0 0 0 0 0 6(0)
Image serialization.
• height=6,width=7,6(0)2(0)1(1)3(0)1(0)1(1)1(0)2(0)1(0)1(1)1(0)2(0)1(0)3(1)2(0)1(0)1(1)1(0)2(0)6(0).
Create directory is linearoffset = 0;for (line = 0; line < hight; line++){
{length = 0;while (length < width){length += run.getLength();run.next();offset++;}output(offset);}
}
The Geometric Operations OP Procedure
No op Copy source to destination row by row run by run.
Column flip Read input columns in reverse order.
Row flip Read input rows in reverse order.
Rotate 180° Do row flip and column flip.
Diagonal flip Swap rows with columns.
Rotate 90° (CCW) Do column flip and then diagonal flip.
Rotate 270° (CW) Do row flip and then diagonal flip.
Opposite diagonal flip Do 180° rotation and diagonal flip.
Rotate by 0° < α ≤ 45°
Rotate by 0° > α ≥ 45°
Rotate by any angle
The No Op operation.
The Columns flip operation. • for (line = 0; line < height; i++)• {• start = directory[line];• ends = directory[line + 1];• // go backwards• for (index = ends – 1; index >= start; index--)• {• output_run(image[index]);• }• }
The Rows flip operation. • for (line = 0; line < height; line++)• {• start = directory[height - line - 1];• ends = directory[height - line];• // go forwards• for (index = start; index < end; index++)• {• output_run(image[index]);• }• }
The Rotation by 180° operation.
• for (line = 0; line < height; line++)• {• start = directory[height - line - 1];• ends = directory[height - line];• // go backwards• for (index = ends – 1; index >= start; index--)• {• output_run(image[index]);• }• }
The Diagonal Flip operation.
• Merging process• For each line sequence runi={leni,colouri}
• Create ordered list {Σij=0 lenj,colouri}
• Use regular merging algorithm• Compare colours while merging.
Same colour runs
Different colour runs
States in merge
1 0 3 2 1 1 1 0 0
0 1 0 0 0 0 0 0 0 0
1 0 0 0 0 1 1 1 0 0
2 0 0 1 1 1 1 1 0 0
3 0 0 0 1 1 1 0 0 0
4 0 0 0 0 1 1 0 0 0
5 0 0 0 0 0 0 0 0 0
6 0 0 0 0 0 0 0 0 0
0 1 2 3 4 5 6 7 8
1 0 3 4 1 1 1 0 0
0 1 0 0 0 0 0 0 0 0
1 0 0 0 0 1 1 1 0 0
2 0 0 1 1 1 1 1 0 0
3 0 0 0 1 1 1 0 0 0
4 0 0 0 0 1 1 0 0 0
5 0 0 0 0 0 0 0 0 0
6 0 0 0 0 0 0 0 0 0
0 1 2 3 4 5 6 7 8
Source to destination problem• for (I= 0; I < 10; I++)• {
– for (J = 0; J< 10; J++)– {
• map pixel at [I,J] to• [round(I * cos(30) – J*sin(30)) , round(I*sin(30) + J * cos(30)) }
• }
(0:0) (0:1) (0:2) (0:3) (-1:3) (-1:4) (-2:5) (-2:6) (-3:7) (-3:8)
(1:1) (0:1) (0:2) (0:3) (0:4) (-1:5) (-1:6) (-2:7) (-2:7) (-3:8)
(2:1) (1:2) (1:3) (0:4) (0:4) (0:5) (0:6) (-1:7) (-1:8) (-2:9)
(3:1) (2:2) (2:3) (1:4) (1:5) (0:6) (0:7) (0:8) (0:8) (-1:9)
(3:2) (3:3) (2:4) (2:5) (1:5) (1:6) (0:7) (0:8) (0:9) (0:10)
(4:2) (4:3) (3:4) (3:5) (2:6) (2:7) (1:8) (1:9) (0:9) (0:10)
(5:3) (5:4) (4:5) (4:6) (3:6) (3:7) (2:8) (2:9) (1:10) (1:11)
(6:3) (6:4) (5:5) (5:6) (4:7) (4:8) (3:9) (3:10) (2:10) (2:11)
(7:4) (6:5) (6:6) (5:7) (5:7) (4:8) (4:9) (3:10) (3:11) (2:12)
(8:4) (7:5) (7:6) (6:7) (6:8) (5:9) (5:10) (4:11) (4:11) (3:12)
Tanaka et-al algorithm
102
tan1*1sin01
*10
2tan1
cossinsincos a
a
a
aaaa
Eliminate Vertical sheer.
0110
*10
sin1*
0110
1sin01 a
a
Combining it all together
What’s wrong
Not linear in the worst case
One pass algorithm 1 1 1 1 1
0 0 0 1 1 0 0 0 0 0
1 1 1 1 1 1 1 1 0 0
0 0 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 1 1 1
0 0 0 0 0
1st case
2nd case
3rd case
4th case
5th case
6th case
7th case
1st case
2nd case
3rd case
4th case
5th case
Cohen algorithm
What’s wrong
cossinsincos
tan1tantan1
10tan1
*1tan01
2
Fixing Cohen's algorithm
cossinsincos
10tan1
sec00sin
1tan01
Note – non reversible
Top Related