Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
clc;
clear all;
close all;
x=[-1 1 2 3];
n=-2:1:1;
l=1;
m=n+l;
stem(n,x)
xlabel('n')
ylabel('x')
title('12481D3829 original signal')
figure, stem(m,x)
xlabel('m')
ylabel('x')
title('12481D3829 shifted signal')
output waveforms:
12481D3829 original signal
3
2.5
1.5
1
x
0.5
-0.5
-1
-2 -1.5 -1 -0.5 0 0.5 1
n
2.5
1.5
1
x
0.5
-0.5
-1
-1 -0.5 0 0.5 1 1.5 2
m
1(b) representation of disrete time signal and its scaling and reverse
signal
clc;
clear all;
close all;
x=[1 -1 2 3]
n=-1:1:2
l=2
m=n*l
subplot(2,2,1)
stem(n,x)
xlabel('n')
ylabel('x')
title('12481D3829 original signal x(n)')
subplot(2,2,2)
stem(m,x)
xlabel('m')
ylabel('x')
title('12481D3829 scaling signal x(n/2)')
p=n/l
subplot(2,2,3)
stem(p,x)
xlabel('p')
ylabel('x')
title('12481D3829 scaling signal x(2n)')
q=-n
subplot(2,2,4)
stem(q,x)
xlabel('q')
ylabel('x')
title('12481D3829 reversal signal x(-n)')
output waveforms:
2 2
1 1
x
x
0 0
-1 -1
-1 0 1 2 -2 0 2 4
n m
12481D3829 scaling signal x(2n) 12481D3829 reversal signal x(-n)
3 3
2 2
1 1
x
0 0
-1 -1
-0.5 0 0.5 1 -2 -1 0 1
p q
clc;
clear all;
close all;
x=[1 -1 2 3]
n=-1:1:2
b=[1 -1]
a=[1]
y=filter(b,a,x)
stem(n,x)
xlabel('n')
ylabel('x')
title('12481D3829 original signal')
figure,stem(n,y)
stem(n,y)
xlabel('n')
ylabel('y')
title('12481D3829 highpass filter')
output waveforms:
12481D3829 original signal
3
2.5
1.5
1
x
0.5
-0.5
-1
-1 -0.5 0 0.5 1 1.5 2
n
2.5
1.5
0.5
y
-0.5
-1
-1.5
-2
-1 -0.5 0 0.5 1 1.5 2
n
Ex:2- z-transforms
2(a z-transform
clc;
clear all;
close all;
syms n a w real
syms z complex
x=1^n
disp('z-transform of 1^n')
ztrans(x)
y=a^n
disp('z-transform of a^n')
ztrans(y)
p=cos(w*n)
disp('z-transform of cos(w*n)')
ztrans(p)
q=sin(w*n)
disp('z-transform of sin(w*n)')
ztrans(q)
iztrans(x,z,n)
simplify(x)
iztrans(y,z,n)
simplify(y)
iztrans(p,z,n)
simplify(p)
iztrans(q,z,n)
simplify(q)
2(b) representation of unit impulse , unit step, and unit ramp signals
clc;
clear all;
close all;
n=-10:1:10
x1=1
x2=0
x=x1.*(n==0)+x2.*(n~=0)
subplot(3,1,1)
stem(n,x)
xlabel('n')
ylabel('x(n)')
title('12481D3829 unit impulse signal')
x1=1
x2=0
x=x1.*(n>=0)+x2.*(n<0)
subplot(3,1,2)
stem(n,x)
xlabel('n')
ylabel('x(n)')
title('12481D3829 unitstep signal')
x1=n
x2=0
x=x1.*(n>=0)+x2.*(n<0)
subplot(3,1,3)
stem(n,x)
xlabel('n')
ylabel('x(n)')
title('12481D3829 unitramp signal')
output waveforms:
0.5
x(n)
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
12481D3829 unitstep signal
1
x(n)
0.5
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
12481D3829 unitramp signal
10
x(n)
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
n
2(c) impulse response of fir and iir systems
a) Fir system
clc;
clear all;
close all;
n=0:1:6
x=[1,zeros(1,6)]
b=[1 -3]
a=[1]
y=filter(b,a,x)
subplot(2,1,1)
stem(n,x)
xlabel('n')
ylabel('x')
title('12481D3829 impulse signal')
subplot(2,1,2)
stem(n,y)
xlabel('n')
ylabel('y')
title('12481D3829 impulse response of fir system')
output waveforms:
0.5
x
0
0 1 2 3 4 5 6
n
12481D3829 impulse response of fir system
1
-1
y
-2
-3
0 1 2 3 4 5 6
n
b) iir system
clc;
clear all;
close all;
n=0:1:6
x=[1,zeros(1,6)]
b=[1 0 5]
a=[1 0.5]
y=filter(b,a,x)
subplot(2,1,1)
stem(n,x)
xlabel('n')
ylabel('x')
title('12481D3829 impulse signal')
subplot(2,1,2)
stem(n,y)
xlabel('n')
ylabel('y')
title('12481D3829 impulse response of iir system')
output waveforms:
0.5
x
0
0 1 2 3 4 5 6
n
12481D3829 impulse response of iir system
10
5
y
-5
0 1 2 3 4 5 6
n
Ex:3- Discrete Fourier Transform and its Properties
clc
clear all
close all
N=4
j=sqrt(-1)
xn=[1 3 -4 5]
xk=zeros(1,N)
for k=0:1:N-1
for n=0:1:N-1
xk(k+1)=xk(k+1)+xn(n+1)*exp(-j*2*pi*k*n/N)
end
end
wk=0:1:N-1
subplot(2,1,1)
stem(wk,abs(xk))
title('12481D3829 magnitude spectrum')
xlabel('k')
ylabel('abs(xk)')
subplot(2,1,2)
stem(wk,angle(xk))
title('12481D3829 phase spectrum')
xlabel('k')
ylabel('angle(xk)')
output waveforms:
10
abs(xk)
0
0 0.5 1 1.5 2 2.5 3
k
12481D3829 phase spectrum
2
0
angle(xk)
-2
-4
0 0.5 1 1.5 2 2.5 3
k
10
abs(xk)
0
0 0.5 1 1.5 2 2.5 3
k
12481D3829 phase spectrum
2
1
angle(xk)
-1
-2
0 0.5 1 1.5 2 2.5 3
k
3(b) Discrete Fourier Transform properties
a) periodicity property
clc
clear all
close all
N=4
j=sqrt(-1)
xn=[1 3 -4 5]
n=0:1:3
xk=zeros(1,8)
subplot(2,1,1)
stem(n,xn)
title('12481D3829 original sequence')
xlabel('n')
ylabel('xn')
for k=0:1:7
for n=0:1:3
xk(k+1)=xk(k+1)+xn(n+1)*exp(-j*2*pi*k*n/N)
end
end
wk=0:1:7
subplot(2,1,2)
stem(wk,abs(xk))
title('12481D3829 magnitude spectrum')
xlabel('k')
ylabel('abs(xk)')
output waveforms:
-5
0 0.5 1 1.5 2 2.5 3
n
12481D3829 magnitude spectrum
15
10
abs(xk)
0
0 1 2 3 4 5 6 7
k
b) circular convolution property
clc
clear all
close all
N=max(N1,N2)
n=0:1:N-1
subplot(3,1,1)
stem(n,x1n)
title('12481D3829 first sequence')
xlabel('n')
ylabel('x1n')
subplot(3,1,2)
stem(n,x2n)
title('12481D3829 second sequence')
xlabel('n')
ylabel('x2n')
x1n=[x1n zeros(1,N-N1)]
x2n=[x2n zeros(1,N-N2)]
for n=0:1:N-1;
y(n+1)=0;
for l=0:N-1
p=mod(n-l,N);
y(n+1)=y(n+1)+x1n(l+1)*x2n(p+1);
end
end
disp(y)
n=0:1:3
subplot(3,1,3)
stem(n,y)
title('12481D3829 circular convolution')
xlabel('n')
ylabel('y')
x1k=zeros(1,N)
x2k=zeros(1,N)
for k=0:1:3
for n=0:1:3
x1k(k+1)=x1k(k+1)+x1n(n+1)*exp(-j*2*pi*k*n/N)
end
end
wk=0:1:N-1
figure,subplot(3,1,1)
stem(wk,abs(x1k))
title('12481D3829 magnitude spectrum x1k')
xlabel('k')
ylabel('abs(x1k)')
for k=0:1:3
for n=0:1:3
x2k(k+1)=x2k(k+1)+x2n(n+1)*exp(-j*2*pi*k*n/N)
end
end
wk=0:1:N-1
subplot(3,1,2)
stem(wk,abs(x2k))
title('12481D3829 magnitude spectrum x2k')
xlabel('k')
ylabel('abs(x2k)')
x3k=x1k.*x2k
x3n=zeros(1,N)
for n=0:1:3
for k=0:1:3
x3n(n+1)=x3n(n+1)+x3k(k+1)*exp(j*2*pi*k*n/N)/N
end
end
n=0:1:N-1
subplot(3,1,3)
stem(n,x3n)
title('12481D3829 idft')
xlabel('n')
ylabel('idft)')
output waveforms:
0
0 0.5 1 1.5 2 2.5 3
n
12481D3829 second sequence
4
x2n
0
0 0.5 1 1.5 2 2.5 3
n
12481D3829 circular convolution
20
10
y
0
0 0.5 1 1.5 2 2.5 3
n
0
0 0.5 1 1.5 2 2.5 3
k
12481D3829 magnitude spectrum x2k
10
abs(x2k)
0
0 0.5 1 1.5 2 2.5 3
k
12481D3829 idft
20
idft)
10
0
0 0.5 1 1.5 2 2.5 3
n
Ex:4- iir filter design
clc
clear all
close all
wp=input('pass band frequency wp=')
ws=input('stop band frequency ws=')
ap=input('pass band attenuation ap=')
as=input('pass band attenuation as=')
T=1
n=(log(((10^(ap/10))-1)/((10^(as/10))-1))/(2*log(wp/ws)))
if round(n)==n
wc=wp/((10^(0.1*ap)-1))^(1/(2*n))
else n=fix(n)+1
wc=wp/((10^(0.1*ap)-1))^(1/(2*n))
end
if rem(n,2)==1
for k=1:1:(2*n)
sk(k)=(exp((j*pi*k)/(n)))
end
else
for k=1:1:(2*n)
sk(k)=(exp((j*pi)/(2*n))*exp((j*pi*k)/(n)))
end
end
pk=0
l=1
for k=1:1:(2*n)
if real(sk(k))<0
pk(l)=sk(k)
l=l+1
end
end
zk=[]
[b,a]=zp2tf(zk,pk,1)
sy=tf(b,a)
q=wc^n;
pk1=pk.*wc
[b1,a1]=zp2tf(zk,pk1,q)
sys=tf(b1,a1)
[H w]=freqs(b1,a1)
[bz,az]=bilinear(b1,a1,1)
sy=tf(bz,az,T)
[bz,az]=impinvar(b1,a1,1)
sy=tf(bz,az)
plot(w/pi,20*log10(abs(H)))
xlabel('w/pi')
ylabel('H')
title('12-3829 butterworth lpf magnitude')
figure,plot(w/pi,angle(H))
xlabel('w/pi')
ylabel('angle')
title('12-3829 butterworth lpf phase')
output waveforms:
12-3829 butterworth lpf magnitude
0
-5
-10
-15
H
-20
-25
-30
0 50 100 150 200 250 300 350
w/pi
12-3829 butterworth lpf phase
4
1
angle
-1
-2
-3
-4
0 50 100 150 200 250 300 350
w/pi
clc
clear all
close all
wp=input('pass band frequency wp=')
ws=input('stop band frequency ws=')
rp=input('pass band attenuation ap=')
rs=input('pass band attenuation as=')
t=(((10^(0.1*rs))-1)/((10^(0.1*rp))-1))^(0.5)
k=ws/wp
n=(acosh(t))/(acosh(k))
N=ceil(n)
e=sqrt((10^(0.1*rp))-1)
u=(1/e)+sqrt(1+1/(e^2))
a=(wp/2)*((u^(1/N))-(u^(-1/N)))
b=(wp/2)*((u^(1/N))+(u^(-1/N)))
for k=1:N
an=(pi/2)+(((2*k-1)*pi)/(2*N))
s(k)=a*cos(an)+i*b*sin(an)
end
zk=[]
[b,a]=zp2tf(zk,s,1)
sy=tf(b,a)
g1=numel(b)
g=numel(a)
if rem(N,2)==0
n=a(1,g)/sqrt(1+e^2)
else
n=a(1,g)
end
b(1,g1)=n
sy=tf(b,a)
T=1
[bz,az]=bilinear(b,a,1)
sy=tf(bz,az,T)
[H w]=freqs(b,a)
plot(w/pi,20*log10(abs(H)))
xlabel('w/pi')
ylabel('H')
title('12481D3829 chebychev lpf magnitude')
figure,plot(w/pi,angle(H))
xlabel('w/pi')
ylabel('angle')
title('12481D3829 chebichev lpf phase')
[bz,az]=impinvar(b,a,1)
sy=tf(bz,az,T)
output waveforms:
12481D3829 chebychev lpf magnitude
0
-5
-10
H
-15
-20
-25
0 50 100 150 200 250 300 350
w/pi
12481D3829 chebichev lpf phase
0
-0.5
-1
angle
-1.5
-2
-2.5
-3
0 50 100 150 200 250 300 350
w/pi
5 a)Fir LPF
clc
clear all
close all
N=input('enter legth of the sequence')
wc=input('enter the cutoff frequency')
p=(N-1)/2
for n=0:1:N-1
h(n+1)=(wc/pi)*(sin(wc*(n-p)+0.00001))/(wc*(n-p)+0.00001)
w=rectwin(n+1)
hd(n+1)=h(n+1).*w(n+1)
b=hd
end
a=[1]
[H w]=freqz(b,a)
plot(w/pi,20*log(abs(H)))
xlabel('w/pi')
ylabel('magnitude of H(w)')
title('12481d3801 magnitude spectrum of LPF')
grid
figure,plot(w/pi,angle(H))
xlabel('w/pi')
ylabel('phase of H(w)')
title('12481d3801 phase spectrum of LPF')
grid
output waveforms:
12481d3829 magnitude spectrum of LPF
10
-10
magnitude of H(w)
-20
-30
-40
-50
-60
-70
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
w/pi
12481d3829 phase spectrum of LPF
1.5
0.5
-0.5
phase of H(w)
-1
-1.5
-2
-2.5
-3
-3.5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
w/pi
5 b) fir hpf
clc
clear all
close all
N=input('enter legth of the sequence')
wc=input('enter the cutoff frequency')
al=(N-1)/2
for n=0:1:N-1
if (wc*(n-al))==0
h(n+1)=(sinc(pi*(n-al)))-((wc/pi)*(sinc(wc*(n-al))))
else
h(n+1)=((sin(pi*(n-al)))-(sin(wc*(n-al))))/(pi*(n-al))
end
w=rectwin(n+1)
hf(n+1)=h(n+1).*w(n+1)
b=hf
end
a=[1]
[H w]=freqz(b,a)
plot(w/pi,20*log10( abs(H)))
xlabel('w/pi')
ylabel('magnitude of H(w)')
title('12481d3801 magnitude spectrum of hPF')
grid
figure,plot(w/pi,angle(H))
xlabel('w/pi')
ylabel('phase of H(w)')
title('12481d3801 phase spectrum of hPF')
grid
output waveforms:
-10
magnitude of H(w)
-20
-30
-40
-50
-60
-70
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
w/pi
12481d3829 phase spectrum of HPF
4
1
phase of H(w)
-1
-2
-3
-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
w/pi
5 c) fir bpf
clc
clear all
close all
N=input('enter legth of the sequence')
wc1=input('enter the lower cutoff frequency')
wc2=input('enter the upper cutoff frequency')
al=(N-1)/2
for n=0:1:N-1
if ((wc2*(n-al))==0|(wc1*(n-al))==0)
h(n+1)=(wc2/pi)*(sinc(wc2*(n-al)))-(wc1/pi)*(sinc(wc1*(n-al)))
else
h(n+1)=((sin(wc2*(n-al)))-(sin(wc1*(n-al))))/(pi*(n-al))
end
w=rectwin(n+1)
hf(n+1)=h(n+1).*w(n+1)
b=hf
end
a=[1]
[H w]=freqz(b,a)
plot(w/pi,20*log10( abs(H)))
xlabel('w/pi')
ylabel('magnitude of H(w)')
title('12481d3801 magnitude spectrum of BPF')
grid
figure,plot(w/pi,angle(H))
xlabel('w/pi')
ylabel('phase of H(w)')
title('12481d3801 phase spectrum of BPF')
grid
output waveforms:
12481d3829 magnitude spectrum of BPF
0
-10
-20
magnitude of H(w)
-30
-40
-50
-60
-70
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
w/pi
12481d3829 phase spectrum of BPF
4
1
phase of H(w)
-1
-2
-3
-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
w/pi
5 d) fir brf
clc
clear all
close all
N=input('enter legth of the sequence')
wc1=input('enter the lower cutoff frequency')
wc2=input('enter the upper cutoff frequency')
al=(N-1)/2
for n=0:1:N-1
if ((wc2*(n-al))==0|(wc1*(n-al))==0)
h(n+1)=((wc1/pi)*(sinc(wc1*(n-al))))-((wc2/pi)*(sinc(wc2*(n-al))))+(sinc(pi*(n-al)))
else
h(n+1)=((sin(wc1*(n-al)))-(sin(wc2*(n-al)))+(sin(pi*(n-al))))/(pi*(n-al))
end
w=rectwin(n+1)
hf(n+1)=h(n+1).*w(n+1)
b=hf
end
a=[1]
[H w]=freqz(b,a)
plot(w/pi,20*log(abs(H)))
xlabel('w/pi')
ylabel('magnitude of H(w)')
title('12481d3801 magnitude spectrum of BRF')
grid
figure,plot(w/pi,angle(H))
xlabel('w/pi')
ylabel('phase of H(w)')
title('12481d3801 phase spectrum of BRF')
grid
output waveforms:
12481d3829 magnitude spectrum of BRF
5
0
magnitude of H(w)
-5
-10
-15
-20
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
w/pi
12481d3829 phase spectrum of BRF
4
1
phase of H(w)
-1
-2
-3
-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
w/pi
subprogram:
function dn = unsys(xn)
global INPUTVEC % Global variable
uw = [1 -1.416 5 -1.416 1]; % System Coefficients
len = length(uw); % Length of system
INPUTVEC(1) = xn; % get new sample
if length(INPUTVEC) ~= len
INPUTVEC(len) = 0;
end
dn = uw*INPUTVEC'; % convolve samples with uw
for i = len:-1:2 % update coefficients
INPUTVEC(i) = INPUTVEC(i-1);
end
output waveforms:
0.4
magnitude
0.3
0.2
0.1
0 1 2 3 4 5 6 7
frequency
0.4
0.2
phase
-0.2
-0.4
0 1 2 3 4 5 6 7
frequency
12-3829 Plot of Mean Square Error vs. Iteration Number
3
2.5
2
MSE
1.5
0.5
0
0 0.5 1 1.5 2 2.5 3
Iteration
1
noisy signal
-1
-2
-3
0 100 200 300 400 500 600 700 800 900 1000
time
1.5
0.5
filtered signal
-0.5
-1
-1.5
-2
0 100 200 300 400 500 600 700 800 900 1000
time
2
1.8
1.6
1.4
1.2
0.8
0.35
0.3
0.25
noisy signal
0.2
0.15
0.1
0.05
0
0 1000 2000 3000 4000 5000 6000 7000 8000
frequency
0.35
0.3
0.25
filtered signal
0.2
0.15
0.1
0.05
0
0 1000 2000 3000 4000 5000 6000 7000 8000
frequency
2.5
1.5
MSE
0.5
0
0 100 200 300 400 500 600 700 800 900 1000
time
CYCLE-II: IMAGE PROCESSING
flipped image
crop image-2
crop image-1
0 0
0 100 200 0 100 200
arithematic operations
clc;
clear all;
close all;
i1=imread('horsebw.jpg');
i1r=imresize(i1,[256,256]);
subplot(3,3,1)
imshow(i1r)
title('resized image1')
i2=imread('manbw.jpg');
i2r=imresize(i2,[256,256]);
subplot(3,3,2)
imshow(i2r)
title('resized image2');
ai=imadd(i1r,i2r);
subplot(3,3,3);
imshow(ai);
title('added image');
si=imsubtract(i1r,i2r);
subplot(3,3,4);
imshow(si);
title('subtracted image');
mi=immultiply(i1r,i2r);
subplot(3,3,5);
imshow(mi);
title('multiplied image');
di=imdivide(i1r,i2r);
subplot(3,3,6);
imshow(di);
title('divided image');
Output for Arithematic operations:
resized image1 resized image2 added image
removal of noise
clc;
clear all;
close all;
ir=imread('rice.png');
subplot(1,3,1)
imshow(ir)
title('originalimage');
ni=imnoise(ir,'salt & pepper');
subplot(1,3,2)
imshow(ni)
title('noisy image');
nl=medfilt2(ni,[3 3]);
subplot(1,3,3)
imshow(nl);
title('noise less image or original image');
0 0
0 100 200 0 100 200
histogram of eqalized image2 histogram of readed image
readed image
1000
1000
500
0 0
0 100 200 0 100 200
histogram of adjusted image
adjusted image
2000
0
0 100 200
b) image smoothening & image sharpening
clc;
clear all;
close all;
ir=imread('rice.png');
subplot(1,3,1)
imshow(ir)
title('originalimage');
w=[0 1 0;1 -4 1;0 1 0]
shi=imfilter(ir,w)
subplot(1,3,2)
imshow(shi)
title('sharpening image');
ww=(1/9)*[1 1 1;1 1 1;1 1 1]
soi=imfilter(ir,ww)
subplot(1,3,3)
imshow(soi)
title('smoothening image');
Output for image smoothening & image sharpening:
a) line detection
clc;
clear all;
close all;
ir=imread('redrose1.jpg');
subplot(2,2,1)
imshow(ir)
title('originalimage');
w1=[-1 -1 -1;2 2 2;-1 -1 -1]
hi=imfilter(ir,w1)
subplot(2,2,2)
imshow(hi)
title('horizontal line detection');
w2=[-1 2 -1;-1 2 -1;-1 2 -1]
vi=imfilter(ir,w2)
subplot(2,2,3)
imshow(vi)
title('vertical line detection');
w3=[ 2 -1 -1;-1 2 -1;-1 -1 2]
si=imfilter(ir,w3)
subplot(2,2,4)
imshow(si)
title('slant line detection');
Output for line detection:
originalimage horizontal line detection
clc;
clear all;
close all;
ir=imread('redrose1.jpg');
subplot(3,3,1)
imshow(ir)
title('originalimage');
w1=[-1 -2 -1;0 0 0;1 2 1];
hi=imfilter(ir,w1)
subplot(3,3,2)
imshow(hi)
title('sobelhorizontaledgedetection');
w2=[-1 0 1;-1 0 1;-1 0 1];
vi=imfilter(ir,w2)
subplot(3,3,3)
imshow(vi)
title('sobelverticaledgedetection');
w3=[-1 -1 -1;0 0 0;1 1 1];
phi=imfilter(ir,w3)
subplot(3,3,4)
imshow(phi)
title('prewitthorizontaledgedetection');
w4=[-1 0 1 ; -1 0 1 ; -1 0 1 ];
pvi=imfilter(ir,w4)
subplot(3,3,5)
imshow(pvi)
title('prewittverticaledgedetection');
w5=[-1 0;0 1];
rhi=imfilter(ir,w5)
subplot(3,3,6)
imshow(rhi)
title('roberthorizontaledgedetection');
originalimage sobelhorizontaledgedetectionsobelverticaledgedetection
prewitthorizontaledgedetection
prewittverticaledgedetection
roberthorizontaledgedetection
c) point detection
clc;
clear all;
close all;
f=zeros(30,30);
f(5:5,15:15)=1;
subplot(3,3,1);
imshow(f);
title('original image');
w=[1 1 1 ;1 -8 1;1 1 1];
pi= imfilter(f,w);
subplot(3,3,2);
imshow(pi);
title('point detection');
clc;
clear all;
close all;
ir=imread('RAO.jpg');
ri=imresize(ir,[256,256]);
subplot(3,3,1)
imshow(ri)
title('original image');
se=strel('diamond',4);
di=imdilate(ri,se);
subplot(3,3,2)
imshow(di)
title('dilated image');
ei=imerode(ri,se);
subplot(3,3,3)
imshow(ei)
title('eroded image');
ni=imcomplement(ei);
subplot(3,3,4)
imshow(ni)
title('complemented image');
ai=imadd(ei,di)
subplot(3,3,5)
imshow(ai)
title('added image');
g=bwmorph(ri,'dilate')
subplot(3,3,6)
imshow(g)
title('dilation using command');
h=bwmorph(ri,'erode');
subplot(3,3,7)
imshow(h)
title('erosion using command');