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
| function Encadrer_Callback(hObject, eventdata, handles)
I1= imcrop(handles.Image,[215.5 76.5 1146 529]);
cla;
imshow(I1,'Parent', handles.axes2);
hold on;
function Calculer_Callback(hObject, eventdata, handles)
I = rgb2gray(I1);
hedge = vision.EdgeDetector;
hhoughtrans = vision.HoughTransform(pi/360,'ThetaRhoOutputPort', true);
hfindmax = vision.LocalMaximaFinder(1,'HoughMatrixInput', true);
hhoughlines = vision.HoughLines('SineComputation','Trigonometric function');
BW = step(hedge,I);
[ht, theta, rho] = step(hhoughtrans, BW);
idx = step(hfindmax, ht);
linepts = step(hhoughlines, theta(idx(1)), rho(idx(2)), I);
imshow(I);
hold on;
line(linepts([1 3]), linepts([2 4]),'LineWidth',4,'color',[0 1 1]); |
Partager