A=180; % Angle has a value of 0 to 180 degrees
D=round (SQRT (m ^ 2 + n ^ 2)); A maximum of % image diagonal length is p
S=zeros 2 * (a, d); % store each number (a, p)
Z=cell (a, 2 * d); % with cellular store the coordinates of each point were detected
For I=1: m
For j=1: n % traversal images each point
If (q (I, j)==255) % only threshold of image edge detection, the remaining points not detect
For k=1: a
P=round (I * cos (PI * k/180) + j * sin (PI * k/180)); % for each point traverse again from 1 to 180 degrees, made after all the point at which a line of p value (integer)
If (p & gt; If p is greater than 0, 0) % will point is stored in (d, 2 d) space
S (k, d + p)=s (k, d + p) + 1; % (a, p) corresponding accumulator unit plus one
Z={k, d + p} [z + p} {k, d, [I, j] '];
% save point coordinatesThe else
Ap=abs (p) + 1; % if p is less than zero, then the points stored in space (0, d)
S (k, ap)=s (k, ap) + 1; % (a, p) corresponding accumulator unit plus one
[z z {k, ap}={k, ap}, [I, j] '];
% save point coordinatesEnd
End
End
End
End
For I=1: a
For j=1: d * 2% check each accumulator unit number stored in the
If (s (I, j) & gt; 90) % will extract the linear threshold is set to 90
Lp={I, j} z;
% extract the corresponding point coordinatesFor k=1: s (I, j) % to meet the threshold condition of accumulator unit (a, p) corresponding to operate at all points
O (lp (1, k), lp (2 k), 1)=255; Each point %=255 R components, G, B component weight=0=0
O (lp (1, k), lp (2 k), 2)=0.
O (lp (1, k), lp (2 k), 3)=0. % results to meet the requirements of the threshold on the original point of line fu red
End
End
End
end
CodePudding user response:
http://jingyan.baidu.com/article/91f5db1bd040e31c7e05e34d.html