Robotics Lectures-1 For Final Year Indir
Robotics Lectures-1 For Final Year Indir
Matlab Code:
I = imread('a3.jpg');
I=rgb2gray(I);
BW = edge(I,'canny');
[H,T,R] = hough(BW);
P = houghpeaks(H,2);
figure
imshow(I);
title('Original Image');
figure
imshow(BW);
title('Edges');
figure
imshow(H,[],'XData',T,'YData',R,'InitialMagnification','fit');
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
plot(T(P(:,2)),R(P(:,1)),'s','color','white');
Output:
OTSU Thresholding Method:
MATLAB CODE:
I=imread('l7.jpg');
I=rgb2gray(I);
figure(1)
imshow(I);
figure(2)
imhist(I);
n=imhist(I);
N=sum(n);
max=0;
for i=1:256
P(i)=n(i)/N;
end
for T=2:255
w0=sum(P(1:T));
w1=sum(P(T+1:256));
u0=dot([0:T-1],P(1:T))/w0;
u1=dot([T:255],P(T+1:256))/w1;
sigma=w0*w1*((u1-u0)^2);
if sigma>max
max=sigma;
threshold=T-1;
end
end
bw=im2bw(I,threshold/255);
figure(3)
imshow(bw);
OUTPUT: