Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. close all;
  2. clear all;
  3.  
  4. obraz = zeros(11,11);
  5. obraz(6,7) = 1;
  6.  
  7. [H, theta, rho] = hough(obraz, 'RhoResolution',0.1,'ThetaResolution',0.5);
  8.  
  9.  
  10. obraz(5,10) = 1;
  11. [H2 theta rho] = hough(obraz, 'RhoResolution',0.1,'ThetaResolution',0.5);
  12.  
  13. obraz(1,1) = 1;
  14. obraz(3,3) = 1;
  15.  
  16. [H3 theta rho] = hough(obraz, 'RhoResolution',0.1,'ThetaResolution',0.5);
  17.  
  18. figure()
  19. subplot(1,3,1)
  20. imshow(H, []);
  21. subplot(1,3,2)
  22. imshow(H2, []);
  23. subplot(1,3,3)
  24. imshow(H3, []);
  25.  
  26.  
  27. ================================================
  28.  
  29.  
  30.  
  31. clear all;
  32. close all;
  33.  
  34. kwadraty=imread('kwadraty.tif');
  35.  
  36. load('maskiPP.mat');
  37.  
  38. abs1 = abs( conv2(kwadraty, R1, 'same') ) + abs( conv2(kwadraty, R2, 'same') );
  39. uin = uint8(abs1);
  40. % uin128 = uin + uint8(128 * ones(size(uin)));
  41. uinabs = abs(uin);
  42.  
  43. figure()
  44. imshow(uinabs,[]);
  45.  
  46. I=kwadraty;
  47. rotI = imrotate(I,33,'crop');
  48. BW = edge(rotI,'canny');
  49.  
  50. [H,T,R] = hough(BW);
  51. figure(2)
  52. imshow(H,[],'XData',T,'YData',R,...
  53. 'InitialMagnification','fit');
  54. xlabel('\theta'), ylabel('\rho');
  55. axis on, axis normal, hold on;
  56.  
  57. P = houghpeaks(H,8,'threshold',ceil(0.3*max(H(:))));
  58. x = T(P(:,2)); y = R(P(:,1));
  59. plot(x,y,'s','color','white');
  60.  
  61. lines = houghlines(BW,T,R,P,'FillGap',5,'MinLength',7);
  62. figure, imshow(rotI), hold on
  63. max_len = 0;
  64.  
  65. for k = 1:length(lines)
  66. xy = [lines(k).point1; lines(k).point2];
  67. plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
  68.  
  69. % Plot beginnings and ends of lines
  70. plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
  71. plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
  72.  
  73. % Determine the endpoints of the longest line segment
  74. len = norm(lines(k).point1 - lines(k).point2);
  75. if ( len > max_len)
  76. max_len = len;
  77. xy_long = xy;
  78. end
  79. end
  80.  
  81.  
  82.  
  83.  
  84.  
  85. ==============================================
  86.  
  87.  
  88.  
  89.  
  90.  
  91. close all;
  92. clear all;
  93.  
  94. lab112=imread('lab112.bmp');
  95. lab112=rgb2gray(lab112);
  96.  
  97.  
  98. figure()
  99. imshow(lab112);
  100.  
  101. figure()
  102. imhist(lab112);
  103.  
  104. lab=lab112>20 & lab112<33;
  105.  
  106. figure()
  107. imshow(lab);
  108.  
  109. SE=strel('square',3);
  110. open=imopen(lab,SE);
  111. closee=imclose(open,SE);
  112.  
  113. figure()
  114. imshow(closee);
  115.  
  116. I=closee;
  117. rotI = imrotate(I,33,'crop');
  118. BW = edge(rotI,'canny');
  119.  
  120.  
  121. [H,T,R] = hough(BW);
  122. figure()
  123. imshow(H,[],'XData',T,'YData',R,...
  124. 'InitialMagnification','fit');
  125. xlabel('\theta'), ylabel('\rho');
  126. axis on, axis normal, hold on;
  127.  
  128. P = houghpeaks(H,8,'threshold',ceil(0.3*max(H(:))));
  129. x = T(P(:,2)); y = R(P(:,1));
  130. plot(x,y,'s','color','white');
  131.  
  132. lines = houghlines(BW,T,R,P,'FillGap',5,'MinLength',7);
  133. figure, imshow(rotI), hold on
  134. max_len = 0;
  135. for k = 1:length(lines)
  136. xy = [lines(k).point1; lines(k).point2];
  137. plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
  138.  
  139. % Plot beginnings and ends of lines
  140. plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
  141. plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
  142.  
  143. % Determine the endpoints of the longest line segment
  144. len = norm(lines(k).point1 - lines(k).point2);
  145. if ( len > max_len)
  146. max_len = len;
  147. xy_long = xy;
  148. end
  149. end
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157. ================================================
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165. close all;
  166. clear all;
  167.  
  168. obraz = zeros(11,11);
  169. obraz(6,7) = 1;
  170.  
  171. H = houghAB(obraz);
  172.  
  173.  
  174. obraz(5,10) = 1;
  175. H2 = houghAB(obraz);
  176.  
  177. obraz(1,1) = 1;
  178. obraz(2,1) = 1;
  179. obraz(3,1) = 1;
  180.  
  181. H3 = houghAB(obraz);
  182.  
  183. figure()
  184. subplot(1,3,1)
  185. imshow(H, []);
  186. subplot(1,3,2)
  187. imshow(H2, []);
  188. subplot(1,3,3)
  189. imshow(H3, []);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement