Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %1
- close all;
- clear all;
- obraz = zeros(11,11);
- obraz(1,1) = 1;
- obraz(2,2) = 1;
- obraz(3,2) = 1;
- obraz(3,6) =1;
- [H,theta,rho] = hough(obraz,'Theta',0.1,'RhoResolution',0.5)
- figure(1)
- subplot(1,2,1)
- imshow(H,[]);
- subplot(1,2,2)
- imshow(obraz,[]);
- %2
- close all;
- clear all;
- img = imread('kwadraty.tif');
- img_sobel = imgradient(img);
- [H,theta,rho] = hough(img_sobel)
- P = houghpeaks(H,8);
- figure(1)
- subplot(1,3,1)
- imshow(img);
- subplot(1,3,2)
- imshow(img_sobel,[]);
- subplot(1,3,3)
- imshow(H,[]);
- lines = houghlines(img_sobel,theta,rho,P,'FillGap',5,'MinLength',7);
- figure, imshow(img), 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
- %3
- close all;
- clear all;
- imgLab = imread('lab112.bmp');
- imgLab = im2bw(imgLab, 0.2);
- imgLab = imdilate(imgLab, ones(3,10));
- imgGra = imgradient(imgLab)
- [H,theta,rho] = hough(imgGra)
- P = houghpeaks(H,8);
- figure(1)
- subplot(1,3,1)
- imshow(imgLab);
- subplot(1,3,2)
- imshow(imgGra,[]);
- subplot(1,3,3)
- imshow(H,[]);
- lines = houghlines(imgLab,theta,rho,P,'FillGap',5,'MinLength',7);
- figure, imshow(imgLab), 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
- %4
- close all;
- clear all;
- obraz = zeros(11, 11);
- obraz(1,1) = 1;
- obraz(2,2) = 1;
- obraz(3,2) = 1;
- obraz(3,6) = 1;
- H = houghAB(obraz);
- figure(1);
- subplot(2,1,1);
- imshow(obraz);
- subplot(2,1,2);
- imshow(H, []);
Advertisement
Add Comment
Please, Sign In to add comment