0% found this document useful (0 votes)
3 views25 pages

DMPT 2025 Lecture08 ENG ContextFreeOperations

The document discusses context-free operations in digital image processing, which are pixel-level operations that do not consider neighboring pixels. It provides examples such as binarization, histogram equalization, and image arithmetic, detailing methods for thresholding and image normalization. The lecture also covers various techniques for adjusting image intensity and contrast, as well as logical operations for image analysis.

Uploaded by

Meow Meow
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)
3 views25 pages

DMPT 2025 Lecture08 ENG ContextFreeOperations

The document discusses context-free operations in digital image processing, which are pixel-level operations that do not consider neighboring pixels. It provides examples such as binarization, histogram equalization, and image arithmetic, detailing methods for thresholding and image normalization. The lecture also covers various techniques for adjusting image intensity and contrast, as well as logical operations for image analysis.

Uploaded by

Meow Meow
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/ 25

DIGITAL MEDIA

PROCESSING TECHNIQUES
– Lecture 08

CONTEXT FREE OPERATIONS:


8.1. Context free operations in digital image processing
8.2. Examples of context free operations

KCH – DMPT Lecture08 2025 1/25


Context free operations – point operations

Definition:
context free operation in image processing is an operation on an
individual pixel and the environment, i.e., neighbor pixels of the
processed pixel have no effect on this operation.

The consequence:
all pixels of the same values are identically processed.

KCH – DMPT Lecture08 2025 2/25


Examples of context-free operations

• Binarization
• Image negative
• Histogram changes (equalizations)
• Color changes
• Arithmetic operation on images
(addition, subtraction, multiplication, raising to a power)
• Image merging (cross dissolve transitions in video editing)
• Gamma correction
• Adding a constant to the image
• Logical operations
• Look-up table
• Image normalization

KCH – DMPT Lecture08 2025 3/25


Binarization

Binarization is the process of converting a pixel image to a binary


image. Image binarization is the process of transforming a grayscale
image to black-and-white image. It was applied in the past mainly for
sending faxes. Nowadays its is still important in text digitalization and
image segmentation.
Binarization reduces the information contained within the image
from 256 shades of gray to only two values: black and white.
In binarization process a threshold can be applied.
The threshold can either be set fixed or adaptive using a clustering
algorithm. It first counts the appearance of each tone in the image
and tries to find a good center.

KCH – DMPT Lecture08 2025 4/25


Image binarization – Thresholding

Thresholding is the simplest method of segmenting images.


From a grayscale image, thresholding is used to create binary images.
Each pixel in an image is repleced with a black pixel if the image
intensity Iij is less than some fixed constant T
that is, I(x,y) < T,
or a white pixel if the image intensity is greater than that constant
that is, I(x,y) > T.
To simplify, this results that the dark points in an image are becoming
completely black, and the bright points are becoming completely
white.

KCH – DMPT Lecture08 2025 5/25


Image binarization – Thresholding
– automatic selection of the threshold T

Threshold T can be set automatically using different methods:


• Histogram shape-based methods – the peaks, valleys and curvatures of the
smoothed histogram are analyzed,
• Clustering-based methods – the gray-level samples are clustered in two parts as
background and foreground (object), or alternately are modeled as a mixture of
two Gaussians,
• Entropy-based methods result – the entropy of the foreground and background
regions, the cross-entropy between the original and binarized image, are analyzed,
• Object Attribute-based methods – a measure is used of similarity between the
gray-level and the binarized images, such as fuzzy shape similarity, edge
coincidence, etc.
• Spatial methods – higher-order probability distribution and/or correlation
between pixels is used,
• Local methods – adaptation of the threshold value on each pixel to the local image
characteristics, a different T can be selected for each pixel in the image.

KCH – DMPT Lecture08 2025 6/25


Color image thresholding

Color images can also be thresholded:

• three thresholds can be established for each of the RGB components


of the image and then combine them with an AND operation,
• CMYK color model can also be used,
• HSL and HSV color models are more often used.

KCH – DMPT Lecture08 2025 7/25


Example of image binarization

Full color image


of flowers Grayscale image Binary image

KCH – DMPT Lecture08 2025 8/25


Example of negative (inverted) image

Grayscale image Nagative image

KCH – DMPT Lecture08 2025 9/25


Histogram changes (equalizations)

Histogram changes mainly histogram equalizations can be also included in


the group of context-free operations.
Histogram equalizations have been presented in the previous lecture.
As it was mentioned the RGB color image should be first converted to
another color space, in particular to HSL or HSV color space. Then the
algorithm can be applied to the luminance or value channel without
resulting in changes to the hue and saturation of the image.

The main goal of the image histogram equalization is to differentiate the


intensity of image pixels and in consequence to make the image details
visible.

KCH – DMPT Lecture08 2025 10/25


Image color change

KCH – DMPT Lecture08 2025 11/25


Image arithmetic

Image arithmetic – standard arithmetic operations on images:


addition and subtraction
(multiplication and division are generally less useful)
With 8-bit images, results greater than 255 are set to 255,
with 16-bit images, results greater than 65,535 are set to 65,535,
results less than 0 are set to 0.

Image addition
Two images are added as per the equation below:
I’(x,y) = If1(x,y) + If2(x,y)

KCH – DMPT Lecture08 2025 12/25


Image merging
(cross dissolve transitions in video editing)

Image merging (blending) – mixing of two input images (of some parts of
two images) of the same size. This operation is similar to pixel addition. The
value of each pixel in the output image is a linear combination of the
corresponding pixel values of two input images. The coefficients defines how
great is the impact of each input pixel on the merged image. These
proportions ensured that the output pixel values do not exceed the
maximum pixel value.
Mathematical definition:
I’(x,y) = (1 - α) If1(x,y) + α If2(x,y)
By varying α from 0 to 1, we can perform a cool transition between one
image to another.
Such a transformation is used in different video effects, first of all in video
cross dissolve transitions.
It also gives a feeling of blending or transparency.

KCH – DMPT Lecture08 2025 13/25


Subtraction of two images

Image subtraction – a process whereby the digital numeric value of one


pixel or whole image is subtracted from another image
(results less than 0 are set to 0).
Purposes:
• levelling uneven sections of an image such as half an image having a
shadow on it,
in digital photography – to reduce image noise in photos taken with long
exposure times (so called dark-frame subtraction),
• detecting changes between two images, mainly to detect the movements
(applied in astronomy and astrophysics, medicine, biology,
video analysis, etc.).

KCH – DMPT Lecture08 2025 14/25


Elimination of the variation in the
background intensity

Application of the image subtraction – the foreground objects may be more


easily analyzed if we subtract background variations in illumination from a
scene.

https://inf.ed.ac.uk/ 1) 2)
Example
1) text is not well visible because it has been badly illuminated during
scanning, there is a strong illumination gradient across the image
2) simple thresholding fails due to the illumination gradient
KCH – DMPT Lecture08 2025 15/25
Elimination of the variation in the
background intensity (continued)

3) White paper scanned in the same environment – a new image


4) Such an image is the light field. The light field image is SUBSTRACTED
from the original image to attempt to eliminate variation in the
background intensity.
5) Background intensity of the image is much more uniform than before –
thresholding gives better results than before

3) 4) 5)

KCH – DMPT Lecture08 2025 16/25


Raising to a power

I’(x,y) = I(x,y)γ
Input values of the image I(x,y) are raised to the power γ (gamma).
I(x,y) – intensity of the pixel with the coordinates x and y

This arithmetic operation is called gamma correction and it was


presented in the previous lecture as one of the correction operation.

γ > 1 –> the dark pixels become brighter,


the bright pixels remain almost unchanged
γ < 1 –> the bright pixels become darker
the dark pixels remain almost unchanged

KCH – DMPT Lecture08 2025 17/25


Adding a constant to the image
or multiplying the image by a constant

Corrections of image intensity or contrast:


• Intensity (brightness)
Brightness of a grayscale image is the average intensity of all pixels
in image
• Contrast
Contrast of a grayscale image – how easily objects in the image can
be distinguished,
- high contrast image: many distinct intensity values,
- low contrast: image uses few intensity values.

KCH – DMPT Lecture08 2025 18/25


Simple adding a constant to the image

Simple addition/subtraction of a constant (a) from an image can be


used to brighten/darken an image.
I’(x,y) = I(x,y) ± a
The multiplication by a constant c
I’(x,y) = I(x,y) * c
The constant c is:
– often a floating point number,
– may be less than one.
Multiplication by a constant reduces the image intensities
(so called scaling).

KCH – DMPT Lecture08 2025 19/25


Logical operations

Logical AND/NAND
The AND and NAND operators take two binary, grayscale or color
(intensity values) images as input, and outputs a third image whose pixel
values are just those of the first image ANDed with the corresponding pixels
from the second.
This operator can be used also on a single input image. Each pixel is
processed with a specified constant value in order to produce the output.
All the input pixel values should have the same number of bits. Where the
pixel values in the input images are not simple 1-bit numbers, the
AND/NAND operation is carried out individually on each corresponding bit
in the pixel values, in bitwise fashion.

KCH – DMPT Lecture08 2025 20/25


Logical AND/NAND (continued)

In general, applying the AND operator (or other logical operators) to two
images in order to detect differences or similarities between them is most
appropriate if they are binary or can be converted into binary format using
thresholding.
The most obvious application of AND is to compute the intersection of two
images.
AND and NAND are often used as sub-components of more complex image
processing tasks. One of the common uses for AND is masking.

KCH – DMPT Lecture08 2025 21/25


Logical OR/NOR
Logical XOR/XNOR

OR/NOR (XOR/XNOR) operations are performed similarly to


AND/NAND operations.
Logical OR operator is used to compute the union of two images, It
enables us to highlight all pixels representing an object either in the
first or in the second image.
These two images should be first thresholded, since the process is
simplified by use binary input.
OR operator can be used to merge two images together.
XOR can be used to detect changes in the images.

KCH – DMPT Lecture08 2025 22/25


Logical NOT
(inverted image, photographic negative)

Logical NOT operator is used to produce the photographic negative of


a binary image.

The objects in the inverted images appear in white on a dark


background. It is often more suitable for the human eye.
It was presented earlier as an example of negative (inverted) image.

KCH – DMPT Lecture08 2025 23/25


Look-up table

Special array specifies the value of the pixel after the operation.

Original value Value of the pixel


of the pixel after the operation
0 v1

1 v2

2 v3

255 vn

KCH – DMPT Lecture08 2025 24/25


Image normalization

Definition of image normalization:


– a process that changes the range of pixel intensity values.
I(x,y) –> I’(x,y) , I(x,y) ϵ [Min,Max],
I’(x,y) ϵ [NewMin,newMax].
Normalization transforms an image with intensity values in the range
(Min,Max), into a new image with intensity values in the range
(NewMin,NewMax).
The linear normalization of a grayscale digital image is performed
according to the formula:
I’(x,y) =
= (I(x,y)–Min) * (NewMax–NewMin) / (Max–Min) + NewMin

KCH – DMPT Lecture08 2025 25/25

You might also like