HoughLine Struct

A straight line found by ImageProcessingExtensions.DetectLines, in normal form: the points (x, y) with x cos θ + y sin θ = ρ.

public readonly struct HoughLine : IEquatable<HoughLine>

Remarks

The coordinates are those of the stored pixels, where the frame covers [0, width] x [0, height] and the center of pixel (i, j) is (i + 1/2, j + 1/2); y grows downward. An angle of 0 is a vertical line (x = ρ), an angle of 90 a horizontal one (y = ρ).

Implements

Constructors

NameDescription
HoughLine(double, double, int)Initializes a new instance of the HoughLine struct.

HoughLine(double, double, int)

HoughLine.cs

Initializes a new instance of the HoughLine struct.

public HoughLine(double angle, double distance, int votes)

Parameters

angle double
The angle θ of the normal of the line, in degrees.
distance double
The signed distance ρ of the line to the origin, in pixels.
votes int
The number of edge pixels on the line.

Properties

NameDescription
AngleGets the angle θ of the normal of the line, in degrees, from 0 (included) to 180 (excluded), clockwise from the x axis since y grows downward.
DistanceGets the signed distance ρ of the line to the origin (the top-left corner of the frame), in pixels.
SlopeGets the angle of the direction of the line, in degrees, from -90 (excluded) to 90 (included): 0 for a horizontal line, positive when it goes down to the right (clockwise, since y grows downward).
VotesGets the number of edge pixels that voted for the line: the length of the visible part of the line, roughly.

Gets the angle θ of the normal of the line, in degrees, from 0 (included) to 180 (excluded), clockwise from the x axis since y grows downward.

public double Angle { get; }

Property value

double

Distance

HoughLine.cs

Gets the signed distance ρ of the line to the origin (the top-left corner of the frame), in pixels.

public double Distance { get; }

Property value

double

Gets the angle of the direction of the line, in degrees, from -90 (excluded) to 90 (included): 0 for a horizontal line, positive when it goes down to the right (clockwise, since y grows downward).

public double Slope { get; }

Property value

double

Gets the number of edge pixels that voted for the line: the length of the visible part of the line, roughly.

public int Votes { get; }

Property value

int

Methods

NameDescription
Equals(HoughLine)Indicates whether the current object is equal to another object of the same type.
Equals(object?)Indicates whether this instance and a specified object are equal.
GetHashCode()Returns the hash code for this instance.
ToString()Returns the line formatted as θ={Angle} ρ={Distance} ({Votes} votes).

Equals overloads

Equals(HoughLine)

HoughLine.cs

Indicates whether the current object is equal to another object of the same type.

public bool Equals(HoughLine other)
Parameters
other HoughLine
An object to compare with this object.
Returns

bool true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

HoughLine.cs

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)
Parameters
obj object?
The object to compare with the current instance.
Returns

bool true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

HoughLine.cs

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int A 32-bit signed integer that is the hash code for this instance.

ToString()

HoughLine.cs

Returns the line formatted as θ={Angle} ρ={Distance} ({Votes} votes).

public override string ToString()

Returns

string A string representation of the line.

Operators

NameDescription
operator ==(HoughLine, HoughLine)Compares two lines for equality.
operator !=(HoughLine, HoughLine)Compares two lines for inequality.

operator ==(HoughLine, HoughLine)

HoughLine.cs

Compares two lines for equality.

public static bool operator ==(HoughLine left, HoughLine right)

Parameters

left HoughLine
The first line.
right HoughLine
The second line.

Returns

bool true if both lines are equal; otherwise false.

operator !=(HoughLine, HoughLine)

HoughLine.cs

Compares two lines for inequality.

public static bool operator !=(HoughLine left, HoughLine right)

Parameters

left HoughLine
The first line.
right HoughLine
The second line.

Returns

bool true if the lines differ; otherwise false.