<< holder Post-Processing or Help to the Interpretation margtfr >>

stftb >> stftb > Post-Processing or Help to the Interpretation > htl

htl

Hough transform for detection of lines in images

Calling Sequence

[HT,RHO,THETA] = htl(IM)
[HT,RHO,THETA] = htl(IM, M,)
[HT,RHO,THETA] = htl(IM, M, N)
[HT,RHO,THETA] = htl(IM, M, N, TRACE)
[HT,RHO,THETA] = htl(...,'plot')

Parameters

IM :

A real Xmax by Ymax matrix: the image to be analyzed.

M :

A positive integer value: the desired number of samples along the radial axis (default : Xmax).

N :

A positive integer value: the desired number of samples along the azimutal (angle) axis (default : Ymax).

TRACE :

A boolean (or a real scalar) if true (or nonzero),the progression of the algorithm is shown (default : %f).

HT :

A real M by N matrix: the Hough transform result.

'plot':

when called with the additional string 'plot', htl displays HT using mesh.

RHO :

A real row vector of size M: the radial coordinates.

THETA :

A real row vector of size N: the azimutal angles (in radians).

Description

From an image IM, computes the integration of the values of the image over all the lines. The lines are parametrized using polar coordinates.

The origin of the coordinates is fixed at the center of the image (in pixel coordinates), THETA is the azimutal angle and RHO is the distance to the origin of the coordinates.

Only the values of IM exceeding 5% of the maximum are taken into account (to speed up the algorithm).

Examples

N = 128; t = (1:N); y = fmlin(N,0.15,0.45);
[IM,T,F] = tfrwv(y,t,N);
//Draw the image
clf; gcf().color_map = jetcolormap(128);
//Draw the image
subplot(211); grayplot(1:N,1:N,IM'),ax=gca();
xlabel(_("Time (pixels)"))
ylabel(_("Frequency (pixels)"))

//Draw the Hough transform result
[HT,RHO,THETA] = htl(IM,64);
subplot(212); grayplot(RHO,THETA,HT),
xlabel(_("Radial coordinate"));
ylabel(_("Polar angle"))
xtitle(_("Hough transform"))

//Locate the Highest HT value
[m,ind] = max(HT);
theta = THETA(ind(2));rho=RHO(ind(1));
xpoly(rho,theta,"marks");

// Draw the line
set(gce(),"mark_style",2,"mark_size",2,"mark_foreground",color("red"));
//Take care rho and theta correspond to an image coordinates in pixels
xl = N/2-rho*sin(theta)+60*cos(theta)*[-1 1];
yl = N/2+rho*cos(theta)+60*sin(theta)*[-1 1];
sca(ax); xpoly(xl,yl);
set(gce(),"foreground",color("red"),"thickness",3);
legend("Detected line");

See Also

Authors


Report an issue
<< holder Post-Processing or Help to the Interpretation margtfr >>