Format For First Page: Group No. Roll No. Name As Per The Attendance List Small Photo

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

Format for First Page

Group No. 50

Roll No. 1704108

Name as per the Attendance Shambwani Rohit Pradeep


List

Small Photo
GROUP No: 50 ROLL No: 1704108

EXPERIMENT 1: Write a program


to sample a continuous time signal and convert to discrete time signal and
reconstruct to original.

Theory:

In signal processing, sampling is the reduction of a continuous-time signal to a discrete-time


signal. A common example is the conversion of a sound wave (a continuous signal) to a
sequence of samples (a discrete-time signal).
A sample is a value or set of values at a point in time and/or space. A sampler is a subsystem
or operation that extracts samples from a continuous signal. A theoretical ideal sampler
produces samples equivalent to the instantaneous value of the continuous signal at the
desired points.
The original signal is retrievable from a sequence of samples, up to the Nyquist limit, by
passing the sequence of samples through a type of low pass filter called a reconstruction
filter.

Concept of digital frequency .

Unlike an analog frequency, a digitally generated frequency does not have infinite resolution.
A digital frequency can only take on discrete values. A digital sine wave, for example, can only
take on discrete values for frequency, phase, and amplitude. The frequency resolution of a
digitally generated sinusoid is limited by the period of the digital sample clock T = 1/f , and
S

the precision of the sinusoidal waveform amplitude is limited by the bit width of each digital
sample. The normalized values of these limits are respectively 0.5 and 1.0 cycles/sample.
Reasons for aliasing and how to handle aliasing?

In signal processing and related disciplines, aliasing is an effect that causes different signals to
become indistinguishable (or aliases of one another) when sampled. It also often refers to
the distortion or artifact that results when a signal reconstructed from samples is different
from the original continuous signal.
Aliasing can occur in signals sampled in time, for instance digital audio, and is referred to as
temporal aliasing. It can also occur in spatially sampled signals (e.g. moiré patterns in digital
images); this type of aliasing is called spatial aliasing.

Anti-aliasing and Nyquist Theorem

An anti-aliasing filter (AAF) is a filter used before a signal sampler to restrict the bandwidth of
a signal to approximately or completely satisfy the Nyquist–Shannon sampling theorem over
the band of interest. Since the theorem states that unambiguous reconstruction of the signal
from its samples is possible when the power of frequencies above the Nyquist frequency is
zero, a real anti-aliasing filter trades off between bandwidth and aliasing. A realizable anti-
aliasing filter will typically either permit some aliasing to occur or else attenuate some in-
band frequencies close to the Nyquist limit. For this reason, many practical systems sample
higher than would be theoretically required by a perfect AAF in order to ensure that all
frequencies of interest can be reconstructed, a practice called oversampling.

Example:
Consider the analog signal ,
determine sampling and reconstruction signals.

T = 1 / 500

Since and are greater than , we map them to and respectively.


Sampled Signal

Reconstructed Signal
SAMPLING AND RECON
t=[0:0.1:2];

x2=sin(4*t);

T=pi/2;

n = t/T;

x3=sin(4*n*T);

figure(1);
plot(t,x2);

figure(2);
stem(n,x3);
GROUP NO: 50 ROLL NO: 1704108

EXPERIMENT 6: Implement image negative, gray level slicing and


thresholding

Theory:

Point Processing Techniques are among the simplest of all image enhancement techniques.

1. Negative of an Image:

The simple operation in image processing is to compute the negative of an image. It


can be done by reversing the pixel values from black to white and white to black.
Intensity of output image decreases as intensity of input image increases.

2. Thresholding:

It is a process of extracting a part of an image which contains information. In this


transformation, one threshold level is set and pixel values below threshold are to be
taken as 0 and above values are taken as 255.
Intermediate values of r1, r2, s1 and s2 produce various degrees of grey levels at
output which affects its contrast as shown in fig.

3. Gray Level Slicing with Background:

Grey level slicing is equivalent to band pass filtering. It manipulates groups of


intensity levels in an image up to specific range by diminishing rest or by leaving
them alone. This transformation is applicable in medical images and satellite images
such as X-ray flaws, CT scan. Two different approaches are adopted for grey level
slicing.
4. Gray Level Slicing without Background:

It displays high values in the specific region of an image and low values to other
regions by ignoring background.
NEGATIVE IMAGE
a = imread("My_photo.jpg");

img=rgb2gray(a);

sz = size(img);

for i = 1: sz(1)

for j = 1:sz(2)

b(i, j ) = 256 -1- a(i, j);

end
end

figure(1);

imshow(img);

figure(2);

imshow(b)

Original Image

Negative Index
THRESHOLDING
image = imread('My_photo.jpg');

image1=rgb2gray(image);

[r,c] = size(image1);

s = image1;

for i=1:r
for j=1:c

if(s(i,j)<100)

s(i,j) = 1;

end

end
end

figure(1),imshow(image1);title('Original image');

figure(2),imshow(s);title('Thresholding image');

Original Image Threshold Image


GRAY LEVEL SLICING
img = imread('My_photo.jpg');
img = rgb2gray(img);

without_background = uint8(img);

with_background = uint8(img);

[n,m] = size(without_background);

l = 256;

for i=1:n

for j=1:m
%With out BackGround

if(without_background(i,j)>120 & without_background(i,j)<220)

without_background(i,j) = l-1;

else
without_background(i,j) = 0;

end

%With BackGround

if(with_background(i,j)>120 & with_background(i,j)<220)


with_background(i,j) = l-1;

end

end

end
figure,imshow(img);title('Original Image');

figure;

imshow(without_background); title('Gray Level Slicing Without BackGround');

for i=1:n
for j=1:m
%With BackGround

if(without_background(i,j)>120 & without_background(i,j)<220)

without_background(i,j) = l-1;
end

end

end

figure;
imshow(with_background); title('Gray Level Slicing With BackGround');

Gray level Slicing without background Gray level Slicing with Background
GROUP NO: 50 ROLL NO: 1704108
EXPERIMENT 7: Implement contrast stretching, dynamic range compression
and bit plane slicing

Theory:

1. Contrast Stretching:

Contrast Stretching is used to increase the dynamic range of grey levels in an image.
It is required due to poor contrast. Poor Contrast normally occurs due to poor or
non-uniform illumination, non-linear dynamic range in an image sensor, wrong
setting of lens aperture. This technique simply increases the contrast of an image by
making dark regions darker and bright regions brighter
The linear normalization of a grayscale digital image is performed according to the
formula,

2. Dynamic Range Compression:

Dynamic range in photography describes the ratio between the maximum and
minimum measurable light intensities (white and black, respectively). In the real
world, one never encounters true white or black — only varying degrees of light
source intensity and subject reflectivity. Therefore the concept of dynamic range
becomes more complicated, and depends on whether you are describing a capture
device (such as a camera or scanner), a display device (such as a print or computer
display), or the subject itself.
One aim of HDR is to present a similar range of luminance to that experienced
through the human visual system. The human eye, through non-linear response,
adaptation of the iris, and other methods, adjusts constantly to a broad range of
luminance present in the environment. The brain continuously interprets this
information so that a viewer can see in a wide range of light conditions.

3. Bit Plane Slicing:

A bit plane of a digital discrete signal such as an image or sound, is a set of bits
corresponding to a given bit position in each of the binary numbers representing the
signal. For example, for 16-bit data representation there are 16 bit planes; the first
bit plane contains the set of the most significant bit, and the 16th contains the least
significant bit.

It is possible to see that the first bit plane gives the roughest but the most critical
approximation of values of a medium, and the higher the numbe r of the bit plane,
the less is its contribution to the final stage. Thus, adding a bit plane gives a better
approximation.

Digital steganography makes use of bit planes and the phenomena that too-
complicated visual patterns can not be perceived as “shape-informative”. It replaces
complex areas on the bit-planes of the vessel image with other complex data
patterns.
Bit Plane Slicing
img = imread('20200801_182446.jpg');

img = rgb2gray(img);

dimg = double(img);

s= 1;

z = mod(dimg,2);

z = 0;
for i=1:8

bit_plane = mod(floor(dimg/(2^(i-1))),2); % Right Shift by One Bit(Floor to make Binary Image )

subplot(2,4,i);

imshow(bit_plane);title(['Bit Plane ',num2str(s)]);

s = s+1;

z = z+bit_plane*(2^(i-1));

end

figure;imshow(img);title('Original Image');

Bit Plane Slicing


Contrast Stretching
img = imread(“My_photo_2.jpg");

gray_img = rgb2gray(img);

MP = 255;

a = min(gray_img(:));

b = max(gray_img(:));

R = b-a;

scale = R/MP;
p = (gray_img - a) .* scale;

p = round(p);

h1 = hist(uint8(gray_img));

figure;plot(h1)

h2 = hist(uint8(p));

figure;plot(h2)

figure; imshow(uint8(gray_img)); title("Original");

figure; imshow(uint8(p)); title("Contrast Stretched");


Dynamic Range
img = imread('20200801_182446.jpg');

img2 = rgb2gray(img);

img=double(img2);

figure(1),imshow(img),title('Orginal Image');

x = 150/255;

y = 200/255;

[n,m] = size(img);

for i=1:n

for j=1:m

img(i,j)=img(i,j)/255;

end

end

for i=1:n

for j=1:m

if(img(i,j)>x && img(i,j)<y)

img(i,j) = img(i,j)-(30/255);

end

end

end

for i=1:n

for j=1:m

img(i,j)=img(i,j)*255;

end

end

img=floor(img)

img=uint8(img)
figure(2),imshow(img),title('After Enhancement');
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner
Scanned with CamScanner

You might also like