Multimedia Systems-L4
Multimedia Systems-L4
Multimedia Systems-L4
Lecture 4
Assignment 2
• https://learnopencv.com/alpha-blending-using-opencv-cpp-
python/
Dithering
• Dithering is the process by which we create illusions of the color that are not
present actually. It is done by the random arrangement of pixels.
• This is an image with only black and white pixels in it. Its pixels are arranged in
an order to form another image that is shown below.
• Note at the arrangement of pixels has been changed, but not the quantity of pixels.
Dithering
• There can be various kinds of dithering processes. These
include:
• Random Dithering
• Average Dithering
• Ordered Dithering
• Floyd-Steinberg Dithering
Dithering
• Random dither: the process of converting a grayscale image into a black and
white or monochrome image. The process works by randomly choosing the pixel
values in the image.
• For each value in the image, simply generate a random number 1..256; if it is
greater than the image value at that point, plot the point white, otherwise plot it
black.
• This type of dithering produces better results with the image having less
information.
Dithering
• Threshold Dithering: This is similar to random dithering because it converts the
grayscale image into a black and white image. It consists in choosing a certain
constant gray level
• All pixels whose intensity level lies above the average value (the threshold) are
quantized to 1; all others get a value of 0.
• This threshold value is compared to the other pixels of the image. If pixels having
less value than the threshold becomes black and if the pixels have a value higher
than the threshold becomes white.
Dithering
• Ordered Dithering: Ordered Dithering consists of comparing, blocks
of the original image to a 2-D grid of thresholds called the dither
pattern.
• Each pixel intensity of the original image is compared to the
corresponding location intensity in the dither pattern. The values in the
dither matrix are fixed but are different from each other.
Index matrix
The algorithm reduces the number
of colors by applying a threshold
map M to the pixels displayed,
causing some pixels to change
color, depending on the distance of
the original color from the available
color entries in the reduced palette.
Sampling has a
relationship with image
pixels.
• Now you see, we got all these images by just re-arranging the pixels of an image.
This re-arranging could be random or could be according to some measure.
Restricted
Original image palette
image
Printed black
and white Dithered
image
image
Dithering Types
• https://www.google.com/search?client=firefox-b-
d&q=dithering+image+and+dither+matrix+#fpstate=ive&vld=cid:822
b6677,vid:jzOs7QSrgbQ
Color Lookup Table diverse
• The most straightforward way to make 8-bit lookup color out of 24·bit
color would be to divide the RGB cube into equal slices in each
dimension.
• we could shrink the R range and G range 0 .. 255 into the 3-bit range 0
.. 7 and shrink the B range down to the 2-bit range o., 3, making a total
of 8 bits.
• we could simply divide the R or G byte value by (256/8 =) 32 and then
truncate.
• Then each pixel in the image gets replaced by its 8-bit index, and the
color LUT serves to generate 24-bit color.
Median cut algorithm
• Median cut algorithm is an adaptive algorithm for color quantization to
select the best representative subset of colors. It is used, for example, in the
palette generation process.(used for color quantization).
• The idea behind the median cut algorithm is to use each of the colors in the
synthesized look-up table to represent the equal number of pixels in the
original image.
• The algorithm subdivides the color space interactively into smaller and
smaller boxes.
• The median is the point where half the pixels are smaller and half are larger.
• The idea is to sort the R byte values and find their median. Then values
smaller than the median are labeled with a 0 bit and values larger than the
median are labeled with a 1 bit.
Median cut algorithm
• Algorithm
1.Move all pixels into a single large bucket.
2.Find the color channel (red, green, or blue) in the image with
the greatest range.
3.Sort the pixels by that channel values.
4.Find the median and cut the region by that pixel.
5.Repeat the process for both buckets until you have the desired
number of colors.
Median cut algorithm
• For example, In your image, if the blue channel has the greatest range,
then a pixel with an RGB value of (32, 8, 16) is less than a pixel with
an RGB value of (1, 2, 24), because 16 < 24.
• Sort the pixels along blue channel.
• After the bucket has been sorted, move the upper half of the pixels into
a new bucket. Repeat the process on both buckets, giving you 4
buckets, then repeat on all 4 buckets, giving you 8 buckets, then repeat
on all 8, giving you 16 buckets.
• Average the pixels in each bucket and you have a palette of 16 colors.
Example of color reduction using the median cut algorithm: (left)
color samples of the image, and (b) sixteen-color palette.
Image compression