+ All Categories
Home > Documents > Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... ·...

Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... ·...

Date post: 19-Jan-2021
Category:
Upload: others
View: 4 times
Download: 0 times
Share this document with a friend
29
Fundamentals of Digital Image Processing Ho Kyung Kim [email protected] Pusan National University Introduction to Medical Engineering
Transcript
Page 1: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

Fundamentals ofDigital Image Processing

Ho Kyung [email protected]

Pusan National University

Introduction to Medical Engineering

Page 2: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

Outline

• Gray level transformation• Windowing & leveling• Arithmetic operations• Low‐pass & high‐pass filtering• Unsharp masking• Multi‐scale image processing

2

Page 3: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

Motivation

3

• Introduce a number of basic mathematical operations on images– Image enhancement– Image analysis– Visualization

• Provide the clinician with some means to: (perceive better all the relevant diagnostic information present)– Enhance contrast of local features– Remove noise and other artifacts– Enhance edges and boundaries– Composite multiple images for a more comprehensive view

• Two basis operations– Global operations

• Operate on the entire set of pixels at once• e.g., Brightness and contrast enhancement

– Local operations• Operate only on a subset of pixels (in a pixel neighborhood)• e.g., Edge detection, contouring, image sharpening, blurring

Page 4: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

• To increase the contrast in some regions of the image (while sacrificing a contrast in other parts)

• 𝐼 𝑖, 𝑗 𝑇 𝐼 𝑖, 𝑗– Function 𝑇 transforms each gray level 𝐼 𝑖, 𝑗 to another value 𝐼 𝑖, 𝑗 independent of the position 

𝑖, 𝑗enhance the dark area(slope > 1)

suppress the bright area(slope < 1)

Original Enhanced (or transformed)

Gray level transformations

4

Page 5: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

• 𝐼 𝑖, 𝑗 𝑇 𝐼 𝑖, 𝑗 𝑐𝐼 𝑖, 𝑗• or 𝑠 𝑐𝑟

5

Page 6: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

• Image negatives– 𝑠 𝑇 𝑟 𝐿 1 𝑟 , where 𝑘 ∈ 0, 𝐿 1

6

Page 7: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

• Thresholding– 𝑇 𝑟 0 for 𝑟 𝑟– 𝑇 𝑟 𝑀 for 𝑟 𝑟

• 𝑀 = the largest gray level (or 𝐿 1)• 𝑟 = the threshold

– Very useful for images with a bimodal histogram 

• Window/level operation– 𝑇 , 𝑟 0 for 𝑟 𝑙

– 𝑇 , 𝑟 𝑟 𝑙 for 𝑙 𝑟 𝑙

– 𝑇 , 𝑟 𝑀 for 𝑟 𝑙

• 𝑙 = level (window center)• 𝑤 = window width

– Lost contrast outside the window– Stretched contrast inside the window

Window/level operation

7

window width

level

threshold

Page 8: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

8

Original

Bone window Lung window

(Bimodal histogram)

Page 9: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

Multi‐image operations: Add/subtraction

9

• Get rid of the background in two similar images– 𝐼 𝑖, 𝑗 𝐼 𝑖, 𝑗 𝐼 𝑖, 𝑗– 𝐼 𝑖, 𝑗 𝐼 𝑖, 𝑗 𝐼 𝑖, 𝑗– e.g., Blood vessel imaging (angiography): images with and without a contrast agent

After injection Before injection (mask image) After subtraction

Digital subtraction angiography (DSA)

Page 10: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

Multi‐image operations: Averaging

10

• 𝐼 𝑖, 𝑗 𝐼 𝑖, 𝑗 ⋯ 𝐼 𝑖, 𝑗

• Useful to decrease the noise in a sequence of images (of a motionless object)• Averaged the random noise out but leaving the object unchanged

Original After averaging 16 images

Page 11: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

Geometric operations

11

• Image‐to‐patient registration for image‐guided surgery• Registration of images from different modalities (image fusion)

K. K. Brock et al. | Med. Phys. 44 (7) e43-e76 | 2017

Page 12: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

Geometric operations

12

• Examples– Registration of images– Image‐to‐patient registration for image‐guided surgery

• 2D geometric transformations  𝑥 , 𝑦 𝑆 𝑥, 𝑦

– Scaling (zooming)𝑥′𝑦′1

𝑠 0 00 𝑠 00 0 1

𝑥𝑦1

– Translation𝑥′𝑦′1

1 0 𝑡0 1 𝑡0 0 1

𝑥𝑦1

– Shear𝑥′𝑦′1

1 𝑢 0𝑢 1 00 0 1

𝑥𝑦1

– Rotation 𝑥′𝑦′1

cos 𝜃 sin 𝜃 0sin 𝜃 cos 𝜃 0

0 0 1

𝑥𝑦1

– General affine𝑥′𝑦′1

𝑎 𝑎 𝑡𝑎 𝑎 𝑡

0 0 1

𝑥𝑦1

Page 13: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

13

• Affine transformations preserve parallelism of lines but generally not lengths and angles• Orthogonal transformations to preserve angles and lengths

–𝑥′𝑦′1

𝑟 𝑟 𝑡𝑟 𝑟 𝑡0 0 1

𝑥𝑦1

where 𝑅𝑟 𝑟𝑟 𝑟 subject to 𝑅 𝑅 1

• The transformed pixel  𝑥 , 𝑦 from a pixel  𝑥, 𝑦 𝑖, 𝑗 of image 𝐼 𝑖, 𝑗 usually no longer integer values; therefore, interpolation is required

• Affine 3D transformation

𝑥′𝑦′𝑧′1

𝑎 𝑎𝑎 𝑎

𝑎 𝑡𝑎 𝑡

𝑎 𝑎0 0

𝑎 𝑡0 1

𝑥𝑦𝑧1

• Projective transformation to map 3D image data onto a 2D plane

Page 14: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

Filters

14

– 𝑓 𝑖, 𝑗 𝒮 𝛿 𝑖, 𝑗 called the kernel or filter– Linear transformation on 𝐼 is the discrete convolution with its kernel 𝑓

From linear‐systems theory: 𝐼 𝑖, 𝑗 ∑ 𝐼 𝑘, 𝑙 𝛿 𝑖 𝑘, 𝑗 𝑙,

For a linear shift‐invariant (LSI) transformation :

𝒮 𝐼 𝑖, 𝑗 𝐼 𝑘, 𝑙 𝒮 𝛿 𝑖 𝑘, 𝑗 𝑙,

𝐼 𝑘, 𝑙 𝑓 𝑖 𝑘, 𝑗 𝑙,

𝑓 𝑘, 𝑙 𝐼 𝑖 𝑘, 𝑗 𝑙,

𝑓 𝑖, 𝑗 ∗ 𝐼 𝑖, 𝑗

Page 15: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

15

– This transformation on 𝐼 is the discrete cross‐correlation of ℎ and 𝐼• Aka, ℎ is called an image template or mask

– If the filter is symmetric, the cross‐correlation and convolution are identical

Applying the same operation with the flipped kernel: ℎ 𝑖, 𝑗 𝑓 𝑖, 𝑗

𝒮 𝐼 𝑖, 𝑗 𝑓 𝑖, 𝑗 ∗ 𝐼 𝑖, 𝑗 𝑓 𝑘, 𝑙 𝐼 𝑖 𝑘, 𝑗 𝑙,

ℎ 𝑘, 𝑙 𝐼 𝑖 𝑘, 𝑗 𝑙,

ℎ 𝑖, 𝑗 ⊗ 𝐼 𝑖, 𝑗

• Filtering operation① Superimpose the center of the mask ℎ 0,0 onto an image pixel  𝑖, 𝑗② Multiply the values of the mask and image that correspond to the same positions③ Sum and replace the value of pixel  𝑖, 𝑗 by the summed value④ Move to the next pixel and repeat– The cross‐correlation emphasizes patterns in the image similar to the template

Page 16: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

16

• Averaging filter– Making the image smoother and removing some noise– Giving the same weight to the center pixel as to its 

neighbors

Taken from R. C. Gonzalez & R. C. Woods, Digital Imaging Processing (2002)

33

55 99

1515 3535

Page 17: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

17

• Low‐pass filter– Averaging filters– To smoothen and/or reduce noise

• High‐pass filter– To enhance small‐scale variations– To extract edges and fine structures

Gaussian filter(20 x 20 pixels,  = 15)

Original

Original – LPF'd image

Gaussian filter: to give high weight to the center pixel and less weight to distant pixels

‐ Convolution vs. multiplication‐ Acting as LPF‐ Then, how to construct HPF?

𝑔 𝐫1

2𝜋𝜎 𝑒 / ℱ 𝑔 𝐫 ?

𝐼 𝑔 ∗ 𝐼

Page 18: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

18

• Gaussian filters in space and frequency domains

Taken from R. C. Gonzalez & R. C. Woods, Digital Imaging Processing (2002)

Page 19: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

19

• Differential operator: Gradient & Laplacian– Not defined on discrete images– Approached by interpolating a discrete function with a differentiable continuous function

• 𝐼 𝑖, 𝑗 ∑ 𝐼 𝑘, 𝑙 𝑓 𝑥 𝑘, 𝑦 𝑙, ,∑ , 𝐼 𝑘, 𝑙,

• An approximate derivative by a convolution with a filter that is the sampled derivative of some differentiable interpolation function

– This procedure can be used to• 𝛻𝐼 𝛻𝑓 ∗ 𝐼 gradient• 𝛻 𝐼 𝛻 𝑓 ∗ 𝐼 Laplacian• Using the Gaussian function for 𝑓:

– 𝛻𝑔 𝐫 𝑔 𝐫 · 𝐫

– 𝛻 𝑔 𝐫 𝑟 2𝜎 · 𝑔 𝒓

– For 𝜎 = 0.5;

0.01 0.08 0.01

0.08 0.64 0.08

0.01 0.08 0.01

0.05 0 -0.05

0.34 0 -0.34

0.05 0 -0.05

0.05 0.34 0.05

0 0 0

-0.05 -0.34 -0.05

0.3 0.7 0.3

0.7 -4 0.7

0.3 0.7 0.3

Gaussian

Note that the Laplacian is superior in enhancing fine detail, but which causes noisier results than the gradient.

𝜕/𝜕𝑥 𝜕/𝜕𝑦 𝛻

Page 20: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

20

1 0 -1

2 0 -2

1 0 -1

1 1 1

1 -8 1

1 1 1

Approximate Laplacian of Gaussian= difference of Gaussians

“Sobel”for the first derivative

“average ‐ ”for the Lapalacian

Gaussian function Derivative in 𝑥

Derivative in 𝑦 Laplacian

Note that integration of a Gaussian over the whole spatial domain must be 1, and for the gradient and Laplacian must be 0.

𝑟𝜎

2𝜎 𝑔 𝐫

4𝜎 𝑔 𝐫

Page 21: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

21

• Unsharp masking– To enhance image details by emphasizing the high‐frequency part and assigning it a higher weight

Original 𝐼 𝑔 ∗ 𝐼 (3 x 3)

𝑰 – 𝒈 ∗ 𝑰 5

‐ (> 0) controls the strength of the enhancement, and (of 𝑔) is responsible for the size of the frequency band that is enhanced.

‐ The smaller , the more unsharp masking focuses on the finest details.

𝐼 𝑔 ∗ 𝐼 𝐼 𝑔 ∗ 𝐼

𝐼′ 𝑔 ∗ 𝐼 1 𝛼 𝐼 𝑔 ∗ 𝐼

𝐼 𝛼 𝐼 𝑔 ∗ 𝐼

1 𝛼 𝐼 𝛼𝑔 ∗ 𝐼

Page 22: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

Nonlinear filters

22

• The averaging filter removes noise. In addition, edges are also smeared out.• Better to calculate the median instead of the mean value in small window around each 

pixel.

Original chromosome image Gaussian filter Median filter

• Bilateral filter: 𝐼 ∑ 𝐼 𝐫 𝑔 𝐫 𝐫 , 𝜎 𝑔 𝐼 𝐫 𝐼 𝐫 , 𝜎𝐫– Filtering both the spatial 𝑠 and gray level 𝐼 domains to preserve the edges while the noise is reduced

Page 23: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

23

• Note that the “median filtering” is a non‐linear process capable of removing image features, and which is unacceptable in medical imaging processing

33 averaging filter 33 median filterSalt‐and‐pepper noise

Taken from R. C. Gonzalez & R. C. Woods, Digital Imaging Processing (2002)

Page 24: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

24

1) Original 2) Laplacian of 1)

3) Sharpened by adding 1) & 2) 4) Sobel of 1)

5) Smoothed by taking a 55 averaging filter to 4)

6) Mask [3)  5)]

7) Sharpened by adding 1) & 6)

8) Power‐law transformation of 7)

Laplacian to highlight fine detailGradient to enhance prominent edgesTransformation to increase dynamic range

Taken from R. C. Gonzalez & R. C. Woods, Digital Imaging Processing (2002)

Page 25: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

Effect of the filter size in unsharp masking

25

Original

Unsharp; size 10 Unsharp; size 30

Unsharp; size 60 Unsharp; size 125

Enhanced fine details, but reduction in contrast

Enhanced large‐scale variations (lung & mediastinum), but suppressed small details

Page 26: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

Multi‐scale image processing

26

• Gray value transformations (e.g., window/level operation)– Increase the contrast in a subpart of the gray value scale, whereas features outside this gray value 

interval are attenuated– Do not make use of the spatial relationship among object pixels and therefore equally enhance 

meaningful & meaningless features such as noise

• Spatial operations can overcome the problem mentioned above– Unsharp masking, averaging, median filtering– Limited to features of a particular size because of the fixed size of the filter

• If the filter is small, the unsharp masking emphasizes small‐scale features and neglects small gray value variations that extend over larger areas in the image

• Diagnostic information is available at all scales in the image and is not limited to a particular freq. band

• Image processing intensifies gray value variations equally; desirable for low‐contrast features but unnecessary for high‐contrast features that are easily perceivable

• A method is needed that is independent of the spatial extent or scale of the image features and emphasizes the amplitude of only the low‐contrast features

Page 27: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

27

• Reduce an image by smoothing and subsampling (with a factor of 2)– ℛ 𝐼 ↓ 𝑔 ∗ 𝐼

• Pyramid of images– 𝐼 ℛ 𝐼 ↓ 𝑔 ∗ 𝐼 for 𝑖 0, … , 𝐾 1 and 𝐼 𝐼

• Expand an image by upsampling and interpolation– ℰ 𝐼 4𝑔 ∗ ↑ 𝐼

• Approximate Laplacian operator:– 𝒟 𝐼 𝐼 ℰℛ 𝐼 1 ℰℛ 𝐼

• ℰℛ 𝐼 = the smoothed version of 𝐼• Laplacian pyramid: 𝒟 𝐼 1 ℰℛ 𝐼 𝐼 ℰ 𝐼

• Multi‐scale representation– 𝒟 , 𝒟 , … , 𝒟 , 𝐼 reconstruction by 𝐼 𝒟 ℰ 𝐼– The edges or details at the different resolution levels together with the residual image 𝐼– A pyramid of detail images– A finer‐scale image 𝐼 can be obtained from the coarser‐scale image 𝐼 by adding the finer‐scale 

details 𝒟 to it

𝒟

𝐼

𝐼 𝐼

𝒟

𝒟𝒟

𝒟

Page 28: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

Image enhancement by nonlinear mapping

28

• MUltiScale Image Contrast Amplification– Convert 𝐼 to its multi‐scale representation  𝒟 , 𝒟 , … , 𝒟 , 𝐼– Enhance the contrast of each detailed image by the non‐linear gray scale transformation, hence 

𝒟′ , 𝒟′ , … , 𝒟′– Reconstruct the enhanced image from  𝒟′ , 𝒟′ , … , 𝒟′ and the residual image 𝐼

Original Edge enhancement Window/level MUSICA

Page 29: Fundamentals of Digital Image Processingbml.pusan.ac.kr/LectureFrame/Lecture/Undergraduates/... · 2020. 9. 18. · Multi‐scale image processing 26 • Gray value transformations

Wrap‐up

• Gray level transformation• Windowing & leveling• Arithmetic operations• Low‐pass & high‐pass filtering• Unsharp masking• Multi‐scale image processing

29


Recommended