29
Practical Image Processing 1 기기기기 6 6 16( 16( ) 11:00 – 12:00 ) 11:00 – 12:00 기기 기기 : : 기기기기 기기기기 ( ( 기기 기기 ), ), 기기기기기기 기기기기기기 , , 기기 기기 기기 기기 : 1102 ( : 1102 ( 기기 기기 . . 기기 기기기 기기 기기 기기 기기기 기기 기기 ) ) ( ( 기기 기기기기 기기기기 기기 기기 기기기기 기기기기 기기 ) )

Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Embed Size (px)

Citation preview

Page 1: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 1

기말고사 66 월 월 16(16( 목목 ) 11:00 – 12:00) 11:00 – 12:00 범위 범위 : : 영역처리영역처리 (( 모두모두 ), ), 기하학적처리기하학적처리 , ,

압축 압축 장소 장소 : 1102 (: 1102 ( 신청신청 . . 아직 확정된 것은 아님아직 확정된 것은 아님 ))

( ( 학교 홈페이지 참조하기 바람학교 홈페이지 참조하기 바람 ))

Page 2: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 2

Chap.9 Image Compression Image : huge data size if not compressedImage : huge data size if not compressed

1MB/page at 300dpi 1MB/page at 300dpi 25 GB for 25,000 pages 25 GB for 25,000 pages 512x512 color, 30 frame/sec 512x512 color, 30 frame/sec 23.6 MByte/sec 23.6 MByte/sec 2 hours moving images 2 hours moving images 169 GBytes 169 GBytes

Compression : international standardsCompression : international standards binary image : group3, group4 – faxbinary image : group3, group4 – fax still image : JPEGstill image : JPEG moving image : H.261, MPEG-I, MPEG-IImoving image : H.261, MPEG-I, MPEG-II

Lots of applications : storage and transmissionLots of applications : storage and transmission video teleconferencing, remote sensing, document, medvideo teleconferencing, remote sensing, document, med

ical images, fax, multimedia contentsical images, fax, multimedia contents

Page 3: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 3

Data compressionData compression process of reducing the amount of data required to reprprocess of reducing the amount of data required to repr

esent a given quantity of information esent a given quantity of information (( 정보량을 표현하는 정보량을 표현하는 데이터 양을 줄이는 과정데이터 양을 줄이는 과정 ))

done by reducing or eliminating data redundancy done by reducing or eliminating data redundancy ((데이터에 중복성이 있다는 성질을 이용데이터에 중복성이 있다는 성질을 이용 ))

compression ratio : Ccompression ratio : CRR = original / compressed = original / compressed

lossless compression, lossy compression lossless compression, lossy compression (( 손실압축손실압축 , ,

무손실 압축무손실 압축 )) Data redundancies (Data redundancies ( 데이터 중복성데이터 중복성 ))

coding redundancy coding redundancy (( 코딩중복성코딩중복성 )): Huffman coding: Huffman coding interpixel redundancy interpixel redundancy (( 화소간 중복성화소간 중복성 )): Runlength coding: Runlength coding Psychovisual redundancy Psychovisual redundancy (( 시각 심리적 중복성시각 심리적 중복성 )): improved : improved

gray-scale (IGS) quantizationgray-scale (IGS) quantization

Page 4: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 4

terminologiesterminologies character - fundamental data element in input character - fundamental data element in input

streamstream string - sequence of charactersstring - sequence of characters input stream - source of uncompressed data, input stream - source of uncompressed data,

sometimes data file or communication mediumsometimes data file or communication medium codeword - data element used to represent input codeword - data element used to represent input

character or character stringcharacter or character string

Page 5: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 5

Run Length Coding (RLC)

utilize utilize repetitiveness of datarepetitiveness of data : run : run ex) AAAABBBBBCCCCCCCCDEEEEex) AAAABBBBBCCCCCCCCDEEEE

4A5B8C1D4E (C4A5B8C1D4E (CRR = 22/10 = 2.2) = 22/10 = 2.2)

ex) binary imageex) binary image0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 88 8(0)8(0) 0 01 1 1 1 0 0 0 01 1 1 1 0 0 0 0 0, 4, 40, 4, 4 4(1), 4(0)4(1), 4(0) 1[(0, 3)] 1[(0, 3)]0 1 1 0 0 0 0 00 1 1 0 0 0 0 0 1, 2, 51, 2, 5 1(0), 2(1), 5(0) 1[(1, 2)]1(0), 2(1), 5(0) 1[(1, 2)]0 1 1 1 1 1 0 00 1 1 1 1 1 0 0 1, 5, 21, 5, 2 1(0), 5(1), 2(0) 1[(1, 5)]1(0), 5(1), 2(0) 1[(1, 5)]0 1 1 1 0 0 1 00 1 1 1 0 0 1 0 1, 3, 2, 1, 11, 3, 2, 1, 1 2[(1, 3), (6, 6)] 2[(1, 3), (6, 6)]0 0 1 0 0 1 1 00 0 1 0 0 1 1 0 2, 1, 2, 2, 12, 1, 2, 2, 1 ..... ..... .... ....1 1 1 1 0 1 0 01 1 1 1 0 1 0 0 0, 4, 1, 1, 20, 4, 1, 1, 20 0 0 0 0 0 0 00 0 0 0 0 0 0 0 88

Page 6: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 6

gray imagegray image cartoon, drawing by paintbrushcartoon, drawing by paintbrush MacPaint, PCX, MacPaint, PCX, TIFF, TGA (optional)TIFF, TGA (optional) ex) MacPaint : prefix + count + dataex) MacPaint : prefix + count + data

prefix (MSB) : 1 repeating, 0 independent dataprefix (MSB) : 1 repeating, 0 independent data count (7bits) : # of repeating (or independent) datacount (7bits) : # of repeating (or independent) data data (variable size) : repeating pattern or sequence of indata (variable size) : repeating pattern or sequence of in

dependant datadependant data

Page 7: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 7

Huffman Coding variable length code variable length code (( 가변길이 코딩가변길이 코딩 )): length is inversely proportio: length is inversely proportio

nal to that character’s frequency nal to that character’s frequency (character(character 의 빈도수가 많으면 코드 의 빈도수가 많으면 코드 길이 짧게길이 짧게 ))

two pass algorithmtwo pass algorithm first pass : codebook creation from frequency table (first pass : codebook creation from frequency table ( 빈도수 테이블을 빈도수 테이블을

이용해서 이용해서 codebook codebook 생성생성 )) second pass : compression with the codebooksecond pass : compression with the codebook

Codebook creation : by constructing a binary treeCodebook creation : by constructing a binary tree1. consider all characters as free nodes (1. consider all characters as free nodes ( 모드 모드 charactercharacter 를 자유노드로를 자유노드로 ))2. assign two free nodes with lowest frequency to a parent nodes with wei2. assign two free nodes with lowest frequency to a parent nodes with wei

ghts equal to sum of their frequencies (ghts equal to sum of their frequencies ( 빈도수 작은 자유노드 두개 빈도수 작은 자유노드 두개 합해 부모 노드 만듬합해 부모 노드 만듬 ))

3. remove the two free nodes and add the newly created parent node to t3. remove the two free nodes and add the newly created parent node to the list of free nodeshe list of free nodes

4. repeat step2 and 3 until there is one free node left. It becomes the root 4. repeat step2 and 3 until there is one free node left. It becomes the root of treeof tree

Page 8: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 8

Symbol Freq.Symbol Freq. 11 2 2 3 3 4 4 5 5

R 19 19 19 19 28 36

K 17 17 17 17 19 28

G 16 16 16 16 17

B 5 5 7 12

C 4 4 5

M 2 3

Y 1

Binary tree construction

Source reductionSource reduction

Page 9: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 9

0 1

00 01

Page 10: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 10

Symbol Freq.(Symbol Freq.( 빈도수빈도수 )) 11 2 2 3 3 4 4 5 5

R 00 19 19 19 19 28 1 36 0

K 01 17 17 17 17 19 00 28 1

G10 16 16 16 16 17 01

B111 5 5 7 12

C1100 4 4 5

M11010 2 3

Y11011 1

Codebook construction

code assignment on the treecode assignment on the tree

원영상 : 64*8 = 512 bits

부호화 : 19*2+17*2+16*2+5*3 +4*4+2*5+1*5 = 150 bits

Page 11: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 11

Modified Huffman Coding

used in facsimile transmissionsused in facsimile transmissions use one fixed table, and combine variable use one fixed table, and combine variable

length encoding and run length encoding length encoding and run length encoding encode each line as a series of alternating encode each line as a series of alternating

runs of white and black bitsruns of white and black bits count runs of white bits and black bits and count runs of white bits and black bits and

convert the counts as a variable length bit convert the counts as a variable length bit stream stream

Page 12: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 12

assign terminating codes for runs of 63 or less assign terminating codes for runs of 63 or less (table 9. 4)(table 9. 4)

assign for runs of 64 or greater makeup codes assign for runs of 64 or greater makeup codes (table 9. 5) followed by terminating codes(table 9. 5) followed by terminating codes makeup codes are to describe runs in multiple of makeup codes are to describe runs in multiple of

64 from 64 to 256064 from 64 to 2560 assign a special code for EOL(000000000001)assign a special code for EOL(000000000001)

Page 13: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 13

modified READ : modified READ : skipskip 2-dim run length coding for bilevel bitmap 2-dim run length coding for bilevel bitmap exploit transitions that begin and end each blacexploit transitions that begin and end each blac

k and white runk and white run encode the first line of a set of K scanlines with encode the first line of a set of K scanlines with

modified Huffman and remaining lines with refemodified Huffman and remaining lines with reference to the line above itrence to the line above it

Page 14: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 14

notationsnotations• a0:- starting changing element on the coding linea0:- starting changing element on the coding line• a1:- next transition to the right of a0 on coding linea1:- next transition to the right of a0 on coding line• a2:- next transition to the right of a1 on coding linea2:- next transition to the right of a1 on coding line• b1:- next changing element to the right of a0 on b1:- next changing element to the right of a0 on

reference linereference line• b2:- next transition to the right of b1 on reference lineb2:- next transition to the right of b1 on reference line

three different coding modethree different coding mode• pass mode:- when b2 lies to the left of a1pass mode:- when b2 lies to the left of a1• vertical mode:- when a1 is within 3 pixels to the left vertical mode:- when a1 is within 3 pixels to the left

or right of b1or right of b1• horizontal mode:- when neither pass nor vertical horizontal mode:- when neither pass nor vertical

modemode

codes for the three modecodes for the three mode

Page 15: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 15

pass 0001pass 0001

vertical a1 under b1 1vertical a1 under b1 1

a1 1 pixel to the right of b1 011a1 1 pixel to the right of b1 011

a1 2 pixels to the right of b1 000011a1 2 pixels to the right of b1 000011

a1 3 pixels to the right of b1 0000011a1 3 pixels to the right of b1 0000011

horizontal 001+M(a0a1)+M(a1a2)horizontal 001+M(a0a1)+M(a1a2)

Page 16: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 16

LZW Compression A. Lempel + J. Zip, T. WelchA. Lempel + J. Zip, T. Welch string table <--> character table (Huffman)string table <--> character table (Huffman) ex) 12 bit codewords : 4096 itemsex) 12 bit codewords : 4096 items

first 256 locations : single charactersfirst 256 locations : single characters locations 256-4096 : string locations 256-4096 : string parse input characters to form stringsparse input characters to form strings

compressed data only <--> compressed data only <--> compressed data + code table (Huffman)compressed data + code table (Huffman)

no prior information about input stream <--> no prior information about input stream <--> decoder creates the same string table during decompredecoder creates the same string table during decompre

ssionssion single pass : fast <--> two pass (Huffman)single pass : fast <--> two pass (Huffman)

Page 17: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 17

Compression algorithmCompression algorithminitialize string table with single character stringsinitialize string table with single character stringsSTRING = STRING = NullNullWHILEWHILE not end of input stream not end of input stream CHARACTER = next input characterCHARACTER = next input character IFIF STRING+CHARACTER is in the string table STRING+CHARACTER is in the string table // string table // string table 탐색탐색 STRING = STRING+CHARACTERSTRING = STRING+CHARACTER ELSEELSE // string table// string table 에 없는 에 없는 stringstring 은 이쪽으로은 이쪽으로 output code for STRINGoutput code for STRING add STRING+CHARACTER to the string table add STRING+CHARACTER to the string table // string table// string table 에 추가에 추가 STRING = CHARACTER STRING = CHARACTER // // 다음 다음 stringstring 은 은 stringstring 의 맨 끝 문자부터의 맨 끝 문자부터ENDEND WHILEWHILEoutput code for STRINGoutput code for STRING

Ex) BABAABAAA Ex) BABAABAAA CHARACTERCHARACTER//outputoutput//string_tablestring_table 추가추가 //STRING STRING (break point : END WHILE)(break point : END WHILE) BB//__//__//BB AA//BB//BABA//AA BB//AA//ABAB//BB AA//__//__//BABA A A//BABA//BAABAA//AA BB//__//__//ABAB AA//ABAB//ABAABA//AA AA//AA//AAAA//AA AA//__//__//AAAA AAAA

string_table : BA(256), AB(257), BAA(258), ABA(259), AA(260)string_table : BA(256), AB(257), BAA(258), ABA(259), AA(260) output codes : <66><65><256><257><65><260> output codes : <66><65><256><257><65><260>

Page 18: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

18

Decompression algorithmDecompression algorithminitialize string table with single character stringsinitialize string table with single character stringsOLD_CODE = first input character; output translation of OLD_CODEOLD_CODE = first input character; output translation of OLD_CODEWHILEWHILE not end of input stream not end of input stream NEW_CODE = next input characterNEW_CODE = next input character IFIF NEW_CODE is not in the string table NEW_CODE is not in the string table // string table// string table 에 없으면에 없으면 STRING = translation of OLD_CODESTRING = translation of OLD_CODE STRING = STRING+CHARACTERSTRING = STRING+CHARACTER ELSE // string tableELSE // string table 에 있으면에 있으면 STRING = translation of NEW_CODESTRING = translation of NEW_CODE output STRINGoutput STRING CHARACTER = first character of STRINGCHARACTER = first character of STRING add OLD_CODE+CHARACTER to the string table add OLD_CODE+CHARACTER to the string table // string table// string table 에 추가에 추가 OLD_CODE = NEW_CODE OLD_CODE = NEW_CODE ENDEND WHILEWHILE

Ex) Ex) <66><65><256><257><65><260><66><65><256><257><65><260> NEW_CODENEW_CODE//STRING(output)STRING(output)//CHARACTERCHARACTER//string_tablestring_table 추가 추가 (break point : END WHILE)(break point : END WHILE)

((__//BB//__//__) ) <65><65>//AA//AA//BA(256) BA(256) <256><256>//BABA//BB//AB(257)AB(257) <257><257>//ABAB//AA//BAA(258)BAA(258) <65><65>//AA//AA//ABA(259)ABA(259) <260><260>//AAAA//AA//AA(260)AA(260)

output stream : BABAABAAAoutput stream : BABAABAAA

Page 19: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 19

Arithmetic Coding input : whole input data streaminput : whole input data stream

output : one floating point number between 0 and 1output : one floating point number between 0 and 1 two pass algorithmtwo pass algorithm

first pass : computes characters’ frequency and first pass : computes characters’ frequency and constructs constructs probability tableprobability table with ranges assigned to each with ranges assigned to each entry of the tableentry of the table

second pass : second pass : actual compressingactual compressing. first character of . first character of input stream constrains output number to its input stream constrains output number to its corresponding range, and the range of next character of corresponding range, and the range of next character of input stream further constrains the number, and so on.input stream further constrains the number, and so on.

decoding is reverse of encodingdecoding is reverse of encoding higher compression ratio than Huffman, but slowerhigher compression ratio than Huffman, but slower

Page 20: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 20

Compression algorithmCompression algorithmLow = 0.0Low = 0.0High = 1.0High = 1.0WHILEWHILE not end of input stream not end of input stream get next CHARACTERget next CHARACTER RANGE = HIGH - LOWRANGE = HIGH - LOW HIGH = LOW + RANGE * high range of CHARACTERHIGH = LOW + RANGE * high range of CHARACTER LOW = LOW + RANGE * low range of CHARACTERLOW = LOW + RANGE * low range of CHARACTEREND WHILEEND WHILEoutput LOWoutput LOW

Ex) ARITHMETICEx) ARITHMETICProbability table : symbol Probability table : symbol prob. [range. low-high]prob. [range. low-high]

A A 0.1 [0.0-0.1]0.1 [0.0-0.1] C C 0.1 [0.1-0.2]0.1 [0.1-0.2] E E 0.1 [0.2-0.3]0.1 [0.2-0.3] H H 0.10.1 [0.3-0.4][0.3-0.4] I I 0.2 [0.4-0.6]0.2 [0.4-0.6] M M 0.1 [0.6-0.7]0.1 [0.6-0.7] R R 0.1 [0.7-0.8] 0.1 [0.7-0.8] T T 0.2 [0.8-1.0]0.2 [0.8-1.0]

compresson : symbol compresson : symbol range [low-high]range [low-high] AA 1.0[0.0-0.1] 1.0[0.0-0.1] RR 0.1[0.07-0.08] 0.1[0.07-0.08] II 0.01[0.074-0.076] 0.01[0.074-0.076] TT 0.002[0.0756-0.076] 0.002[0.0756-0.076] HH 0.0004[0.07572-0.07576] 0.0004[0.07572-0.07576] MM 0.00004[0.075744-0.075748] 0.00004[0.075744-0.075748] EE 0.000004[0.0757448-0.0757452] 0.000004[0.0757448-0.0757452] TT 0.0000004[0.07574512-0.0757452] 0.0000004[0.07574512-0.0757452] II 0.00000008[0.075745152-0.07574 0.00000008[0.075745152-0.07574

5168] 5168] CC 0.000000016[ 0.000000016[0.07574515360.0757451536-0.0757451552]-0.0757451552]

Page 21: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 21

Decompression algorithmDecompression algorithmget NUMBERget NUMBERDODO find CHARACTER that has LOW < NUMBER < HIGHfind CHARACTER that has LOW < NUMBER < HIGH set HIGH and LOW corresponding to CHARACTERset HIGH and LOW corresponding to CHARACTER output CHARACTERoutput CHARACTER RANGE = HIGH - LOWRANGE = HIGH - LOW NUMBER = NUMBER - LOWNUMBER = NUMBER - LOW NUMBER = NUMBER / RANGENUMBER = NUMBER / RANGEUNTIL UNTIL no more CHARACTERSno more CHARACTERS

Ex) Ex) 0.07574515360.0757451536 Probability table : symbol Probability table : symbol prob. [range. low-high]prob. [range. low-high] A A 0.1 [0.0-0.1]0.1 [0.0-0.1] C C 0.1 [0.1-0.2]0.1 [0.1-0.2] E E 0.1 [0.2-0.3]0.1 [0.2-0.3] H H 0.10.1 [0.3-0.4][0.3-0.4] I I 0.2 [0.4-0.6]0.2 [0.4-0.6] M M 0.1 [0.6-0.7]0.1 [0.6-0.7] R R 0.1 [0.7-0.8] 0.1 [0.7-0.8] T T 0.2 [0.8-1.0]0.2 [0.8-1.0] compresson : compresson : NUMBERNUMBER output output 0.0757451536 0.0757451536 AA 0.757451536 0.757451536 RR 0.57451536 0.57451536 II 0.8725768 0.8725768 TT 0.362884 0.362884 HH 0.62884 0.62884 MM 0.2884 0.2884 EE 0.884 0.884 TT 0.42 0.42 II 0.1 0.1 CC

Page 22: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 22

JPEG still-image compression standardstill-image compression standard has 3 lossless modes and 1 lossy modehas 3 lossless modes and 1 lossy mode

sequential baseline encodingsequential baseline encoding encode in one scanencode in one scan input & output data precision is limited to 8 bits, while quantized input & output data precision is limited to 8 bits, while quantized

DCT values are restricted to 11 bitsDCT values are restricted to 11 bits progressive encoding : multiple scan lineprogressive encoding : multiple scan line hierarchical encoding : multiple resolutionhierarchical encoding : multiple resolution lossless encodinglossless encoding

can achieve compression ratios of upto 20 to 1 witcan achieve compression ratios of upto 20 to 1 without noticeable reduction in image qualityhout noticeable reduction in image quality

Page 23: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 23

raw : ~ 250kBytes

GIF : 80kBytes

JPG : 14kBytes

Page 24: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 24

good for continuous images, but not good for good for continuous images, but not good for cartoons or computer generated imagescartoons or computer generated images

tend to filter out high frequency datatend to filter out high frequency data can specify a quality level (Q)can specify a quality level (Q)

too low Q : blocky, contouring and ringing too low Q : blocky, contouring and ringing

5 steps of sequential baseline encoding5 steps of sequential baseline encoding transform image to YCbCrtransform image to YCbCr reduce the color components (optional)reduce the color components (optional) partition image into 8x8 pixel blocks and perform Dpartition image into 8x8 pixel blocks and perform D

CT on each blockCT on each block quantize resulting DCT coefficientsquantize resulting DCT coefficients variable length code the quantized coefficientsvariable length code the quantized coefficients

Page 25: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 25

step1 : RGB to YCstep1 : RGB to YCbbCCrr conversion conversion separate luminance and chrominance separate luminance and chrominance

step2 : subsample color componentsstep2 : subsample color components average 2x2 block of color componentsaverage 2x2 block of color components human eye is less sensitive to colorhuman eye is less sensitive to color

step3 : tiling and DCTstep3 : tiling and DCT partition image into 8x8 pixel blocks (tiles)partition image into 8x8 pixel blocks (tiles) convert elements in a tile to signed integers by subtrconvert elements in a tile to signed integers by subtr

acting one half of gray scaleacting one half of gray scale (0,0) element of DCTed block is DC and other elem(0,0) element of DCTed block is DC and other elem

ents are ACents are AC DC element is encoded by the difference from the DDC element is encoded by the difference from the D

C of the previous block C of the previous block

Page 26: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 26

step4 : quantization of DCT coefficients step4 : quantization of DCT coefficients quantize and threshold byquantize and threshold by

T*(u,v) = round [ T(u,v) / Z(u,v)]T*(u,v) = round [ T(u,v) / Z(u,v)]

T(u,v) = DCT coefficientT(u,v) = DCT coefficient

Z(u,v) = quantization coefficient (table 9.6, 9.7)Z(u,v) = quantization coefficient (table 9.6, 9.7)

T*(u,v) : thresholded & quantized approximation T*(u,v) : thresholded & quantized approximation of T(u,v) of T(u,v)

reorder quantized coefficients using zigzag patternreorder quantized coefficients using zigzag pattern(fig. 9.14)(fig. 9.14)

Page 27: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 27

step5 : variable length codingstep5 : variable length coding DC coefficient is difference coded relative to DC cDC coefficient is difference coded relative to DC c

oefficient of previous subimageoefficient of previous subimage AC coefficients are broken into runs of zeros endinAC coefficients are broken into runs of zeros endin

g in a nonzero number. Each broken block is to be g in a nonzero number. Each broken block is to be variable length codedvariable length coded

classify each coefficient into some categories baseclassify each coefficient into some categories based on its ranged on its range

run length and category specifies basecode and thrun length and category specifies basecode and the number of bits of a code e number of bits of a code

determine taling bits of a code considering least sidetermine taling bits of a code considering least significant bits of coefficientgnificant bits of coefficient apply one’s complement to specify sign of the capply one’s complement to specify sign of the c

oefficientoefficient

Page 28: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 28

ExampleExample

image (8 x 8 block)

52 55 61 66 70 61 64 73

63 59 66 90 109 85 69 72 62 59 68 113 144 104 66 73 63 58 71 122 154 106 70 69

67 61 68 104 126 88 68 70 79 65 60 70 77 68 58 75 85 71 64 59 55 61 65 83 87 79 69 68 65 76 78 94

image - 128

-76 -73 -67 -62 -58 -67 -64 -55

-65 -69 -62 -38 -19 -43 -59 -56-66 -69 -60 -15 16 -24 -62 -55-65 -70 -57 -6 26 -22 -58 -59

-61 -67 -60 -24 -2 -40 -60 -58-49 -63 -68 -58 -51 -65 -70 -53-43 -57 -64 -69 -73 -67 -63 -45-41 -49 -59 -60 -63 -52 -50 -34

DCT (of image-128)

-415 -29 -62 25 55 -20 -1 3

7 -21 -62 9 11 -7 -6 6-46 8 77 -25 -30 10 7 -5-50 13 35 -15 -9 6 0 3

11 -8 -13 -2 -1 1 -4 1-10 1 3 -3 -1 0 2 -1 -4 -1 2 -1 2 -3 1 -2 -1 -1 -1 -2 -1 -1 0 -1

quantized coefficients

-26 -3 -6 2 2 0 0 0

1 -2 -4 0 0 0 0 0 -3 1 5 -1 -1 0 0 0 -4 1 2 -1 0 0 0 0

1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

round(-29/11(table 9.6)) = -3

zigzag order (fig. 9. 14): -26 -3 1 -3 -2 -6 2 -4 1 -4 1 1 5 0 2 0 0 -1 2 0 0 0 0 0 -1 -1 EOB

Page 29: Practical Image Processing1 기말고사 6 월 16( 목 ) 11:00 – 12:00 범위 : 영역처리 ( 모두 ), 기하학적처리, 압축 장소 : 1102 ( 신청. 아직 확정된 것은

Practical Image Processing 29

Example : variable length codingExample : variable length codingprevious block -34 ...... fig. 9. 15zigzag ordering -31 0 -2 -1 -1 -1 0 0 -1 -1 0 .... 0 EOB

DC difference -31 – (-34) = 3 : Length=2 table 9.8, Code = 011 table 9.9 Integer value(VLI) = 11 table 9.8 011110 -2 run = 1 (# of previous 0’s), value = -2 (Length = 2 table 9.8) Code = 11011 table 9.11 VLI = 01 table 9.8 1101101-1 run = 0, value = -1 (Length = 1, VLI = 0) 0000 0 -1 run = 2, value = -1 (Length = 1, VLI = 0) 1110000 ... 0 EOB : EOB (run = 0, value = 0) 1010

512 bits 34 bits