-
Notifications
You must be signed in to change notification settings - Fork 6
/
ur5_creative.m
76 lines (71 loc) · 1.98 KB
/
ur5_creative.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
%% drawing 1: house
function [a,b,c,d]=ur5_creative()
RGB = imread('test.jpeg');
I = rgb2gray(RGB);
BW = edge(I,'canny');
[H,T,R] = hough(BW);
P = houghpeaks(H,6,'threshold',ceil(0.3*max(H(:))));
lines = houghlines(BW,T,R,P,'FillGap',10,'MinLength',7);
% figure, imshow(I), hold on
benchmark_x = lines(1).point1(1);
benchmark_y = lines(1).point1(2);
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
% plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
begin_x(k)=xy(1,1);
begin_y(k)=xy(1,2);
end_x(k)=xy(2,1);
end_y(k)=xy(2,2);
end_x(k)=(end_x(k)-benchmark_x)/7500;
end_y(k)=(end_y(k)-benchmark_y)/7500;
begin_x(k)=(begin_x(k)-benchmark_x)/7500;
begin_y(k)=(begin_y(k)-benchmark_y)/7500;
end
a=begin_x;
b=begin_y;
c=end_x;
d=end_y;
% figure, hold on
% for k = 1:length(lines)
% xy = [a(k) b(k);c(k) d(k)];
% plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','red');
% axis equal;
% end
end
%% drawing 2: abstract art
% function [a,b,c,d]=ur5_creative()
% I = imread('test2.jpg');
%I = rgb2gray(RGB);
% BW = edge(I,'canny');
% [H,T,R] = hough(BW);
% P = houghpeaks(H,18,'threshold',ceil(0.1*max(H(:))));
% lines = houghlines(BW,T,R,P,'FillGap',30,'MinLength',60);
% %figure, imshow(I), hold on
%
% benchmark_x = lines(1).point1(1);
% benchmark_y = lines(1).point1(2);
% for k = 1:length(lines)
% xy = [lines(k).point1; lines(k).point2];
% % plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
% begin_x(k)=xy(1,1);
% begin_y(k)=xy(1,2);
% end_x(k)=xy(2,1);
% end_y(k)=xy(2,2);
%
% end_x(k)=(end_x(k)-benchmark_x)/3000;
% end_y(k)=(end_y(k)-benchmark_y)/3000;
% begin_x(k)=(begin_x(k)-benchmark_x)/3000;
% begin_y(k)=(begin_y(k)-benchmark_y)/3000;
%
% end
% a=begin_x;
% b=begin_y;
% c=end_x;
% d=end_y;
% % figure, hold on
% % for k = 1:length(lines)
% % xy = [a(k) b(k);c(k) d(k)];
% % plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','red');
% % axis equal;
% % end
% end