4.2.2. discorpy.prep.linepattern
Module of pre-processing methods for handling a line-pattern image:
Determine the slopes and distances between lines.
Extract points belong to a line.
Convert a chessboard image to a line-pattern image.
Functions:
|
Locate the extremum point of a 1D array with subpixel accuracy. |
|
Get a list of local extremum points from a 1D array. |
|
Calculate the representative distance between horizontal lines and the representative slope of these lines using the ROI around the middle of a line-pattern image. |
|
Calculate the representative distance between vertical lines and the representative slope of these lines using the ROI around the middle of a line-pattern image. |
|
Get the intensity-profile along a tilted line across an image. |
|
Get points on horizontal lines of a line-pattern image by intersecting with a list of generated vertical-lines. |
|
Get points on vertical lines of a line-pattern image by intersecting with a list of generated horizontal-lines. |
|
Convert a chessboard image to a line-pattern image. |
- discorpy.prep.linepattern.locate_subpixel_point(list_point, option='min')[source]
Locate the extremum point of a 1D array with subpixel accuracy.
- Parameters:
list_point (array_like) – 1D array.
option ({“min”, “max”}) – To locate the minimum point or the maximum point.
- Returns:
float – Subpixel position of the extremum point.
- discorpy.prep.linepattern.get_local_extrema_points(list_data, option='min', radius=7, sensitive=0.1, denoise=True, norm=True, subpixel=True)[source]
Get a list of local extremum points from a 1D array.
- Parameters:
list_data (array_like) – 1D array.
option ({“min”, “max”}) – To get minimum points or maximum points
radius (int) – Search radius. Used to locate extremum points.
sensitive (float) – To detect extremum points against random noise. Smaller is more sensitive.
denoise (bool, optional) – Applying a smoothing filter if True.
norm (bool, optional) – Apply background normalization to the array.
subpixel (bool, optional) – Locate points with subpixel accuracy.
- Returns:
array_like – 1D array. Positions of local extremum points.
- discorpy.prep.linepattern.calc_slope_distance_hor_lines(mat, ratio=0.3, search_range=30.0, radius=9, sensitive=0.1, bgr='bright', denoise=True, norm=True, subpixel=True)[source]
Calculate the representative distance between horizontal lines and the representative slope of these lines using the ROI around the middle of a line-pattern image.
- Parameters:
mat (array_like) – 2D array.
ratio (float) – Used to select the ROI around the middle of an image.
search_range (float) – Search range in Degree to determine the slope of lines.
radius (int) – Search radius. Used to locate lines.
sensitive (float) – To detect lines against random noise. Smaller is more sensitive.
bgr ({“bright”, “dark”}) – Specify the brightness of the background against the lines.
denoise (bool, optional) – Applying a smoothing filter if True.
norm (bool, optional) – Apply background normalization to the array.
subpixel (bool, optional) – Locate points with subpixel accuracy.
- Returns:
slope (float) – Slope of horizontal lines in Radian.
distance (float) – Distance between horizontal lines.
- discorpy.prep.linepattern.calc_slope_distance_ver_lines(mat, ratio=0.3, search_range=30.0, radius=9, sensitive=0.1, bgr='bright', denoise=True, norm=True, subpixel=True)[source]
Calculate the representative distance between vertical lines and the representative slope of these lines using the ROI around the middle of a line-pattern image.
- Parameters:
mat (array_like) – 2D array.
ratio (float) – Used to select the ROI around the middle of an image.
search_range (float) – Search range in Degree to determine the slope of lines.
radius (int) – Search radius. Used to locate lines.
sensitive (float) – To detect lines against random noise. Smaller is more sensitive.
bgr ({“bright”, “dark”}) – Specify the brightness of the background against the lines.
denoise (bool, optional) – Applying a smoothing filter if True.
subpixel (bool, optional) – Locate points with subpixel accuracy.
- Returns:
slope (float) – Slope of vertical lines in Radian.
distance (float) – Distance between vertical lines.
- discorpy.prep.linepattern.get_tilted_profile(mat, index, angle_deg, direction)[source]
Get the intensity-profile along a tilted line across an image. Positive angle is counterclockwise.
- Parameters:
mat (array_like) – 2D array.
index (int) – Index of the line.
angle_deg (float) – Tilted angle in Degree.
direction ({“horizontal”, “vertical”}) – Direction of line-profile.
- Returns:
xlist (array_like) – 1D array. x-positions of points on the line.
ylist (array_like) – 1D array. y-positions of points on the line.
profile (array_like) – 1D array. Intensities of points on the line.
- discorpy.prep.linepattern.get_cross_points_hor_lines(mat, slope_ver, dist_ver, ratio=1.0, norm=True, offset=0, bgr='bright', radius=7, sensitive=0.1, denoise=True, subpixel=True)[source]
Get points on horizontal lines of a line-pattern image by intersecting with a list of generated vertical-lines.
- Parameters:
mat (array_like) – 2D array.
slope_ver (float) – Slope in Radian of generated vertical lines.
dist_ver (float) – Distance between two adjacent generated lines.
ratio (float) – To adjust the distance between generated lines to get more/less lines.
norm (bool, optional) – Apply background normalization to the array.
offset (int) – Starting index of generated lines.
bgr ({“bright”, “dark”}) – Specify the brightness of the background against the lines.
radius (int) – Search radius. Used to locate extremum points.
sensitive (float) – To detect extremum points against random noise. Smaller is more sensitive.
denoise (bool, optional) – Applying a smoothing filter if True.
subpixel (bool, optional) – Locate points with subpixel accuracy.
- Returns:
array_like – List of (y,x)-coordinates of points.
- discorpy.prep.linepattern.get_cross_points_ver_lines(mat, slope_hor, dist_hor, ratio=1.0, norm=True, offset=0, bgr='bright', radius=7, sensitive=0.1, denoise=True, subpixel=True)[source]
Get points on vertical lines of a line-pattern image by intersecting with a list of generated horizontal-lines.
- Parameters:
mat (array_like) – 2D array.
slope_hor (float) – Slope in Radian of generated horizontal lines.
dist_hor (float) – Distance between two adjacent generated lines.
ratio (float) – To adjust the distance between generated lines to get more/less lines.
norm (bool, optional) – Apply background normalization to the array.
offset (int) – Starting index of generated lines.
bgr ({“bright”, “dark”}) – Specify the brightness of the background against the lines.
radius (int) – Search radius. Used to locate extremum points.
sensitive (float) – To detect extremum points against random noise. Smaller is more sensitive.
denoise (bool, optional) – Applying a smoothing filter if True.
subpixel (bool, optional) – Locate points with subpixel accuracy.
- Returns:
array_like – List of (y,x)-coordinates of points.
- discorpy.prep.linepattern.convert_chessboard_to_linepattern(mat, smooth=False, bgr='bright')[source]
Convert a chessboard image to a line-pattern image.
- Parameters:
mat (array_like) – 2D array.
smooth (bool, optional) – Apply a gaussian smoothing filter if True.
bgr ({‘bright’, ‘dark’}) – Select the background of the output image.
- Returns:
array_like – Line-pattern image.