fit_line_contour_xld fit_line_contour_xld FitLineContourXld FitLineContourXld fit_line_contour_xld (算子)
名称
fit_line_contour_xld fit_line_contour_xld FitLineContourXld FitLineContourXld fit_line_contour_xld — 按线段近似计算 XLD 轮廓。
签名
fit_line_contour_xld (Contours : : Algorithm , MaxNumPoints , ClippingEndPoints , Iterations , ClippingFactor : RowBegin , ColBegin , RowEnd , ColEnd , Nr , Nc , Dist )
Herror fit_line_contour_xld (const Hobject Contours , const char* Algorithm , const Hlong MaxNumPoints , const Hlong ClippingEndPoints , const Hlong Iterations , double ClippingFactor , double* RowBegin , double* ColBegin , double* RowEnd , double* ColEnd , double* Nr , double* Nc , double* Dist )
Herror T_fit_line_contour_xld (const Hobject Contours , const Htuple Algorithm , const Htuple MaxNumPoints , const Htuple ClippingEndPoints , const Htuple Iterations , const Htuple ClippingFactor , Htuple* RowBegin , Htuple* ColBegin , Htuple* RowEnd , Htuple* ColEnd , Htuple* Nr , Htuple* Nc , Htuple* Dist )
void FitLineContourXld (const HObject& Contours , const HTuple& Algorithm , const HTuple& MaxNumPoints , const HTuple& ClippingEndPoints , const HTuple& Iterations , const HTuple& ClippingFactor , HTuple* RowBegin , HTuple* ColBegin , HTuple* RowEnd , HTuple* ColEnd , HTuple* Nr , HTuple* Nc , HTuple* Dist )
void HXLDCont ::FitLineContourXld (const HString& Algorithm , Hlong MaxNumPoints , Hlong ClippingEndPoints , Hlong Iterations , double ClippingFactor , HTuple* RowBegin , HTuple* ColBegin , HTuple* RowEnd , HTuple* ColEnd , HTuple* Nr , HTuple* Nc , HTuple* Dist ) const
void HXLDCont ::FitLineContourXld (const HString& Algorithm , Hlong MaxNumPoints , Hlong ClippingEndPoints , Hlong Iterations , double ClippingFactor , double* RowBegin , double* ColBegin , double* RowEnd , double* ColEnd , double* Nr , double* Nc , double* Dist ) const
void HXLDCont ::FitLineContourXld (const char* Algorithm , Hlong MaxNumPoints , Hlong ClippingEndPoints , Hlong Iterations , double ClippingFactor , double* RowBegin , double* ColBegin , double* RowEnd , double* ColEnd , double* Nr , double* Nc , double* Dist ) const
void HXLDCont ::FitLineContourXld (const wchar_t* Algorithm , Hlong MaxNumPoints , Hlong ClippingEndPoints , Hlong Iterations , double ClippingFactor , double* RowBegin , double* ColBegin , double* RowEnd , double* ColEnd , double* Nr , double* Nc , double* Dist ) const
(
Windows only)
static void HOperatorSet .FitLineContourXld (HObject contours , HTuple algorithm , HTuple maxNumPoints , HTuple clippingEndPoints , HTuple iterations , HTuple clippingFactor , out HTuple rowBegin , out HTuple colBegin , out HTuple rowEnd , out HTuple colEnd , out HTuple nr , out HTuple nc , out HTuple dist )
void HXLDCont .FitLineContourXld (string algorithm , int maxNumPoints , int clippingEndPoints , int iterations , double clippingFactor , out HTuple rowBegin , out HTuple colBegin , out HTuple rowEnd , out HTuple colEnd , out HTuple nr , out HTuple nc , out HTuple dist )
void HXLDCont .FitLineContourXld (string algorithm , int maxNumPoints , int clippingEndPoints , int iterations , double clippingFactor , out double rowBegin , out double colBegin , out double rowEnd , out double colEnd , out double nr , out double nc , out double dist )
def fit_line_contour_xld (contours : HObject, algorithm : str, max_num_points : int, clipping_end_points : int, iterations : int, clipping_factor : float) -> Tuple[Sequence[float], Sequence[float], Sequence[float], Sequence[float], Sequence[float], Sequence[float], Sequence[float]]
def fit_line_contour_xld_s (contours : HObject, algorithm : str, max_num_points : int, clipping_end_points : int, iterations : int, clipping_factor : float) -> Tuple[float, float, float, float, float, float, float]
描述
fit_line_contour_xld fit_line_contour_xld FitLineContourXld FitLineContourXld FitLineContourXld fit_line_contour_xld approximates the XLD contours
Contours Contours Contours Contours contours contours by line segments. It does not perform a
segmentation of the input contours. Thus, one has to make sure that
each contour corresponds to one and only one line segment. The
operator returns for each contour the start point
(RowBegin RowBegin RowBegin RowBegin rowBegin row_begin , ColBegin ColBegin ColBegin ColBegin colBegin col_begin ), the end point
(RowEnd RowEnd RowEnd RowEnd rowEnd row_end , ColEnd ColEnd ColEnd ColEnd colEnd col_end ), and the regression line to the
contour given by the normal vector (Nr Nr Nr Nr nr nr , Nc Nc Nc Nc nc nc ) of the
line and its distance Dist Dist Dist Dist dist dist from the origin, i.e., the line
equation is given by
。
The algorithm used for the fitting of lines can be selected via
Algorithm Algorithm Algorithm Algorithm algorithm algorithm :
'regression' "regression" "regression" "regression" "regression" "regression" :
Standard 'least squares' line fitting.
'huber' "huber" "huber" "huber" "huber" "huber" :
Weighted 'least squares' line fitting, where the impact of outliers
is decreased based on the approach of Huber (see below).
'tukey' "tukey" "tukey" "tukey" "tukey" "tukey" :
Weighted 'least squares' line fitting, where outliers
are ignored based on the approach of Tukey (see below).
'drop' "drop" "drop" "drop" "drop" "drop" :
'least squares' line fitting, where outliers are ignored. In
particular, all contour points further away from the contour than the mean
distance to the regression line multiplied with the ClippingFactor ClippingFactor ClippingFactor ClippingFactor clippingFactor clipping_factor
(see below) are ignored for the calculation of the undistorted regression
line.
'gauss' "gauss" "gauss" "gauss" "gauss" "gauss" :
Weighted 'least squares' line fitting, where the impact of outliers
is decreased based on the mean value and the standard deviation of
the distances of all contour points from the approximating line.
For 'huber' "huber" "huber" "huber" "huber" "huber" , 'tukey' "tukey" "tukey" "tukey" "tukey" "tukey" , and 'drop' "drop" "drop" "drop" "drop" "drop"
a robust error statistics is used to
estimate the standard deviation of the distances from the contour points
without outliers from the approximating line. The parameter
ClippingFactor ClippingFactor ClippingFactor ClippingFactor clippingFactor clipping_factor (a scaling factor for the standard deviation)
controls the amount of outliers: The smaller the value chosen for
ClippingFactor ClippingFactor ClippingFactor ClippingFactor clippingFactor clipping_factor the more outliers are detected. The detection of
outliers is repeated. The parameter Iterations Iterations Iterations Iterations iterations iterations specifies the number
of iterations.
In the mode 'regression' "regression" "regression" "regression" "regression" "regression" this value is ignored.
Note that in the approach of Tukey ('tukey' "tukey" "tukey" "tukey" "tukey" "tukey" ), the outliers are
removed before performing the approximation and all other points are weighted,
whereas in the approach of Huber ('huber' "huber" "huber" "huber" "huber" "huber" ), the outliers still have
a small influence. Particularly,
for outliers the optimization is influenced linearly and for points with a
smaller distance it is influenced to the square.
In practice, the approach of Tukey is recommended.
To reduce the computational load, the fitting of lines can be
restricted to a subset of the contour points: If a value other than
-1 is assigned to MaxNumPoints MaxNumPoints MaxNumPoints MaxNumPoints maxNumPoints max_num_points , only up to
MaxNumPoints MaxNumPoints MaxNumPoints MaxNumPoints maxNumPoints max_num_points points - uniformly distributed over the
contour - are used.
The start point and the end point of a line segment is determined by
projecting the first and the last point of the corresponding contour
to the approximating line. Due to artifacts in the pre-processing
the start and end points of a contour might be faulty. Therefore, it
is possible to exclude ClippingEndPoints ClippingEndPoints ClippingEndPoints ClippingEndPoints clippingEndPoints clipping_end_points points at the beginning
and at the end of a contour from the line fitting. However, they are
still used for the determination of the start point and the end
point of the line segment.
The minimum necessary number of contour points for fitting a line is two.
Therefore, it is required that the number of contour points is at least
。
执行信息
多线程类型:可重入(与非独占算子并行运行)。
多线程作用域:全局(可从任何线程调用)。
未采用并行化处理。
参数
Contours Contours Contours Contours contours contours (输入对象) xld_cont(-array) → object HXLDCont HObject HXLDCont Hobject
Input contours.
Algorithm Algorithm Algorithm Algorithm algorithm algorithm (输入控制) string → HTuple str HTuple Htuple (string) (string ) (HString ) (char* )
Algorithm for the fitting of lines.
默认值:
'tukey'
"tukey"
"tukey"
"tukey"
"tukey"
"tukey"
值列表:
'drop' "drop" "drop" "drop" "drop" "drop" , 'gauss' "gauss" "gauss" "gauss" "gauss" "gauss" , 'huber' "huber" "huber" "huber" "huber" "huber" , 'regression' "regression" "regression" "regression" "regression" "regression" , 'tukey' "tukey" "tukey" "tukey" "tukey" "tukey"
MaxNumPoints MaxNumPoints MaxNumPoints MaxNumPoints maxNumPoints max_num_points (输入控制) integer → HTuple int HTuple Htuple (integer) (int / long) (Hlong ) (Hlong )
Maximum number of contour points used for the computation
(-1 for all points).
默认值:
-1
限制:
MaxNumPoints >= 2
ClippingEndPoints ClippingEndPoints ClippingEndPoints ClippingEndPoints clippingEndPoints clipping_end_points (输入控制) integer → HTuple int HTuple Htuple (integer) (int / long) (Hlong ) (Hlong )
Number of points at the beginning and at the end of the
contours to be ignored for the fitting.
默认值:
0
限制:
ClippingEndPoints >= 0
Iterations Iterations Iterations Iterations iterations iterations (输入控制) integer → HTuple int HTuple Htuple (integer) (int / long) (Hlong ) (Hlong )
Maximum number of iterations
(unused for 'regression' "regression" "regression" "regression" "regression" "regression" ).
默认值:
5
限制:
Iterations >= 0
ClippingFactor ClippingFactor ClippingFactor ClippingFactor clippingFactor clipping_factor (输入控制) real → HTuple float HTuple Htuple (real) (double ) (double ) (double )
Clipping factor for the elimination of outliers
(typical values: 1.0 for 'huber' "huber" "huber" "huber" "huber" "huber" and
'drop' "drop" "drop" "drop" "drop" "drop" and 2.0 for 'tukey' "tukey" "tukey" "tukey" "tukey" "tukey" ).
默认值:
2.0
建议值:
1.0, 1.5, 2.0, 2.5, 3.0
限制:
ClippingFactor > 0
RowBegin RowBegin RowBegin RowBegin rowBegin row_begin (输出控制) line.begin.y(-array) → HTuple Sequence[float] HTuple Htuple (real) (double ) (double ) (double )
Row coordinates of the starting points of the line
segments.
ColBegin ColBegin ColBegin ColBegin colBegin col_begin (输出控制) line.begin.x(-array) → HTuple Sequence[float] HTuple Htuple (real) (double ) (double ) (double )
Column coordinates of the starting points of the line
segments.
RowEnd RowEnd RowEnd RowEnd rowEnd row_end (输出控制) line.end.y(-array) → HTuple Sequence[float] HTuple Htuple (real) (double ) (double ) (double )
Row coordinates of the end points of the line
segments.
ColEnd ColEnd ColEnd ColEnd colEnd col_end (输出控制) line.end.x(-array) → HTuple Sequence[float] HTuple Htuple (real) (double ) (double ) (double )
Column coordinates of the end points of the line
segments.
Nr Nr Nr Nr nr nr (输出控制) number(-array) → HTuple Sequence[float] HTuple Htuple (real) (double ) (double ) (double )
Line parameter: Row coordinate of the normal vector
Nc Nc Nc Nc nc nc (输出控制) number(-array) → HTuple Sequence[float] HTuple Htuple (real) (double ) (double ) (double )
Line parameter: Column coordinate of the normal vector
Dist Dist Dist Dist dist dist (输出控制) number(-array) → HTuple Sequence[float] HTuple Htuple (real) (double ) (double ) (double )
Line parameter: Distance of the line from the origin
示例(HDevelop)
read_image (Image, 'mreut')
edges_sub_pix (Image, Edges, 'lanser2', 0.5, 20, 40)
gen_polygons_xld (Edges, Polygons, 'ramer', 2)
split_contours_xld (Polygons, Contours, 'polygon', 1, 5)
fit_line_contour_xld (Contours, 'regression', -1, 0, 5, 2, RowBegin, \
ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
示例(HDevelop)
read_image (Image, 'mreut')
edges_sub_pix (Image, Edges, 'lanser2', 0.5, 20, 40)
gen_polygons_xld (Edges, Polygons, 'ramer', 2)
split_contours_xld (Polygons, Contours, 'polygon', 1, 5)
fit_line_contour_xld (Contours, 'regression', -1, 0, 5, 2, RowBegin, \
ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
示例(HDevelop)
read_image (Image, 'mreut')
edges_sub_pix (Image, Edges, 'lanser2', 0.5, 20, 40)
gen_polygons_xld (Edges, Polygons, 'ramer', 2)
split_contours_xld (Polygons, Contours, 'polygon', 1, 5)
fit_line_contour_xld (Contours, 'regression', -1, 0, 5, 2, RowBegin, \
ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
示例(HDevelop)
read_image (Image, 'mreut')
edges_sub_pix (Image, Edges, 'lanser2', 0.5, 20, 40)
gen_polygons_xld (Edges, Polygons, 'ramer', 2)
split_contours_xld (Polygons, Contours, 'polygon', 1, 5)
fit_line_contour_xld (Contours, 'regression', -1, 0, 5, 2, RowBegin, \
ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
示例(HDevelop)
read_image (Image, 'mreut')
edges_sub_pix (Image, Edges, 'lanser2', 0.5, 20, 40)
gen_polygons_xld (Edges, Polygons, 'ramer', 2)
split_contours_xld (Polygons, Contours, 'polygon', 1, 5)
fit_line_contour_xld (Contours, 'regression', -1, 0, 5, 2, RowBegin, \
ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
结果
fit_line_contour_xld fit_line_contour_xld FitLineContourXld FitLineContourXld FitLineContourXld fit_line_contour_xld returns 2 (
H_MSG_TRUE )
if all parameter values
are correct, and line segments could be fitted to the input contours.
如果输入为空则可设置行为通过 set_system('no_object_result',<Result>) set_system("no_object_result",<Result>) SetSystem("no_object_result",<Result>) SetSystem("no_object_result",<Result>) SetSystem("no_object_result",<Result>) set_system("no_object_result",<Result>) 。如有必要,则抛出异常。
If the parameter ClippingFactor ClippingFactor ClippingFactor ClippingFactor clippingFactor clipping_factor is chosen too small, i.e.,
all points are classified as outliers, the error 3264 is raised.
可能的前趋
gen_contours_skeleton_xld gen_contours_skeleton_xld GenContoursSkeletonXld GenContoursSkeletonXld GenContoursSkeletonXld gen_contours_skeleton_xld ,
lines_gauss lines_gauss LinesGauss LinesGauss LinesGauss lines_gauss ,
lines_facet lines_facet LinesFacet LinesFacet LinesFacet lines_facet ,
edges_sub_pix edges_sub_pix EdgesSubPix EdgesSubPix EdgesSubPix edges_sub_pix ,
smooth_contours_xld smooth_contours_xld SmoothContoursXld SmoothContoursXld SmoothContoursXld smooth_contours_xld
可能的后继
disp_line disp_line DispLine DispLine DispLine disp_line ,
line_orientation line_orientation LineOrientation LineOrientation LineOrientation line_orientation
另见
regress_contours_xld regress_contours_xld RegressContoursXld RegressContoursXld RegressContoursXld regress_contours_xld ,
get_regress_params_xld get_regress_params_xld GetRegressParamsXld GetRegressParamsXld GetRegressParamsXld get_regress_params_xld
模块
基础