0% found this document useful (0 votes)
2 views9 pages

dc_assignment_1 (1)

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)
2 views9 pages

dc_assignment_1 (1)

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/ 9

UEC1501 – Digital Communication

Assignment (CO1)
Name: Mohanapriya K
Reg.No:3122223002076

A subsection of the transmitter section of a communication system is shown in


the below figure. Consider the input as your face image (resize as 256×256),
find the transmitted signal Y with the waveform codec as DPCM and Delta.

 Implement the system using MATLAB. Submit your design with


supportive illustrations & calculations.
 Tabulate and comment on the bandwidth required for coded waveforms
and raw image transmission (without coding).

 Consider the first five samples of the source image and represent them
using a line coding format. Specify the disadvantage in it and suggest a
suitable pulse shaping methodology to overcome it.
Note: if you use colour image as input convert that to gray level
image and proceed.

Matlab Code:

% Load and preprocess the image


img = imread('76.jpg'); % Load the image file
img = imresize(img, [256, 256]); % Resize to 256x256
if size(img, 3) == 3
img = rgb2gray(img); % Convert to grayscale if it's a color image
end
img = double(img); % Convert image to double for processing

% Display the original image


figure;
imshow(uint8(img));
title('Original Image (256 x 256)');

% Select the first five samples from the image for NRZ representation
first_five_samples = img(1, 1:5); % Take first five values from the first
row

% Display selected five sample values for verification


disp('Selected first five sample values for NRZ representation:');
disp(first_five_samples);

% Step 2: DPCM Encoding


dpcm_encoded = zeros(size(img));
predicted_value = 0;

for i = 1:numel(img)
dpcm_encoded(i) = img(i) - predicted_value;
predicted_value = img(i);
end

% Display the DPCM encoded image


figure;
imshow(uint8(dpcm_encoded + 128)); % Shift to make values visible in
grayscale
title('DPCM Encoded Image');

% Step 3: Delta Modulation (DM) Encoding


step_size = 1; % Adjust as needed
dm_encoded = zeros(size(img));
dm_signal = 0;

for i = 1:numel(img)
if img(i) > dm_signal
dm_encoded(i) = 1;
dm_signal = dm_signal + step_size;
else
dm_encoded(i) = -1;
dm_signal = dm_signal - step_size;
end
end

% Display the Delta Modulation encoded image


figure;
imshow(uint8((dm_encoded + 1) * 127.5)); % Normalize values for
display
title('Delta Modulation Encoded Image');

% Step 4: Bitrate and Bandwidth Calculation


raw_bitrate = 256 * 256 * 8; % Bits per pixel (8 bits for grayscale)
dpcm_bitrate = nnz(dpcm_encoded) * 8; % Bitrate based on non-zero
values in DPCM
dm_bitrate = nnz(dm_encoded) * 1; % 1 bit per symbol for DM

% Assuming bandwidth is proportional to bitrate


raw_bandwidth = raw_bitrate; % Same as bitrate for simplicity
dpcm_bandwidth = dpcm_bitrate; % Same as bitrate for DPCM
dm_bandwidth = dm_bitrate; % Same as bitrate for DM

% Prepare table data with scientific notation using '×10^'


input_sizes = repmat({'256 x 256'}, 3, 1); % Repeat to match rows
codecs = {'No', 'DPCM', 'DM'};

% Convert values to strings with exponent format using '×10^'


bitrates = {sprintf('%.2f × 10^%d bps',
raw_bitrate/10^floor(log10(raw_bitrate)), floor(log10(raw_bitrate))), ...
sprintf('%.2f × 10^%d bps',
dpcm_bitrate/10^floor(log10(dpcm_bitrate)),
floor(log10(dpcm_bitrate))), ...
sprintf('%.2f × 10^%d bps',
dm_bitrate/10^floor(log10(dm_bitrate)), floor(log10(dm_bitrate)))}; %
bps for bitrate
bandwidths = {sprintf('%.2f × 10^%d Hz',
raw_bandwidth/10^floor(log10(raw_bandwidth)),
floor(log10(raw_bandwidth))), ...
sprintf('%.2f × 10^%d Hz',
dpcm_bandwidth/10^floor(log10(dpcm_bandwidth)),
floor(log10(dpcm_bandwidth))), ...
sprintf('%.2f × 10^%d Hz',
dm_bandwidth/10^floor(log10(dm_bandwidth)),
floor(log10(dm_bandwidth)))}; % Hz for bandwidth

% Display table of results


T = table(input_sizes, codecs', bitrates', bandwidths', ...
'VariableNames', {'Input_Size', 'Codec', 'Bitrate', 'Bandwidth'});

disp(T);

% Step 5: Line Coding for First Five Samples using NRZ


% Apply scaling factor for better visualization if needed
scaling_factor = 10; % Adjust scaling to make small variations visible
scaled_samples = first_five_samples * scaling_factor;
time = 1:5;

% Plot NRZ Representation with scaled samples


figure;
stairs(time, scaled_samples, 'LineWidth', 2); % Using 'stairs' for NRZ
title('NRZ Line Coding for First Five Samples (Scaled)');
xlabel('Sample Number');
ylabel(['Amplitude (Scaled by ', num2str(scaling_factor), ')']);
grid on;

% Display disadvantages and solutions


disp('Disadvantage of line coding: High-frequency components increase
bandwidth.');
disp('Solution: Use pulse shaping filters like raised cosine to reduce ISI
and bandwidth requirements.');
Output:

You might also like