Lecture11 Print

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

5/22/24

DEPARTMENT OF PHYSICS

MEDICAL IMAGE PROCESSING


MASTERS DEGREE IN BIOMEDICAL ENGINEERING

Ricardo Vigário
(r.vigario@fct.unl.pt)

QUICK RECAP
2 Image coding

q Image coding and data compression


q Basic considerations
q redundancies and the degree of information loss
q measures of distortion and fidelity
q key concepts
q alphabet; word; code
q lossy; lossless; fidelity and similarity measures
q Direct source coding
q applied directly to pixel values, generated by the source
q without processing them to generate different series of values
q Huffman coding
q Run-length coding
1 1 1 1 1 1 1 1 1 2 2 2 2 2 3 0 0 → (1, 8); (2, 5); (3, 1); (0, 2)
q Arithmetic coding
Huffman
shorter codes for highly probable words

1
5/22/24

EXPECTED FLOW
3 Image coding / compression

q Image coding and data compression


q Direct source coding
q Huffman coding
q Run-length coding
q Arithmetic coding
q Lempel-Ziv-Welch coding
q contour coding
q Exploiting K-space properties
q Transform coding
q discrete cosine transform (DCT)
q Principal Component Analysis (PCA) and Karhunen-Loeve transform
q Interpolative coding
q Predictive coding

ARITHMETIC CODING
4 Remembering this one… with correct explanations as well J

q Symbols treated as magnitudes


q Shannon — string of symbols as the sum of scaled probabilities
q Unlike Hoffman — each symbol does not have a unique code word with,
at least one bit of length
q Arithmetic coding
q symbols of the source string
given by individual prob., 𝑝-
and the cumulative prob., 𝑃-
q coding starts from a certain
source string, represented by
a code point 𝐶. and an
interval 𝐴.
q new symbol is a scaling of
the current symbol, 𝐴./0 = 𝐴. 𝑝- , and the new code point is given as
𝐶./0 = 𝐶. + 𝑃-

2
5/22/24

ARITHMETIC EXAMPLE
5 Remembering this one… with correct explanations as well J

q How does string 4 6 5 gets codded?


q Notice the intervals, given from the table

q Initializing with 𝐶! = 0 and 𝐴! = 1


q 𝐶" = 𝐶! + 𝐴! 𝑃# = 0.66
q 𝐴" = 𝐴! 𝑝# = 0.13
q 4 = 𝐶" , 𝐶" + 𝐴" = [0.66, 0.79)
q 4, 6 = 𝐶" + 𝐴" 𝑃$ , 𝐶" + 𝐴" 𝑃$ + 𝐴" 𝑝$ = [0.7783, 0.7887)
!

!
𝐶! 𝐶! 𝐴"#$

ARITHMETIC EXAMPLE
6 Back to the eye

q Compression — encode long strings of symbols

3
5/22/24

LEMPEL-ZIV(-WELCH) CODING
7 Yet another one…

q Universal coding scheme for discrete source


q Even when their probabilities are not known a priori
q May also be used to assess complexity level of a signal / image
q From variable length words to fixed length code words
q Can be seen as a search
q Through a fixed-size
q Variable-content dictionary
q For words that match current string
q (-Welch) is a variation of LZ, where new strings are added to
the dictionary whenever they are found from the text

LEMPEL-ZIV — AN EXAMPLE
8 Back to the eye

q Build a dictionary with symbols 0 to 7


q Add new symbol for a combination
that has not been seen
q Ex: if we consider string {2, 2} as 8,
the new string {2, 2, 3} can be viewed
as 9, or 83, ie., “3” with prefix “8”

q Idea:
q Start scanning,
q Do not repeat a
“basic” symbol
q Add new symbols
to the dictionary
as they appear

4
5/22/24

CONTOUR CODING
9 Follow the leader...

q Assumption: contours within an image probably consist of pixels


which have same grey-values
q The complete contour may be represented as
q A starting point of the contour
q A sequence of steps — eg., Freeman code
q 0 = right; 1 = up; 2 = left; 3 = down
q Remember to record the contour’s grey value as well
q Consistent rule for finding contours is required:
q Left-most-looking rule is a possibility
q Check left pixel, relative to the direction of entry
q if same grey-value, add the code to contour and proceed
q if not, check pixel ahead, ... etc

THE EXAMPLE FOR CONTOUR CODING


10 The eye

q Contour starting at upper-left corner — [1, 1]


q Grey level: 1
q Freeman code:
0000000003030303022221212233201122122212
q Contour coding:
q originally — 41 ∗ 3 = 123𝑏𝑖𝑡𝑠
q 4 + 4 + 3 + 40 ∗ 2 = 91𝑏𝑖𝑡𝑠 — 74%
q 4 per coordinate; 3 for grey level
q total number of symbols coded: 41
q With [5, 8]
q Grey level: 2
q Freeman code:
0330221201
q With [9, 1]
q Grey level: 1
q Freeman code:
03303233121111

10

5
5/22/24

EXPLORING K-SPACE
11 Back to frequencies?

q Centre
q Low frequency
q Most of contrast
q Most of the signal

q Surround
q High frequency
q Details, edges & noise
q Weak signal

11

LOW AND HIGH FREQUENCIES


12 Not stuck in details

q Contrast and tissue information available in small area in K-space

12

6
5/22/24

TRANSFORM CODING
13 General framework

q Using orthogonal transforms


q Related coefficients represent elements that are mutually uncorrelated
q Compress the energy of the image into a narrow region

q Most natural images have limitations on the rate of change of their


elemental values
q Energy confined to narrow, low-frequency, range in the transform domain

q Most used decorrelation techniques


q Differentiation — remove commonalities present between adjacent elements
q Transform into another domain — Fourier; Discrete Cosine;…
q Model-based prediction — prediction error with reduced error content
q Interpolation

13

KARHUNEN-LOÈVE TRANSFORM (KLT)


14 Well… PCA, really J

q The many names of a successful mathematical tool


q KLT
q Principal Component Analysis (PCA)
q Hotelling transform
q Eigenvector transform
q Image may be treated as a vector 𝒇
q Realization of an image-generation stochastic process
q The 𝑀×𝑁 dimensions of an image lead to a 𝑃 = 𝑀𝑁 dimensional vector
q The process
q Calculate the Cov 𝒇
q Its eigenvalues and vectors
q Parameters can be encoded, improving the compression reached

14

7
5/22/24

NON-PC/MEDICAL IMAGE EXAMPLE


15 Will change this for next years’ courses

Original Data 2 PC’s Reconstruction using 2 PC’s

(≈ 3%)
4 PC’s

(≈ 6%)

8 PC’s

(≈ 13%)

15

NON-PC/MEDICAL IMAGE EXAMPLE


16 Will change this for next years’ courses

Original Data 2 PC’s Reconstruction using 4 PC’s

(≈ 3%)
(≈ 3%)
4 PC’s

(≈ 6%)

8 PC’s

(≈ 13%)

16

8
5/22/24

NON-PC/MEDICAL IMAGE EXAMPLE


17 Will change this for next years’ courses

Original Data 2 PC’s Reconstruction using 8 PC’s

(≈ 3%)
4 PC’s

(≈ 6%)
8 PC’s

(≈ 13%)

17

INTERPOLATIVE CODING
18 There and back again

q From an original image


q Sub-sample it
q Requires lower code-length than the original one
q Interpolate to the original detail
q Compare both original and interpolated
q An error can be calculated
q Two images can be coded
q The sub-sampled
q The error committed in the process
q Both recorded images have shorter codelengths
q Efficient error coded via Direct Source Coding, as with Lempel-Ziv(-Welch)
q As resolution increases, variance of the difference decreases, as pixels are
more correlated to their immediate neighbours than with farther ones

18

9
5/22/24

LINEAR PREDICTIVE (LP) CODING


19 Code the prediction and the error committed

q Real-life signals and images bear a high degree of correlation,


especially over small intervals of time and space
q In 1D, a sample of 𝒇 can be estimated
I

𝒇6 𝑛 = − 9 𝑎 𝑝 𝑓 𝑛 − 𝑝 + 𝐺𝑑 𝑛
GH0
q 𝑎 𝑝 are the coefficients of the LP model
q 𝐺 and 𝑑 𝑛 are, respectively, the gain and driver of an Autoregressive
Model that generates 𝒇
q Can be generalized to a 2D signal, such as an image
𝑓> 𝑚, 𝑛 = − 9 9 𝑎 𝑝, 𝑞 𝑓 𝑚 − 𝑝, 𝑛 − 𝑞
G,J ∈LMN
q 𝑅𝑂𝑆 are the samples used to predict the current pixel value

19

LP CODING AND ERROR COMMITTED


20

q The error can be defined as


𝑒 𝑚, 𝑛 = 𝑓 𝑚, 𝑛 − 𝑓2 𝑚, 𝑛
q With the Mean Square Error (MSE) defined as
𝜖 ' = 𝐸 𝑒 ' 𝑚, 𝑛
q The expected value is often approximated by the samples’ mean
q Exact reconstruction — lossless reconstruction — requires storage of
q Initial conditions
q Model coefficients
q But also the prediction error
q LP-based image compression’s advantage
q Error image tends to have a more concentrated PDF than original image
q Hence… more efficiently compressible

20

10
5/22/24

LP IN SUMMARY & RLS PREDICTION


21

q Based on stationarity assumptions of the image-generating process


q Not universally valid in the case of natural / medical images

q What to do when that is not the case?


q Partition the original image into blocks or Regions of Interest (ROI) — eg., via
Region Growing
q Compute the prediction coefficients independently for each ROI

q Curiosity: RLS is another way to solve the non-stationarity


q Based on adaptive filter theory — parameters are variable
q Wiener and Kalman filtering can be used, but not so efficient
q A better approach, deterministic in its formulation, involves the minimization
of a weighted sum of prediction errors

21

SMALL COMPARISON OF CODING METHODS


22 A rather quick overview

22

11
5/22/24

SCANNING AN IMAGE
23 From 2D to 1D

q Vectorize an image,
while preserving
neighbouring relations

23

PEANO-HILBERT CURVE
24 From 2D to 1D

q Some desirable properties of the Peano-Hilbert curve


q Although not differentiable, the curve is continuous
q Fills the 2D space without passing through any point more than once
q Recursive scanning of an image, quadrant by quadrant
q Preservation of the local 2D context
q tend to increase the correlation between successive elements in the 1D
q and hence the efficiency of the compression
q Four basic definitions of the Peano-scanning operation, to visit each of the
2 × 2 pixels in a sub-image

24

12
5/22/24

PEANO-HILBERT CURVE — BUILDING IT


25 From an image to a line
Basic
Recursive

25

13

You might also like