1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Xử lý ảnh số - Nén dữ liệu ảnh part 7 pps

6 152 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 6
Dung lượng 122,41 KB

Nội dung

yˆe ´ u l`a g´an x´ac suˆa ´ td¯ˆo ´ iv´o . ik´yhiˆe . u shift tru . ´o . c khi m˜a ho´a Huffman khˆo ´ i tham chiˆe ´ u. Thˆong thu . `o . ng ph´ep g´an thu . . chiˆe . nbˇa ` ng c´ach lˆa ´ ytˆo ˙’ ng x´ac suˆa ´ tcu ˙’ atˆa ´ tca ˙’ c´ac k´y hiˆe . u ngo`ai khˆo ´ i tham chiˆe ´ u; t´u . cl`ad¯i . nh ngh˜ıa k´y hiˆe . utiˆe ` ntˆo ´ nhu . trong m˜a Huffman chˇa . t cu . t. Trong tru . `o . ng ho . . p n`ay, tˆo ˙’ ng lˆa ´ yt`u . a 8 d¯ ˆe ´ n a 21 v`a do d¯´o bˇa ` ng 0.39. Do d¯´o k´yhiˆe . u shift c´o x´ac suˆa ´ t xuˆa ´ thiˆe . nl´o . n nhˆa ´ t v`a d¯u . o . . c g´an mˆo . tt`u . m˜a Huffman l`a 00. M˜a ho´a sˆo ´ ho . c Kh´ac v´o . i c´ac m˜a c´o d¯ˆo . d`ai thay d¯ˆo ˙’ id¯u . o . . cd¯ˆe ` cˆa . p trˆen, m˜a ho´a sˆo ´ ho . c sinh ra c´ac t`u . m˜a khˆong pha ˙’ il`achuˆo ˜ i c´ac bit. Khˆong c´o tu . o . ng ´u . ng mˆo . tmˆo . tgi˜u . a c´ac k´y hiˆe . u nguˆo ` n v`a c´ac t`u . m˜a. Thay v`ao d¯´o, mˆo . t d˜ay c´ac k´yhiˆe . u nguˆo ` n (hay thˆong b´ao) d¯u . o . . c g´an bˇa ` ng mˆo . tt`u . m˜a. T`u . m˜a n`ay l`a mˆo . tsˆo ´ thu . . c thuˆo . c khoa ˙’ ng [0, 1). Khi sˆo ´ c´ac k´y hiˆe . u nguˆo ` n trong thˆong b´ao tˇang th`ı khoa ˙’ ng biˆe ˙’ udiˆe ˜ n n´o s˜e nho ˙’ d¯i v`a sˆo ´ c´ac d¯o . nvi . thˆong tin (chˇa ˙’ ng ha . n, bit) biˆe ˙’ udiˆe ˜ n khoa ˙’ ng n`ay s˜e nhiˆe ` uho . n. Mˆo ˜ ik´yhiˆe . ucu ˙’ a thˆong b´ao s˜e thu go . n k´ıch thu . ´o . ccu ˙’ a khoa ˙’ ng tu . o . ng ´u . ng v´o . i x´ac suˆa ´ t xuˆa ´ thiˆe . ncu ˙’ a n´o. Kh´ac v´o . i phu . o . ng ph´ap m˜a ho´a Huffman, k˜y thuˆa . t n`ay khˆong d¯`oi ho ˙’ imˆo ˜ ik´yhiˆe . u nguˆo ` ntu . o . ng ´u . ng mˆo . tsˆo ´ nguyˆen m˜a ho´a k´yhiˆe . u(t´u . c l`a c´ac k´yhiˆe . ud¯u . o . . c m˜a ho´a riˆeng biˆe . t) nˆen vˆe ` mˇa . tl´y thuyˆe ´ t n´o d¯a . tcˆa . ndu . ´o . id¯u . o . . c thiˆe ´ tlˆa . pbo . ˙’ id¯i . nh l´y m˜a ho´a khˆong nhiˆe ˜ u (xem Phˆa ` n 6.3.3). D˜ay m˜a ho´a . . − . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . − − − − − 0 1 a 1 a 1 a 2 a 3 a 4 − . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . − . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . − − − − − 0 0.2 a 2 a 1 a 2 a 3 a 4 − . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . − . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . − − − − − 0.04 0.08 a 3 a 1 a 2 a 3 a 4 − . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . − . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . − − − − − 0.072 0.056 a 4 a 1 a 2 a 3 a 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . − − − − − 0.0688 0.06752 0.0624 a 5 a 1 a 2 a 3 a 4 H`ınh 6.10: Thuˆa . t to´an m˜a ho´a sˆo ´ ho . c. H`ınh 6.10 minh ho . atiˆe ´ n tr`ınh m˜a ho´a sˆo ´ ho . c. X´et d˜ay (thˆong b´ao) gˆo ` m nˇam k´yhiˆe . u m := a 1 a 2 a 3 a 3 a 4 t`u . mˆo . t nguˆo ` ngˆo ` mbˆo ´ nk´yhiˆe . u. Kho . ˙’ ita . o, thˆong b´ao chiˆe ´ m to`an bˆo . khoa ˙’ ng J 1 := [0, 1). Nhu . chı ˙’ ra trong Ba ˙’ ng 6.4, khoa ˙’ ng n`ay d¯u . o . . c phˆan chia 177 K´yhiˆe . u nguˆo ` n X´ac suˆa ´ t Khoa ˙’ ng kho . ˙’ ita . o a 1 0.2 [0.0, 0.2) a 2 0.2 [0.2, 0.4) a 3 0.4 [0.4, 0.8) a 4 0.2 [0.8, 1.0) Ba ˙’ ng 6.4: V´ı du . m˜a ho´a sˆo ´ ho . c. th`anh bˆo ´ nv`ung con du . . a trˆen x´ac suˆa ´ t xuˆa ´ thiˆe . ncu ˙’ amˆo ˜ ik´yhiˆe . u nguˆo ` n. Chˇa ˙’ ng ha . n, k´yhiˆe . u a 1 tu . o . ng ´u . ng khoa ˙’ ng con [0, 0.2). V`ıd¯ˆayl`ak´yhiˆe . ud¯ˆa ` u tiˆen cu ˙’ a thˆong b´ao m nˆen khoa ˙’ ng [0, 1) s˜e thu he . p th`anh J 2 := [0, 0.2). Do d¯´o trong H`ınh 6.10 khoa ˙’ ng J 2 d¯ u . o . . c k´eo d˜an ra v´o . id¯ˆo . cao bˇa ` ng 1 v`a c´ac d¯iˆe ˙’ md¯ˆa ´ u cuˆo ´ icu ˙’ a n´o d¯u . o . . c g´an c´ac gi´a tri . cu ˙’ a khoa ˙’ ng he . pho . n n`ay. Kˆe ´ tiˆe ´ p khoa ˙’ ng J 2 d¯ u . o . . c chia th`anh nh˜u . ng khoa ˙’ ng con tu . o . ng ´u . ng v´o . i x´ac suˆa ´ t xuˆa ´ thiˆe . ncu ˙’ at`u . ng k´y hiˆe . u nguˆo ` n v`a qu´a tr`ınh la . itiˆe ´ ptu . c v´o . ik´yhiˆe . utiˆe ´ p theo trong thˆong b´ao m. Tac´ok´yhiˆe . u a 2 thu he . p khoa ˙’ ng J 2 th`anh khoa ˙’ ng J 3 := [0.04, 0.08); k´y hiˆe . u a 3 thu he . p khoa ˙’ ng J 3 th`anh J 4 := [0.056, 0.072) v`a sau d¯´o th`anh J 5 := [0.0624, 0.0688). K´yhiˆe . u nguˆo ` n cuˆo ´ ic`ung trong thˆong b´ao (l`a a 4 ) xem nhu . k´yhiˆe . ud¯ˇa . cbiˆe . t d¯´anh dˆa ´ ukˆe ´ tth´uc thˆong b´ao s˜e thu he . p khoa ˙’ ng J 5 th`anh J 6 := [0.06752, 0.0688). D˜ı nhiˆen c´o thˆe ˙’ d`ung mˆo . tsˆo ´ bˆa ´ tk`y thuˆo . c khoa ˙’ ng J 6 (chˇa ˙’ ng ha . n, 0.068) d¯ˆe ˙’ biˆe ˙’ udiˆe ˜ n cho thˆong b´ao m. Theo c´ach m˜a ho´a sˆo ´ ho . c tr`ınh b`ay trˆen, ch´ung ta cˆa ` nbach˜u . sˆo ´ thˆa . p phˆan d¯ˆe ˙’ m˜a ho´a thˆong b´ao gˆo ` m nˇam k´yhiˆe . u. T´u . c l`a su . ˙’ du . ng 3/5hay0.6ch˜u . sˆo ´ thˆa ´ p phˆan d¯ ˆe ˙’ biˆe ˙’ udiˆe ˜ nmˆo . tk´yhiˆe . u. Ch´u´yrˇa ` ng entropy cu ˙’ a nguˆo ` n l`a 0.58. Khi d¯ˆo . d`ai cu ˙’ a d˜ay cˆa ` n m˜a ho´a tˇang lˆen th`ı sˆo ´ ch˜u . sˆo ´ thˆa . p phˆan d¯ˆe ˙’ biˆe ˜ udiˆe ˜ nmˆo . tk´yhiˆe . us˜etiˆe ´ nd¯ˆe ´ n cˆa . ndu . ´o . id¯u . o . . c thiˆe ´ tlˆa . pbo . ˙’ id¯i . nh l´y m˜a ho´a khˆong nhiˆe ˜ u. Trong thu . . ctˆe ´ , hai nhˆan tˆo ´ khiˆe ´ n cho khˆong d¯a . td¯u . o . . ccˆa . ndu . ´o . i n`ay l`a: (1) thˆem dˆa ´ uhiˆe . ukˆe ´ tth´uc thˆong b´ao d¯ˆe ˙’ t´ach c´ac thˆong b´ao; v`a (2) su . ˙’ du . ng sˆo ´ v´o . id¯ˆo . ch´ınh x´ac h˜u . uha . n. D - ˆe ˙’ gia ˙’ i quyˆe ´ tvˆa ´ n d¯ ˆe ` sau ch´ung ta c´o thˆe ˙’ thu . . chiˆe . nbu . ´o . c co gi˜an v`a bu . ´o . c l`am tr`on. Ph´ep co gi˜an nhˇa ` m chuˆa ˙’ n ho´a mˆo ˜ i khoa ˙’ ng con th`anh khoa ˙’ ng [0, 1) tru . ´o . c khi phˆan chia n´o th`anh nh˜u . ng khoa ˙’ ng con tu . o . ng ´u . ng x´ac suˆa ´ t xuˆa ´ thiˆe . ncu ˙’ ak´yhiˆe . u. Giai d¯oa . n l`am tr`on ba ˙’ od¯a ˙’ m c´ac ph´ep l`am tr`on sˆo ´ cho sˆo ´ v´o . id¯ˆo . ch´ınh x´ac h˜u . uha . n khˆong l`am mˆa ´ t t´ınh ch´ınh x´ac cu ˙’ a qu´a tr`ınh m˜a ho´a c´ac khoa ˙’ ng con. 178 6.4.2 M˜a ho´a mˇa . t phˇa ˙’ ng bit Ch´ung ta d¯˜a tr`ınh b`ay nh˜u . ng phu . o . ng ph´ap ch´ınh d¯ˆe ˙’ gia ˙’ mdu . th `u . a trong m˜a ho´a. Phˆa ` nkˆe ´ tiˆe ´ p s˜e d¯ˆe ` cˆa . pd¯ˆe ´ nmˆo . tsˆo ´ phu . o . ng ph´ap n´en ba ˙’ o to`an thˆong tin gia ˙’ mdu . th `u . a trong quan hˆe . gi˜u . a c´ac pixel. Tru . ´o . chˆe ´ t, k˜y thuˆa . t m˜a ho´a mˇa . t phˇa ˙’ ng bit du . . a trˆen kh´ai niˆe . m phˆan r˜a mˆo . ta ˙’ nh nhiˆe ` um´u . c x´am (d¯o . nsˇa ´ c hay m`au) th`anh mˆo . t d˜ay c´ac a ˙’ nh nhi . phˆan v`a n´en c´ac a ˙’ nh nhi . phˆan thˆong qua mˆo . tsˆo ´ phu . o . ng ph´ap n´en a ˙’ nh nhi . phˆan quen thuˆo . c. Phˆa ` n n`ay mˆo ta ˙’ c´ac c´ach phˆan r˜a quen thuˆo . c nhˆa ´ t v`a nh`ın la . imˆo . t v`ai phu . o . ng ph´ap n´en thu . `o . ng d`ung. Phˆan r˜a mˇa . t phˇa ˙’ ng bit Ta biˆe ˙’ udiˆe ˜ nc´acm´u . c r cu ˙’ aa ˙’ nh x´am m-bit theo hˆe . nhi . phˆan r = a m−1 2 m−1 + a m−2 2 m−2 + ···+ a 1 2 1 + a 0 2 0 . T`u . d¯´o ta c´o thˆe ˙’ phˆan r˜a a ˙’ nh th`anh c´ac a ˙’ nh nhi . phˆan bˇa ` ng c´ach t´ach m hˆe . sˆo ´ a i th`anh m mˇa . t phˇa ˙’ ng bit; mˆo ˜ imˇa . t phˇa ˙’ ng biˆe ˙’ udiˆe ˜ nmˆo . t bit. Nhu . d¯ ˜a d¯ ˆe ` cˆa . p trong Chu . o . ng 4, mˇa . t phˇa ˙’ ng bit d¯ˆa ` u tiˆen (bˆa . c khˆong) gˆo ` m c´ac bit a 0 ;mˇa . t phˇa ˙’ ng bit bˆa . c(m − 1) ch´u . a c´ac bit a m−1 . N´oi chung, mˆo ˜ imˇa . t phˇa ˙’ ng bit d¯u . o . . c d¯´anh sˆo ´ th ´u . tu . . t`u . 0d¯ˆe ´ n m − 1v`a d¯ u . o . . c xˆay du . . ng bˇa ` ng c´ach d¯ˇa . t c´ac pixel cu ˙’ an´obˇa ` ng c´ac gi´a tri . bit (hay hˆe . sˆo ´ ) th´ıch ho . . pt`u . mˆo ˜ i pixel trong a ˙’ nh gˆo ´ c. Nhu . o . . cd¯iˆe ˙’ mcu ˙’ a c´ach tiˆe ´ pcˆa . n n`ay l`a mˆo . t thay d¯ˆo ˙’ i nho ˙’ vˆe ` gi´a tri . x´am dˆa ˜ nd¯ˆe ´ na ˙’ nh hu . o . ˙’ ng rˆa ´ tl´o . nvˆe ` d¯ ˆo . ph´u . cta . pcu ˙’ a c´ac mˇa . t phˇa ˙’ ng bit. Chˇa ˙’ ng ha . n, nˆe ´ u pixel c´o gi´a tri . 127 (0111111) kˆe ` v´o . i pixel c´o cu . `o . ng d¯ˆo . 128 (1000000) th`ı mˆo ˜ imˇa . t phˇa ˙’ ng bit s˜e ch´u . a liˆen tiˆe ´ p 0 1 (hoˇa . c10). V´ıdu . , v`ı c´ac bit quan tro . ng nhˆa ´ tcu ˙’ ahait`u . m˜a nhi . phˆan 127 v`a 128 kh´ac nhau nˆen mˇa . t phˇa ˙’ ng bit 7 s˜e ch´u . amˆo . t pixel gi´a tri . 0kˆe ´ tiˆe ´ pmˆo . t pixel gi´a tri . 1 v`a s˜e l`am chuyˆe ˙’ n tra . ng th´ai 1 sang 0 (hoˇa . c0 sang 1) ta . i pixel n`ay. D - ˆe ˙’ gia ˙’ ma ˙’ nh hu . o . ˙’ ng thay d¯ˆo ˙’ i nho ˙’ gi˜u . a c´ac gi´a tri . x´am ta c´o thˆe ˙’ biˆe ˙’ udiˆe ˜ na ˙’ nh da . ng m˜a Gray m-bit. M˜a n`ay s˜e biˆe ˙’ udiˆe ˜ n gi´a tri . r th`anh d˜ay nhi . phˆan g m−1 g m−2 g 0 v´o . i g i = a i ⊕ a i+1 ,i=0, 1, ,m−2, g m−1 = a m−1 , trong d¯´o ⊕ k´yhiˆe . u ph´ep to´an OR. M˜a Gray c´o t´ınh chˆa ´ t gia ˙’ i m˜a duy nhˆa ´ t v`a hai t`u . m˜a liˆen tiˆe ´ pchı ˙’ kh´ac nhau d¯´ung mˆo . tvi . tr´ı bit. Do d¯´o khi c´o thay d¯ˆo ˙’ i nho ˙’ trong c´ac 179 m´u . c x´am n´o ´ıt a ˙’ nh hu . o . ˙’ ng d¯ˆe ´ ntˆa ´ tca ˙’ m mˇa . t phˇa ˙’ ng bit. Chˇa ˙’ ng ha . n khi c´ac pixel c´o gi´a tri . 127 v`a 128 kˆe ` nhau th`ı chı ˙’ c´o mˇa . t phˇa ˙’ ng bit th ´u . 7xa ˙’ y ra tra . ng th´ai chuyˆe ˙’ nt`u . 0 sang 1 do c´ac t`u . m˜a Gray cu ˙’ a 127 v`a 128 tu . o . ng ´u . ng l`a 11000000 v`a 01000000. M˜a ho´a v`ung thuˆa ` n nhˆa ´ t D - ˆe ˙’ n´en c´ac a ˙’ nh nhi . phˆan ta c´o thˆe ˙’ su . ˙’ du . ng c´ac t`u . m˜a d¯ˇa . cbiˆe . td¯ˆe ˙’ x´ac d¯i . nh c´ac v`ung liˆen thˆong c´o gi´a tri . x´am 1 hoˇa . c 0. Ch ´ung ta chia a ˙’ nh th`anh c´ac khˆo ´ i c´o k´ıch thu . ´o . c m ×n pixel v`a phˆan loa . i khˆo ´ i tu `y theo tˆa ´ tca ˙’ c´ac gi´a tri . trong v `ung l`a trˇa ´ ng, d¯en hay hˆo ˜ nho . . p. V´o . inh˜u . ng khˆo ´ ithu . `o . ng xuyˆen xuˆa ´ thiˆe . n ta g´an t `u . m˜a l`a 0 v`a hai khˆo ´ i c`on la . i g´an c´ac t`u . m˜a 10 v`a 11. Khi d¯´o v´o . inh˜u . ng v`ung thuˆa ` n nhˆa ´ t (gi´a tri . x´am khˆong d¯ ˆo ˙’ i) s˜e d¯u . o . . c thay bˇa ` ng mˆo . tt`u . m˜a 1-bit hoˇa . ct`u . m˜a 2-bit. D˜ı nhiˆen t`u . m˜a ´u . ng v´o . i c´ac khˆo ´ ihˆo ˜ nho . . pd¯u . o . . c xem nhu . l`a tiˆe ` ntˆo ´ m`a sau d¯´o l`a mˆo . tmˆa ˜ u mn-bit biˆe ˙’ udiˆe ˜ n cho khˆo ´ i. Tru . `o . ng ho . . pnh˜u . ng a ˙’ nh ch´u . a t`ai liˆe . u l`a vˇan ba ˙’ n (k´y tu . . d¯en trˆen nˆe ` n trˇa ´ ng), ta c´o thˆe ˙’ ca ˙’ i biˆen bˇa ` ng c´ach m˜a ho´a c´ac khˆo ´ id¯ˇa . c trˇa ´ ng l`a 0 v`a tˆa ´ tca ˙’ c´ac khˆo ´ i kh´ac (kˆe ˙’ ca ˙’ c´ac khˆo ´ id¯ˇa . c m`au d¯en) l`a 1 theo sau d¯´o l`a mˆa ˜ u bit cu ˙’ a khˆo ´ i. Phu . o . ng ph´ap n`ay (c´o tˆen go . il`abo ˙’ qua khˆo ´ i trˇa ´ ng v`a k´yhiˆe . u WBS-White Block Skipping) cho tı ˙’ lˆe . n´en tˆo ´ t v´o . inh˜u . ng a ˙’ nh biˆe ´ t tru . ´o . cvˆe ` cˆa ´ utr´uc Mˆo . tca ˙’ i biˆen d¯ˇa . cbiˆe . thiˆe . u qua ˙’ cu ˙’ athu ˙’ tu . c n`ay (v´o . i c´ac khˆo ´ ik´ıchthu . ´o . c1× n) l`a m˜a ho´a c´ac d`ong trˇa ´ ng d¯ˇa . cl`a0v`atˆa ´ tca ˙’ c´ac d`ong kh´ac l`a 1 theo sau d˜ay t`u . m˜a WBS. Ch´ung ta c˜ung c´o thˆe ˙’ su . ˙’ du . ng phu . o . ng ph´ap lˇa . p: phˆan chia a ˙’ nh nhi . phˆan th`anh nh˜u . ng v`ung con cho d¯ˆe ´ n khi thoa ˙’ yˆeu cˆa ` u. V´o . i c´ac khˆo ´ i 2-D ta m˜a ho´a a ˙’ nh trˇa ´ ng d¯ˇa . c l`a 0 v`a tˆa ´ tca ˙’ c´ac a ˙’ nh kh´ac d¯u . o . . c chia th`anh c´ac khˆo ´ i con, mˆo ˜ i khˆo ´ i con n`ay d¯u . o . . c g´an tiˆe ` ntˆo ´ l`a 1 v`a sau d¯´o d¯u . o . . c m˜a ho´a tu . o . ng tu . . . T´u . cl`anˆe ´ umˆo . t khˆo ´ i con c´o tˆa ´ tca ˙’ c´ac pixel trˇa ´ ng th`ı n´o d¯u . o . . c m˜a ho´a l`a 10: tiˆe ` ntˆo ´ 1 chı ˙’ ra d¯´o l`a khˆo ´ i con trong ph´ep lˇa . pd¯ˆa ` u tiˆen v`a sˆo ´ 0chı ˙’ ra d¯´o l`a khˆo ´ id¯ˇa . c trˇa ´ ng. Nˆe ´ u khˆo ´ i con khˆong pha ˙’ id¯ˇa . c trˇa ´ ng th`ı ta tiˆe ´ ptu . c phˆan chia cho d¯ˆe ´ n khi k´ıch thu . ´o . ccu ˙’ a khˆo ´ i con d¯a . td¯ˆe ´ n ngu . ˜o . ng n`ao d¯´o v`a d¯u . o . . c m˜a ho´a th`anh 0 (nˆe ´ utˆa ´ tca ˙’ l`a trˇa ´ ng) hoˇa . c l`a 1 theo sau d¯´o l`a mˆa ˜ u bit cu ˙’ a khˆo ´ i. M˜a ho´a run length mˆo . tchiˆe ` u Thuˆa . t to´an run length rˆa ´ td¯o . n gia ˙’ n v`a hiˆe . u qua ˙’ khi su . ˙’ du . ng m˜a ho´a c´ac tˆa . p tin d¯ˆo ` ho . a bitmap. ´ Yco . ba ˙’ n l`a ph´at hiˆe . nsu . . lˇa . pla . i c´ac pixel trˆen mˆo ˜ i h`ang cu ˙’ aa ˙’ nh v`a xuˆa ´ t ra hai gi´a tri . :mˆo . t cho sˆo ´ lˆa ` nlˇa . p v`a mˆo . t cho gi´a tri . pixel lˇa . pthayv`ı xuˆa ´ tt`u . ng gi´a 180 tri . pixel mˆo . t. M˜a ho´a run length khˆong hiˆe . u qua ˙’ d¯ ˆo ´ iv´o . i c´ac mˆa ˜ uchˆa ´ md¯iˆe ˙’ m hoˇa . c c´ac a ˙’ nh d¯u . o . . cqu´et bo . ˙’ i scan (thu . `o . ng khˆong c´o su . . lˇa . pla . i). Ngu . o . . cla . i, run length l`am viˆe . crˆa ´ ttˆo ´ td¯ˆo ´ iv´o . i c´ac kiˆe ˙’ ud˜u . liˆe . u kh´ac v`a d¯u . o . . cd`ung d¯ˆe ˙’ n´en c´ac tˆa . p tin da . ng BMP, PCX, TIFF, Apple MacPaint M˜a ho´a run length mˆo . tchiˆe ` u (RLC) Khi qu´a tr`ınh m˜a ho´a diˆe ˜ n ra, tˆa ´ tca ˙’ c´ac d˜u . liˆe . ud¯u . o . . cqu´et theo t`u . ng h`ang v`a d¯u . o . . c d¯ ˆo ˙’ i th`anh d˜ay c´ac cˇa . p(l k ,g k ) trong d¯´o l k l`a sˆo ´ c´ac pixel kˆe ` nhau c´o c`ung m´u . c x´am g k . Nˆe ´ umˆo ˜ i d`ong qu´et c´o chiˆe ` u d`ai N th`ı 1 ≤ l k ≤ N, do d¯´o (nˆe ´ ud`ung m˜a ho´a tu . . nhiˆen) cˆa ` n log 2 N bit d¯ˆe ˙’ m˜a ho´a c´ac gi´a tri . lˇa . p l k . Nˆe ´ uhˆa ` uhˆe ´ t c´ac gi´a tri . lˇa . p nho ˙’ ho . n nhiˆe ` u so v´o . i N th`ı c´ach m˜a ho´a tu . . nhiˆen khˆong hiˆe . u qua ˙’ .V`ıvˆa . yvˆa ´ nd¯ˆe ` tiˆe ´ p theo l`a cho . n phu . o . ng ph´ap m˜a ho´a c´ac gi´a tri . lˇa . p v`a gi´a tri . x´am sao cho tˆo ´ iu . u. D - iˆe ` u n`ay ho`an to`an phu . thuˆo . cv`aod˜u . liˆe . u ban d¯ˆa ` u. M˜a ho´a run length hai chiˆe ` u (PDQ v`a DDC) cho a ˙’ nh nhi . phˆan Phu . o . ng ph´ap lu . o . . ng tu . ˙’ ho´a sai phˆan du . . b´ao,k´yhiˆe . u PDQ, biˆe ´ nd¯ˆo ˙’ ima ˙’ ng c´ac gi´a tri . x´am hai m´u . c th`anh d˜ay c´ac cˇa . psˆo ´ nguyˆen (∆  , ∆  ), trong d¯´o ∆  := x s 2 − x s 1 l`a hiˆe . ugi˜u . a c´ac ho`anh d¯ˆo . d¯ i ˆe ˙’ m kho . ˙’ id¯ˆa ` ucu ˙’ a c´ac d`ong qu´et trˆen hai d`ong liˆen tiˆe ´ p, v`a ∆  := l 2 − l 1 l`a hiˆe . ugi˜u . a c´ac gi´a tri . lˇa . p trˆen hai d`ong liˆen tiˆe ´ p. Ngo`ai ra ch´ung ta su . ˙’ du . ng thˆem c´ac dˆa ´ uhiˆe . u “new start” v`a “merge” d¯ˆe ˙’ k´yhiˆe . u d`ong bˇa ´ td¯ˆa ` u v`a d`ong kˆe ´ tth´uc cu ˙’ amˆo ˜ iv`ung d¯ˆo ´ itu . o . . ng. Kˆe ´ tiˆe ´ p ta c´o thˆe ˙’ d`ung m˜a B 1 d¯ ˆe ˙’ m˜a ho´a c´ac d¯a . i lu . o . . ng ∆  , ∆  , new start v`a merge. Ch´ung ta c˜ung c´o thˆe ˙’ m˜a ho´a delta k´ep (DDC) bˇa ` ng c´ach su . ˙’ du . ng ∆  v`a ∆  thay cho ∆  v`a ∆  , trong d¯´o ∆  := x e 2 − x e 1 l`a hiˆe . ugi˜u . a c´ac ho`anh d¯ˆo . d¯ i ˆe ˙’ mkˆe ´ tth´uc cu ˙’ a c´ac d`ong qu´et trˆen hai d`ong liˆen tiˆe ´ p. Nhˆa . nx´etrˇa ` ng, v´o . inh˜u . ng d¯ˆo ´ itu . o . . ng d¯en l´o . n, c´ach m˜a ho´a run length hai chiˆe ` u hiˆe . u qua ˙’ ho . n; ngu . o . . cla . i, nˆe ´ u c´o nhiˆe ` uv`ung d¯en nho ˙’ th`ı m˜a ho´a run length mˆo . tchiˆe ` u hiˆe . u qua ˙’ ho . n. 181 6.4.3 M˜a ho´a sai phˆan Phu . o . ng ph´ap n`ay thu . `o . ng su . ˙’ du . ng trong tru . `o . ng ho . . pa ˙’ nh sˆo ´ c´o c´ac gi´a tri . x´am tu . o . ng tu . . ; n´oi c´ach kh´ac, biˆe ˙’ ud¯ˆo ` cˆo . tcu ˙’ aa ˙’ nh tˆa . p trung v`ao mˆo . tv`ung. D - ˆa ` u tiˆen ta biˆe ´ nd¯ˆo ˙’ itˆa . p c´ac gi´a tri . x´am z 0 ,z 1 , ,z N−1 th`anh d˜ay d 0 ,d 1 , ,d N−1 x´ac d¯i . nh bo . ˙’ i  d 0 = z 0 , d i = z i −z i−1 ,i≥ 1. Bu . ´o . ckˆe ´ tiˆe ´ psu . ˙’ du . ng mˆo . t trong c´ac bˆo . m˜a Huffman, m˜a Shift d¯ˆe ˙’ m˜a ho´a d˜ay d i ,i =0, 1, ,N − 1. Chˇa ˙’ ng ha . n, nˆe ´ u d˜ay d i thay d¯ˆo ˙’ i trong pha . mvi[−127, 127] v`a thu . `o . ng tˆa . p trung v`ao khoa ˙’ ng (−8, 8) ta c´o thˆe ˙’ xˆay du . . ng bˆo . m˜a tu . . nhiˆen gˆo ` m16t`u . m˜a c 0 ,c 1 , ,c 15 : trong d¯´o 14 t`u . m˜a c 1 ,c 2 , ,c 14 tu . o . ng ´u . ng 14 gi´a tri . −7, −6, ,−1, 0, 1, ,6; hai t`u . m˜a c`on la . i, c 0 su . ˙’ du . ng d¯ˆe ˙’ d¯´anh dˆa ´ u gi´a tri . d i < −7v`ac 15 d¯´anh dˆa ´ u d i ≥ 7. Nguyˆen tˇa ´ c m˜a ho´a (nhu . m˜a Shift) nhu . sau: 1. nˆe ´ u d i ∈ [−7, 6] ta su . ˙’ du . ng t `u . m˜a tu . o . ng ´u . ng gi´a tri . n`ay. Chˇa ˙’ ng ha . n, −7d¯u . o . . c m˜a ho´a l`a c 1 , −6l`ac 2 v`a vˆan vˆan. 2. nˆe ´ u d i > 6, ta chuyˆe ˙’ ndi . ch theo hu . ´o . ng lˆen. Chˇa ˙’ ng ha . n, 10 d¯u . o . . c m˜a ho´a l`a c 15 c 4 , 25 l`a c 15 c 15 c 5 . 3. tu . o . ng tu . . d¯ ˆo ´ iv´o . i c´ac gi´a tri . nho ˙’ ho . n −7 ta chuyˆe ˙’ ndi . ch theo hu . ´o . ng xuˆo ´ ng. Chˇa ˙’ ng ha . n, −8d¯u . o . . c m˜a ho´a l`a c 0 c 1 , −9l`ac 0 c 2 , −23 l`a c 0 c 0 c 13 . 6.4.4 M˜a ho´a chu tuyˆe ´ n Thuˆa . t to´an m˜a ho´a chu tuyˆe ´ n trong phˆa ` n n`ay gia ˙’ m k´ıch thu . ´o . ca ˙’ nh bˇa ` ng c´ach lu . umˆo . t danh s´ach c´ac chu tuyˆe ´ n. Mˆo ˜ i chu tuyˆe ´ nd¯u . o . . c x´ac d¯i . nh duy nhˆa ´ tbo . ˙’ i: 1. m´u . c x´am cu ˙’ a chu tuyˆe ´ n; 2. vi . tr´ı (h`ang v`a cˆo . t) cu ˙’ amˆo . t pixel trˆen biˆen cu ˙’ a n´o, go . il`ad¯ i ˆe ˙’ m kho . ˙’ ita . o (IP-initial point); v`a 3. mˆo . t d˜ay c´ac hu . ´o . ng cho ph´ep ch´ung ta xˆay du . . ng la . i chu tuyˆe ´ n. Thuˆa . t to´an gˆo ` m hai thu ˙’ tu . c con: 182 . th ´u . 7xa ˙’ y ra tra . ng th´ai chuyˆe ˙’ nt`u . 0 sang 1 do c´ac t`u . m˜a Gray cu ˙’ a 1 27 v`a 128 tu . o . ng ´u . ng l`a 11000000 v`a 01000000. M˜a ho´a v`ung thuˆa ` n nhˆa ´ t D - ˆe ˙’ n´en. mˆo . tt`u . m˜a 1-bit hoˇa . ct`u . m˜a 2-bit. D˜ı nhiˆen t`u . m˜a ´u . ng v´o . i c´ac khˆo ´ ihˆo ˜ nho . . pd¯u . o . . c xem nhu . l`a tiˆe ` ntˆo ´ m`a sau d¯´o l`a mˆo . tmˆa ˜ u mn-bit biˆe ˙’ udiˆe ˜ n cho. ,c 14 tu . o . ng ´u . ng 14 gi´a tri . 7, −6, ,−1, 0, 1, ,6; hai t`u . m˜a c`on la . i, c 0 su . ˙’ du . ng d¯ˆe ˙’ d¯´anh dˆa ´ u gi´a tri . d i < −7v`ac 15 d¯´anh dˆa ´ u d i ≥ 7. Nguyˆen tˇa ´ c m˜a ho´a

Ngày đăng: 06/08/2014, 19:20