Tải bản đầy đủ (.docx) (18 trang)

Thuật toán nén ảnh JPEG

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (343.37 KB, 18 trang )

Mục lục
1. Sơ đồ khối thuật toán nén ảnh JPEG.
2. Phân khối

 !"#$%&'(!)*+*),-('
./!)).&"0"12
3"*!4.51,6571
54 "*87*) 9:1;"<
) 4',
!$('=1>?@1)
*3('A×A"B4 $2'CBD!2*)"'&
2*E!,
F@1A×AG
• H!)5EI! $./!)!$'* )
'J)"B4/!A,
• K"I7"D!1,L54
5"MI,
Giả sử ảnh gốc:
3. Biến đổi DCT
6C'* E*)1-L&'
4"<)!9&@$NAA
"B1(!OIP)QR('&I$
!$E.*S2TUVV,65"<$'4
"MN)5!&W1
 !"#$%&'(!)
*+*),
X*S=
Y
&
U
>1(!OIP)'*D9)&Z=


Y
&
U
>
5)!1-L*DM,
3.1 Biến đổi DCT một chiều
-LD!4S%))!G
6
[\$M!x(n) ]C\$5X(k) ^],
-LD!;")(!*_.D1-LUD!<$,
3.2 Biến đổi DCT hai chiều
-L4]5*E`A"BA+P)'
3\ $a!(*))*3AA(5
-L,5-LE]1MJ)a!BD!
)D!b,c0"-L49')!G
L*G
&$Gb)"BP)',
!&G5-L,
dG)*3]5"0"1,
• L!31-L)D!@**N4"$
1)`YQ"0"1-LD!,
• KM!E&N)1)D!\$('
*E@,FM4]5A,
• e)!1-LD!B2P))*32)!4)!
A"0"1*E,^M4]5A,
 f)*3!?)*351P).I,
L"Mg)!)1Ea!h*'TiUVV&
a!P)"M!j&1E]7kYUA,K((l
:1\)-L'5!!&5!g4SI
!1h*2YUA2@*S"B*1AA,

L2)*3'm*E)SIiYUA&)4)*3G
-L)4)*3G
4 Lượng tử hóa
"BP)/!*C0'4l)5-Ln=!&>
:'41M?(9'J5,
KM!P)0'`U"MGD!)$D!,
5.IM "N*S&J5$
I)"M4P)5!&;"'44l)
),jE5-M\)) &C5$
*S*!1CP)21',e])$*!1CP)
1'm* D! 4P)'0,

K(]5/!*C0J5!&)*35)*()!-L"'4
)1'*bH=!&>(71"M5-L1E
=N"M)M>,

ocpXl:".""4l9`D!&5M "
4)*S&5IM)4)*S
.&/!'4*+=1"M3""<>G

n
/
=!&>q*!
6)*34l)G
n
/
=T&T>q*!qiUQ
n
/
=T&Y>q*!qir

n
/
=T&U>q*!qiQ
,
,
,
n
/
=A&A>q*!qT
L)4)*34')!4l)G
5 Mã hóa
5.1 Các phương pháp mã hóa
 Phương pháp mã hóa loạt dài (Run Level Coding)
c.""\)7;M!4"*('U
IGIB=Y>&I*s=T>1'*ED*s&*)&
1't!3,
d!$EsP)"."""571W"7&:
71ThJ))1Y&)$47&71YhJ)
)1T,c.""$85!/!'D!\$W".
u,-\$1W"b7)$7=*!>,L"B&)$
!@1m!@`U9GD!!@1W"
=v]W">,d3$&!@)$D!s.!@M)$,
 Phương pháp mã hóa Huffman
c.""\)w!xx)".""])9C9E,-])
J5!&N)M! ! 5P)v],65M! 
4]51m!$5!M]5"2M!!,65lvm<$
B1,L*".""$N)v]M! )
2\s&v]M!  "2\,
d&v]M! )4\s
47,j_*I$&)\'D!*!1CP)2

\)1h?D!1,L!$E&*C!
M! *  "&)(944;&3+1S5
1,
Thuật toán
L!31)`U1G
iX)7I GM! P)v]*J5!G!$55"
!M]2M!!(<$]1'\,L")!s""7
1'\BI]M! 'M,
iX)7I)G!$51'M! 2!EM!(]50"U"Ml
M! ! 5 " "Ml!$ ,cMl$M! 
1hUM! "M,L3"371'.E7
1U"Ml\0,H!*C4W"71'8"Ml,
H!*C$b/!*C7<$\w!xx)C53"4"4
N<$S"<U,cMlM!  "m1E"'&"Ml)m
1E*,67<$$& '1J5!yv];z;*
;4",
f\)G@M!1E"')EY1{Y|2\z@M!1E
*)E1{T|,
6:G
Bảng tần suất Bảng tần suất theo thứ tự giảm dần
F!v*h&*".""w!xx)&\P)v]!$ 9\
"M1sM!P)\,6C3$&b5"0212M!!
)(!$5<$\&Iv]\4'0,
Bảng từ mã gán cho các kí tự bởi mã Huffman
5.2 Mã hóa các hệ số DCT Fq(u,v)
• K(\)B*"$5n
/
=!&>&)M15n
/
=!&>

!@D!,
• w5n
/
=T&T>="MYD!>"M*!1CP)
@14)1\))=-cfi-xxB*B)
"!BB!)>,
• 5="M)$D!>*214
bB(!}i}))1\)7=jF>,
• !?J5!2U1\)-cfjF4\)
MJ)1h\p*"$,
• -J5!0&1'\&1'4l44"7
xBB!#ocpX,
 Mã hóa thành phần một chiều.
i 5-*S*!1CP)'AA,K
*!1CP)1'M)!N1&*
!#0ocpX&5-4\)B".
""-cf,
i K(5!! 0&/!'34)!4\)"
1h\w!xx),
i L*Ev!$&'P)*S34)!\)
-cf "9'P)5-L&%)
"M$*Sh*'iUYYUYYiY,e1M
(\)"MYD!YY,
• e.`\)"MYD!-
w5-
L2\-
w5-P)-L4M4)1-cf,L"M)
J))5-E"4\)*1\w!xx),
 H!*C\)w!xx)4]5"M-)!G
• -+C*1'"<7("<7*S~-="<7D!

2\?(\)"M~->,
• -?1'\w!xx)"M-(C*)2\7
~-C4m1Y,
• f\)S"<*S~-,
• X0"2\w!xx)*SS"<P)~-(42
\"M-,
L*E1'YU1'*)M(]5\)"M
-,
F7 c75
d• T
iYY
ir&iUU&r
i€&iQ&iV&iRR&V&Q&€
iYV&•&iAA&•&YV
irY&•&iYQYQ&•&rY
iQr&•&irUrU&•&Qr
iYU€&•&iQRQR&•&YU€
iUVV&•iYUAYUA&•&UVV
iVYY&•&iUVQUVQ&•&VYY
iYTUr&•&iVYUVYU&•&YTUr
iUTR€&•&iYTURYTUR&•&UTR€
Y
U
r
R
V
Q

A


YT
YY
Bảng 1: phân loại hệ số DC và AC
 c<7 L2\
iUVV&•iYUAYUA&•&UVV A YYYYYYT
iYU€&•&iQRQR&•&YU€ € YYYYYT
iQr&•&irUrU&•&Qr Q YYYYT
irY&•&iYQYQ&•&rY V YYYT
iYV&•&iAA&•&YV R YYT
i€&iQ&iV&iRR&V&Q&€ r YTY
ir&iUU&r U TY
iYY Y TT
T T YTT
Bảng 2: bảng mã Huffman cho thành phần DC
6:G
L))*35-LG
YV T iY T T T T T
iU iY T T T T T T
iY iY T T T T T T
T T T T T T T T
T T T T T T T T
T T T T T T T T
T T T T T T T T
T T T T T T T T
L"M-*)*3-

qYV,
X'l-
iY
qYU,

 [/!'\)-cfq-

i-
iY
qr
L*E1'"<75qr!7U,
-])1'\w!xx))2\.I7UTY=U
2\>
X*Sqr\)S"<YY,
 L2\-

TYYY
 Mã hóa thành phần xoay chiều.
Quét zig-zag:
[%!30ocpXl:".""/!0}i}),L:P)s""7
BI]ƒƒ)7*)D!75)!&?\jF5!
/!'0E,
;)1*h4P)5'M2*E1E*!
1E"'E5s""75BI]ƒƒ)7D!
55 "8)!=?I4l>h*E+,
Sơ đồ khối bộ mã hóa thành phần AC:

5•
L2\•
!@5•4M4)1\)jF,„M!*))34
2\1)`)"MG
• X*S7$41…T…I*5…T…)4\
),
• EP)5…T…*E,L2\w!xx)IW"*S*E
4C*)*1'"<7=1'Ym*E>1'\w!xx)

"M•,
 L2\•1)`2\w!xx)*S1EP)5•,

6:2)*3-Lm*E&e)!/!*C/!0}i})&)34!@5
•)!G
T&iU&iY&iY&iY&T&T&iY&T&T••
!@134)!\)jFG
=Y&iU>=T&iY>=T&iY>=T&iY>=U&iY>=p†>
L2\!?(15!;9Gp†=Bx1>,
el:1'"<7)C47P)1E
=Y&U>=iU>&=T&Y>=iY>&=T&Y>=iY>&=T&Y>=iY>&=U&Y>=iY>&=T&T>
‡%)@*S=)&1>G
)*S7$,
17,
1E,
Bảng mã Huffman cho thành phần AC
X*S7$ F7 K\ L2\
T Y U TT
T U U TY
Y Y R YYTT
Y U Q YYYTTY
Y r € YYYYTTY
Y R ‚ YYYYYTYYT
U Y V YYTYY
U U A YYYYYTTT
R Y Q YYYTYY
V Y € YYYYTYT
Q Y € YYYYTYY
p† R YTYT
=Y&U>=iU>4\)YYYTTYTY

 [/!'\)'"M•-)4!@1G
TYYY YYYTTYTY TTTT TTTT TTTT YYTYYTT YTYT
- • p†

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×