0% found this document useful (0 votes)
26 views24 pages

Image Enhancement

The document provides an overview of image enhancement techniques, defining an image as a 2D light intensity function and categorizing images into monochrome, grayscale, and color types. It discusses various methods for enhancing images, including spatial domain techniques like point processing and contrast stretching, as well as frequency domain modifications. Additionally, it covers specific techniques such as digital negatives, log transformations, power-law transformations, thresholding, grey-level slicing, and bit-plane slicing.

Uploaded by

try.admerch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views24 pages

Image Enhancement

The document provides an overview of image enhancement techniques, defining an image as a 2D light intensity function and categorizing images into monochrome, grayscale, and color types. It discusses various methods for enhancing images, including spatial domain techniques like point processing and contrast stretching, as well as frequency domain modifications. Additionally, it covers specific techniques such as digital negatives, log transformations, power-law transformations, thresholding, grey-level slicing, and bit-plane slicing.

Uploaded by

try.admerch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

25-02-2025

Image Enhancement

What’s an image?

• An image refers to a 2D light intensity function


f(x,y), where (x,y) denote spatial coordinates and
the value of f at any point (x,y) is proportional to
the brightness or gray levels of the image at that
point.

1
25-02-2025

Image Types
• Monochrome Image (Black and White Image)

• Grey Scale image

• Color Image

Pixel intensity value


Consider the following
image (2724x2336 pixels)
f(1,1) = 103 to be 2D function or a
matrix with rows and
Pixel location columns

In 8-bit representation
Pixel intensity values
rows columns change between 0 (Black)
and 255 (White)
f(645:650,1323:1328) =
83 82 82 82 82 82
82 82 82 81 81 81
82 82 81 81 80 80
82 82 81 80 80 79
80 79 78 77 77 77
80 79 78 78 77 77

f(2724,2336) = 88

2
25-02-2025

Image Representation

Image Representation

3
25-02-2025

Image Enhancement
• Goal: process an image so that the result is more
suitable than the original image for a specific
application

Two categories

• Spatial domain
• Direct manipulation of pixels
• Point processing

• Neighborhood processing

• Frequency domain
• Modify the Fourier transform of an image

4
25-02-2025

Spatial Domain Methods


• In these methods an operation (linear or non-
linear) is performed on the pixels in the
neighborhood of coordinate (x,y) in the input image
F, giving enhanced image F’

g(x,y) = T[f(x,y)]

Point Processing

10

5
25-02-2025

Point processing is used to transform an image by


operating on individual pixels.
If array A represents an input image then an output
array B is produced by a transformation
B[x, y] = T * A[x, y]

11

1. Digital Negative
• Means inverting the grey levels
• Black in the original image will look white and vice-versa

12

6
25-02-2025

1. Digital Negative contd…


• For L gray levels the transformation function is
s =T(r) = (L - 1) - r

13

Example: Find the digital negative


of the image given below
4 3 2 1
3 1 2 4
5 1 6 2
2 3 5 6

14

7
25-02-2025

Digital Negative

15

2. Contrast Stretching

16

8
25-02-2025

2. Contrast Stretching contd…


• Basic idea is to increase the contrast of an image by
making the dark portions darker and bright
portions brighter
• we stretch the minimum and maximum intensity
values present to the possible minimum and
maximum intensity values.

17

Contrast Stretching
• To increase the dynamic range of the gray levels in
the image being processed.

18

9
25-02-2025

contd…
• The locations of (r1,s1) and (r2,s2) control the shape of
the transformation function.

• If r1= s1 and r2= s2 the transformation is a linear function and


produces no changes.
• If r1=r2, s1=0 and s2=L-1, the transformation becomes a
thresholding function that creates a binary image.
• Intermediate values of (r1,s1) and (r2,s2) produce various
degrees of spread in the gray levels of the output image, thus
affecting its contrast.
• Generally, r1≤r2 and s1≤s2 is assumed.

19

Example

20

10
25-02-2025

Example: Apply contrast stretching to the image given below.


Use r1=3, r2=5, s1=2, s2=6

4 3 2 1
3 1 2 4
5 1 6 2
2 3 5 6

21

For a point r,s,


α=

𝑠1 − 0
∝=
𝑟1 − 0 For a point r, s

β=
𝑠2 − 𝑠1
𝛽=
𝑟2 − 𝑟1
For a point r, s
𝑚𝑎𝑥 − 𝑠2 ϒ=
𝛾=
𝑚𝑎𝑥 − 𝑟2

22

11
25-02-2025

r s
0

23

Input Image Output Image

4 3 2 1
3 1 2 4
5 1 6 2
2 3 5 6

24

12
25-02-2025

3. Log Transformations
• s = c log(1+r)

◼ Enhances the low intensity pixel


values while compressing the higher
intensity
◼ Compress the dynamic range of
images with large variation in pixel
values
◼ The technique of compressing
dynamic range is known as dynamic
range compression
◼ Log operator is an excellent
compressing function

25

Example: Log Transformations

log

26

13
25-02-2025

4. Power-law transformations
• s=cr
• >1 darkens the bright regions
• <1 brightens the dark regions
• : gamma
• display, printers, scanners
follow power-law
• Gamma correction
• Non linearities encountered
during image capturing,
printing and displaying can
be corrected using gamma
correction

27

Power-law: <1

• Expand dark gray


levels

=0.6

=0.4 =0.3
28

14
25-02-2025

Power-law: >1

• Expand light gray


levels

=3

=4 =5
29

5. Thresholding
• It is a way to create a binary image from a
grayscale or full-color image.
• divides the foreground from the background in
an image.

30

15
25-02-2025

5. Thresholding contd…
• Simple Thresholding/Binary Thresholding
• a standard threshold value is set
• each pixel value is compared with the threshold value.
• If the pixel value is less than the mentioned threshold
value then the value is set to 0 or else it is set to the
maximum value.

31

Example: Apply thresholding to the image given below. Assume


the threshold value = 4

4 3 5 2
3 6 4 6
2 2 6 5
7 6 4 1

32

16
25-02-2025

Example

33

import cv2
from google.colab.patches import cv2_imshow
import matplotlib.pyplot as plt

image_path = "/content/sample_image.jpg"

def apply_threshold(image_path, threshold_value=127):


# Read the image
original_image = cv2.imread(image_path,
cv2.IMREAD_GRAYSCALE)

# Check if the image is loaded successfully


if original_image is None:
print("Error: Image not found!")
return

34

17
25-02-2025

# Apply thresholding
_, thresholded_image = cv2.threshold(original_image,
threshold_value, 255, cv2.THRESH_BINARY)

# Display the original and thresholded images


print("Original Image:")
cv2_imshow(original_image) # For Colab

print("Thresholded Image:")
cv2_imshow(thresholded_image) # For Colab

# Save the result (optional)


cv2.imwrite('thresholded_image.jpg', thresholded_image)

# Example usage
image_path = "/content/sample_image.jpg" # Replace with your
image's path
apply_threshold(image_path, threshold_value=127)

35

36

18
25-02-2025

6. Grey-Level Slicing
• It manipulates a group of intensity levels in an
image up to a specific range by diminishing the
rest
• Useful for highlighting features in an image
• Used in medical and satellite images such as
X-ray flaws and CT scans.

39

Perform grey level slicing with r1=2 and r2=5

4 3 5 2
3 6 4 6
2 2 6 5
7 6 4 1

40

19
25-02-2025

Perform grey level slicing with r1=2 and r2=5 (with background)

4 3 5 2
3 6 4 6
2 2 6 5
7 6 4 1

41

42

20
25-02-2025

1. Original Input Image 2. Digital Negative

3. Thresholding 4. Grey Level Slicing with


Background

43

7. Bit Plane Slicing


• Pixels are digital numbers, each one
composed of bits.

44

21
25-02-2025

Bit-Plane Slicing
• To highlight the contribution made to the total
image appearance by specific bits.

• i.e. Assuming that each pixel is represented by 8 bits, the


image is composed of 8 1-bit planes.
• Plane 0 contains the least significant bit and plane 7
contains the most significant bit.
• Only the higher order bits (top four) contain visually
significant data. The other bit planes contribute the
more subtle details.

45

Bit-Plane Slicing: example

46

22
25-02-2025

7 6

5 4 3

2 1 0

47

Example

48

23
25-02-2025

49

50

24

You might also like