Multimedia Systems-L4

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

Multimedia Systems

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.

Threshold maps come in various


sizes, which is typically a power of
two:
Dithering
• Floyd-Steinberg Dithering: it is similar to ordered dithering. The process
works by choosing different patterns from the image but these patterns are
relatively few repeated patterns from the colors of the image. It can be
used with both gray-scale and monochromic images. We can use it in
place of ordered dithering for representing the image with richer
information than ordered dithering.
Sampling

Sampling has a
relationship with image
pixels.

The total number of pixels


in an image can be
calculated as Pixels = total
no of rows * total no of
columns.
Quantization
• Quantization is opposite to sampling because it is done on “y axis” while
sampling is done on “x axis”. Quantization is a process of transforming a real
valued sampled image to one taking only a finite number of distinct values.
• The process in which a continuous range of values gets converted into a range of
discrete values.
• when you are quantizing an image, you are actually dividing a signal into
quanta(partitions).
• If we apply color quantization in an image, then only colors that can represent the
image are selected by losing the rest of the colors.
• While converting the signal from analogue format to digital format, we lose
various information. The accuracy of the digital signal depends on the resolution
of the quantization.
Dithering with quantization

• The picture is not very clear, especially if you will look at


the left arm and back of the image of the Einstein. Also this
picture does not have much information or detail of the
Einstein.

• Now if we were to change this image into some image that


gives more detail then this, we have to perform dithering.

• Dithering is usually working to improve thresholding.


During threholding, the sharp edges appear where
gradients are smooth in an image.
• we simply choose a constant value. All the pixels above
that value are considered as 1 and all the value below it are
considered as 0.
Dithering with quantization
• Since there is not much change in the image,
as the values are already 0 and 1 or black and
white in this image. Now we perform some
random dithering to it. Its some random
arrangement of pixels.

• We got an image that gives slighter of the


more details, but its contrast is very low. So
we do some more dithering that will increase
the contrast.
Dithering with quantization
• Now we mix the concepts of random dithering, along with threshold and we got
an image like this.

• 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

• Compression allows us to store the same image in a much


smaller file, which can be downloaded in a much more
reasonable time
• Image, 1024pixels x 1024pixels x 24bits, with no
compression, will need 3MB storage & 7 minute for
transmission, utilize a higher speed, 64Kbit/s.
• When image is compress at a 10 : 1 compression ratios, the
storage needed is reduce to 300KB & the transmission
duration decrease to below 6 sec.
Image compression
• Lossless: reduces the number of bit require to represent the original
images sample with no any information loss.

• Example: If on a row of pixels there is a line of thirty red pixels, then


we can store the color value for ‘red’ once, and store the fact that it’s
repeated thirty times, which would save us around twenty to twenty-
five color-value entries.
Image compression
• Lossy : A compression type that produce the losing a part of the
original data. Lossy compression trade the potential for the loss of
several images quality for the opportunity for more compression.

• lossless compression produce a compression ratio of 2 : 1, lossy


compression of image data can lead to ratio between 10:1 & 50:1 with
no visibly degrading image quality. JPEG & MPEG are example of
lossy compression technique.

You might also like