Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- close all;
- clear all;
- obraz = zeros(11,11);
- obraz(6,7) = 1;
- [H, theta, rho] = hough(obraz, 'RhoResolution',0.1,'ThetaResolution',0.5);
- obraz(5,10) = 1;
- [H2 theta rho] = hough(obraz, 'RhoResolution',0.1,'ThetaResolution',0.5);
- obraz(1,1) = 1;
- obraz(3,3) = 1;
- [H3 theta rho] = hough(obraz, 'RhoResolution',0.1,'ThetaResolution',0.5);
- figure()
- subplot(1,3,1)
- imshow(H, []);
- subplot(1,3,2)
- imshow(H2, []);
- subplot(1,3,3)
- imshow(H3, []);
- ================================================
- clear all;
- close all;
- kwadraty=imread('kwadraty.tif');
- load('maskiPP.mat');
- abs1 = abs( conv2(kwadraty, R1, 'same') ) + abs( conv2(kwadraty, R2, 'same') );
- uin = uint8(abs1);
- % uin128 = uin + uint8(128 * ones(size(uin)));
- uinabs = abs(uin);
- figure()
- imshow(uinabs,[]);
- I=kwadraty;
- rotI = imrotate(I,33,'crop');
- BW = edge(rotI,'canny');
- [H,T,R] = hough(BW);
- figure(2)
- imshow(H,[],'XData',T,'YData',R,...
- 'InitialMagnification','fit');
- xlabel('\theta'), ylabel('\rho');
- axis on, axis normal, hold on;
- P = houghpeaks(H,8,'threshold',ceil(0.3*max(H(:))));
- x = T(P(:,2)); y = R(P(:,1));
- plot(x,y,'s','color','white');
- lines = houghlines(BW,T,R,P,'FillGap',5,'MinLength',7);
- figure, imshow(rotI), hold on
- max_len = 0;
- for k = 1:length(lines)
- xy = [lines(k).point1; lines(k).point2];
- plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
- % Plot beginnings and ends of lines
- plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
- plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
- % Determine the endpoints of the longest line segment
- len = norm(lines(k).point1 - lines(k).point2);
- if ( len > max_len)
- max_len = len;
- xy_long = xy;
- end
- end
- ==============================================
- close all;
- clear all;
- lab112=imread('lab112.bmp');
- lab112=rgb2gray(lab112);
- figure()
- imshow(lab112);
- figure()
- imhist(lab112);
- lab=lab112>20 & lab112<33;
- figure()
- imshow(lab);
- SE=strel('square',3);
- open=imopen(lab,SE);
- closee=imclose(open,SE);
- figure()
- imshow(closee);
- I=closee;
- rotI = imrotate(I,33,'crop');
- BW = edge(rotI,'canny');
- [H,T,R] = hough(BW);
- figure()
- imshow(H,[],'XData',T,'YData',R,...
- 'InitialMagnification','fit');
- xlabel('\theta'), ylabel('\rho');
- axis on, axis normal, hold on;
- P = houghpeaks(H,8,'threshold',ceil(0.3*max(H(:))));
- x = T(P(:,2)); y = R(P(:,1));
- plot(x,y,'s','color','white');
- lines = houghlines(BW,T,R,P,'FillGap',5,'MinLength',7);
- figure, imshow(rotI), hold on
- max_len = 0;
- for k = 1:length(lines)
- xy = [lines(k).point1; lines(k).point2];
- plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
- % Plot beginnings and ends of lines
- plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
- plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
- % Determine the endpoints of the longest line segment
- len = norm(lines(k).point1 - lines(k).point2);
- if ( len > max_len)
- max_len = len;
- xy_long = xy;
- end
- end
- ================================================
- close all;
- clear all;
- obraz = zeros(11,11);
- obraz(6,7) = 1;
- H = houghAB(obraz);
- obraz(5,10) = 1;
- H2 = houghAB(obraz);
- obraz(1,1) = 1;
- obraz(2,1) = 1;
- obraz(3,1) = 1;
- H3 = houghAB(obraz);
- figure()
- subplot(1,3,1)
- imshow(H, []);
- subplot(1,3,2)
- imshow(H2, []);
- subplot(1,3,3)
- imshow(H3, []);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement