Aim: - Objective:-: Experiment 7

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

EXPERIMENT 7

Aim: - Implementation of contrast stretching, Dynamic range compression and Bit Plane Slicing.
Objective:-
 To conduct contrast stretching.
 To bring images out of visible spectrum range to normal range through Dynamic range
compressor.
 To implement Steganography through encoding images with bit plane Slicing.

Problem Definition:-
 Input grayscale image.
 Apply Contrast Stretching through linear scaling function.
 Apply Dynamic range compression through log(1+|d|)
 Apply Bit Plane Slicing using Binary bits cutting from MSB to LSB.
 Generate output.

Theory:-
Contrast Sequencing

Contrast stretching (often called normalization) is a simple image enhancement technique that attempts to
improve the contrast in an image by `stretching' the range of intensity values it contains to span a desired
range of values, e.g. the the full range of pixel values that the image type concerned allows. It differs from
the more sophisticated histogram equalization in that it can only apply a linear scaling function to the
image pixel values. As a result the `enhancement' is less harsh. (Most implementations accept a graylevel
image as input and produce another graylevel image as output.)

How It Works

Before the stretching can be performed it is necessary to specify the upper and lower pixel value limits
over which the image is to be normalized. Often these limits will just be the minimum and maximum
pixel values that the image type concerned allows. For example for 8-bit graylevel images the lower and
upper limits might be 0 and 255. Call the lower and the upper limits a and b respectively.

The simplest sort of normalization then scans the image to find the lowest and highest pixel values
currently present in the image. Call these c and d. Then each pixel P is scaled using the following
function:
Values below 0 are set to 0 and values about 255 are set to 255.

The problem with this is that a single outlying pixel with either a very high or very low value can severely
affect the value of c or d and this could lead to very unrepresentative scaling. Therefore a more robust
approach is to first take a histogram of the image, and then select c and d at, say, the 5th and 95th
percentile in the histogram (that is, 5% of the pixel in the histogram will have values lower than c, and 5%
of the pixels will have values higher than d). This prevents outliers affecting the scaling so much.

Another common technique for dealing with outliers is to use the intensity histogram to find the most
popular intensity level in an image (i.e. the histogram peak) and then define a cutoff fraction which is the
minimum fraction of this peak magnitude below which data will be ignored. The intensity histogram is
then scanned upward from 0 until the first intensity value with contents above the cutoff fraction. This
defines c. Similarly, the intensity histogram is then scanned downward from 255 until the first intensity
value with contents above the cutoff fraction. This defines d.

Some implementations also work with color images. In this case all the channels will be stretched using
the same offset and scaling in order to preserve the correct color ratios.

Dynamic Range Compression


Dynamic range in broad terms is the ratio of the largest to the smallest value of a measured signal. There
are various things you as a photographer have to deal with which have a dynamic range of their own -
human visual perception has a dynamic range (you can see very faint stars at night and you can see a
bright sky during daytime, though not both at once), your monitor has a dynamic range (far lower than
human vision), as does your camera's sensor and the electronics which process the signal captured by the
sensor. The Dynamic Range Compression tool is used to compress and redistribute the dynamic range of
the scene captured in a photograph.
The dynamic range of the scene is the ratio of the brightest element in the scene to the darkest. If you
imagine an outdoor scene on a very foggy day, the brightest element would not appear much brighter
from the darkest element, so the scene is said to have a low dynamic range. On the other hand, if you
were to stand indoors on a sunny day, the sun-lit clouds outside would appear far brighter than the lamp-
lit room, let alone the dark corners of the room - this is a high dynamic range scene.
The dynamic range of the scene being captured usually exceeds the dynamic range of the viewing device
(monitor, laptop, smartphone). To show the scene on the viewing device, generally two things can
happen: either a certain segment of the dynamic range which falls outside of that which the monitor can
reproduce is discarded (the sky outside is clipped white so the you can see the inside of the room, or the
sky outside is reproduced at the cost of the room being clipped black), or the dynamic range of the scene
can be compressed so that both the dark and the light areas are visible, and that is where this tool comes
into play.
The Dynamic Range Compression tool is used to compress the dynamic range of an image, reducing
highlights and lifting shadows. It is based on the paper Gradient Domain High Dynamic Range
Compression, referred to in other software such as Luminance HDR simply as "Fattal".
The tool operates in RGB space and is applied right after Noise Reduction and Haze Removal, but before
other tone curve adjustments such as the Exposure controls.
The "detail" slider corresponds to the α (alpha) parameter in the paper, and the "amount" slider
corresponds to β (beta).
There are alternative ways of compressing the dynamic range using other tools. The most simple would
be a negative contrast value in the Exposure tool to reduce (or rather to redistribute) the dynamic range,
however the effect would most likely appear flat and unappealing. A curve gives one more control over
the process, however this tool is designed specifically for the task.

Bit Plane Slicing


Instead of highlighting gray level images, highlighting the contribution made to total image appearance
by specific bits might be desired. Suppose that each pixel in an image is represented by 8 bits. Imagine
the image is composed of 8, 1-bit planes ranging from bit plane1-0 (LSB) to bit plane 7 (MSB).

In terms of 8-bits bytes, plane 0 contains all lowest order bits in the bytes comprising the pixels in the
image and plane 7 contains all high order bits.
The bit plane slicing is a fundamental technique of image processing in which the image is sliced into
different planes (each layer contains sequences of only binary digits 0 or 1). It is ranges from plane1
which contains the least significant bit (LSB) to the last plane N which contains the most significant bit
(MSB), where the number of layers depends on the bit depth of the image. The bit depth means how
many bits need to represent the pixel’s intensity. For example if the image is grayscale then the bit depth
is 8bit and it will be separated into 8 layers, or into 24 layers if the image is colored i.e. bit depth is 24bit.

Example of Bit Plane Slicing


The gray level of each pixel in a digital image is stored as one or more bytes in a computer. For an 8-bit
image, 0 is encoded as 00000000 and 255 is encoded as 11111111. Any number between 0 t0 255 is
encoded as one byte. The bit in the far left side is referred as the most significant bit (MSB) because a
change in that bit would significantly change the value encoded by the byte. The bit in the far right is
referred as the least significant bit (LSB), because a change in this bit does not change the encoded gray
value much. The bit plane representation of an eight-bit digital image is given by:

Figure 2: Bit-plane Slicing


Bit plane slicing is a method of representing an image with one or more bits of the byte used for each
pixel. One can use only MSB to represent the pixel, which reduces the original gray level to a binary
image. The three main goals of bit plane slicing is

 Converting a gray level image to a binary image.


 Representing an image with fewer bits and corresponding the image to a smaller size
 Enhancing the image by focusing
Separating the bit planes, we obtain

MSB Plane
Centre bit plane

LSB Plane

Conclusion:-
 Bit plane slicing is the conversion of image into multilevel binary image.
 The Dynamic Range Compression tool is used to compress the dynamic range of an image,
reducing highlights and lifting shadows.
 Contrast stretching enhances the contrast of the image by’stretching ’ the intensity range.

You might also like