0% found this document useful (0 votes)
50 views3 pages

Internal Lab

This document contains code to perform several image processing and communication techniques: 1. It simulates binary error rate for digital communication by generating random binary signals, adding noise, and comparing to theoretical BER curves. 2. It applies the discrete cosine transform to an image to transform it into frequency domain and removes small coefficients to compress the image. 3. It downsamples an image by a factor of 6 using bilinear interpolation, then quantizes pixel values to compress the image further. 4. It generates a Hamming code with m=3 and encodes/decodes data, performing error correction on received bits using the syndrome table. 5. It applies 4 different edge detection filters - Prew

Uploaded by

Faiz Ahmed
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views3 pages

Internal Lab

This document contains code to perform several image processing and communication techniques: 1. It simulates binary error rate for digital communication by generating random binary signals, adding noise, and comparing to theoretical BER curves. 2. It applies the discrete cosine transform to an image to transform it into frequency domain and removes small coefficients to compress the image. 3. It downsamples an image by a factor of 6 using bilinear interpolation, then quantizes pixel values to compress the image further. 4. It generates a Hamming code with m=3 and encodes/decodes data, performing error correction on received bits using the syndrome table. 5. It applies 4 different edge detection filters - Prew

Uploaded by

Faiz Ahmed
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

%%BER

clc;clear all;close all;


N = 10^6;
rand('state',100);
randn('state',200);
ip=rand(1,N)>0.5;
s=2*ip-1;
n=1/sqrt(2)*[randn(1,N)+j*randn(1,N)];
eb_no = [-3:10];
for i =1:length(eb_no)
y = s+10^(-eb_no(i)/20)*n;
iph=real(y)>0;
nerr(i)=size(find([ip-iph]),2);
end
sim_err=nerr/N;
the_err=0.5*erfc(sqrt(10.^(eb_no/10)));
semilogy(eb_no,the_err,'b.-');
hold on
semilogy(eb_no,sim_err,'rx-');
grid on
legend('Theory','Simulation');
%x=eb/no,y=BER
%%
%DCT on image
clc;clear all;close all;
I = imread('BI.jpg');
i = rgb2gray(I);
%show original image - imshow()
j=dct2(i);
imshow(log(abs(j)),[]);
j(abs(j)<20)=0;
figure;imshow(log(abs(j)),[])
%%

%sampling and quantization


clc;clear all;close all;
I = imread('BI.jpg');
i = rgb2gray(I);
l = 6;
di = downsample(i,l);
di = transpose(di);
di = downsample(di,l);
di = transpose(di);
imshow(di);
%show image di and its histogram imhist()
k = size(i);
q=50;
for x =1:k(1)
for y =1:k(2)
ri = rem(i(x,y),q);
if(ri~=0)
i(x,y)=i(x,y)-(q-ri);
end
end
end
figure;imshow(i);
%show image i and its histogram imhist()
%%
%Hamming
clc;clear all;close all;
m=3;
[h,g,n,k]=hammgen(m);
%disp h,g,n,k
c=0:1:2^m-1;
c=dec2bin(c);
v_c=rem(c*h,2)
r=input('recieved bits: ');

trt=syndtable(h)
synd=rem(r*h',2)
synd_d=bi2de(synd,'left-msb')
cor_vect = trt(1+synd_d,:)
corrected = rem(cor_vect+r,2)
%%
%Edge Detection
clc;clear all;close all;
I = imread('BI.jpg');
i = rgb2gray(I);
e1=edge(i,'prewitt');
e2=edge(i,'sobel');
e3=edge(i,'canny');
e4=edge(i,'roberts');
%show the 4 output images

You might also like