LogHeightmaps
Documentation for LogHeightmaps.
LogHeightmaps.ExtremaSegmentsLogHeightmaps.SmoothingSpline3DLogHeightmaps.SmoothingSpline3DLogHeightmaps.calculate_heightmapLogHeightmaps.calculate_heightmap!LogHeightmaps.filter_point_cloudLogHeightmaps.from_heightmap_coordinatesLogHeightmaps.from_heightmap_coordinates!LogHeightmaps.from_logcentric_coordinatesLogHeightmaps.from_logcentric_coordinates!LogHeightmaps.get_lengthLogHeightmaps.predict_pointsLogHeightmaps.rescale_calculate_heightmapLogHeightmaps.rescale_calculate_heightmap!LogHeightmaps.rescale_pointsLogHeightmaps.rescale_points!LogHeightmaps.rescale_points_backLogHeightmaps.rescale_points_back!LogHeightmaps.segment_branchesLogHeightmaps.to_heightmap_coordinatesLogHeightmaps.to_heightmap_coordinates!LogHeightmaps.to_logcentric_coordinatesLogHeightmaps.to_logcentric_coordinates!
LogHeightmaps.ExtremaSegments — Typestruct ExtremaSegments{T}A class to specify that the spline should be divided into segments between the extrema points of the original spline. min_x_step specifies the minimum difference between control points.
min_x_step
LogHeightmaps.SmoothingSpline3D — Typestruct SmoothingSpline3D{T}A class for the 3D smoothing spline, i.e. a class that holds two splines: X ↦ Y and X ↦ Z. Uses splines from SmoothingSplines.jl.
splineXYsplineXZcoeffsXYcoeffsXZcumlengths
LogHeightmaps.SmoothingSpline3D — MethodSmoothingSpline3D(X, Y, Z; n_segments=ExtremaSegments(5), λ=250.0)Function that creates a SmoothingSpline3D from given points.
Keywords
n_segments=ExtremaSegments(5): specifies how to divide the resulting spline into segments. Can be one of 3 possible values: ifn_segments::Nothingthen originalXvalues will be used to divide the spline into segments. ifn_segments::ExtremaSegmentsthen the segments will be chosen according to the extremas of the spline. ifn_segments::Integerthenrange(minimum(X), maximum(X), n_segments+1)will be used as control points.λ=250.0: the smoothing parameter. Please refer to SmoothingSplines.jl package for more information.
LogHeightmaps.calculate_heightmap! — Methodcalculate_heightmap!(heightmap, rescaled_points, α, width, height, real_length; use_cuda=true)In-place version of the calculate_heightmap function. Calculate heightmap from the points in log-centric coordinate system. rescaled_points must be a 3×n AbstractMatrix, where the rows correspond to l, θ, ρ values respectively, α is a smoothing parameter. It is assumed that l is already rescaled to the [1, height] range, and θ is rescaled to [1, width]. real_length is the difference between minimum and maximum l values before rescaling.
Refer to [1], [2] for more details.
Keywords
use_cuda=cuda_is_functional(): it is possible to use CUDA to speed up the computation.
LogHeightmaps.calculate_heightmap — Methodcalculate_heightmap(rescaled_points, α, width, height, real_length; use_cuda=true)Calculate heightmap from the points in log-centric coordinate system. rescaled_points must be a 3×n AbstractMatrix, where the rows correspond to l, θ, ρ values respectively, α is a smoothing parameter. It is assumed that l is already rescaled to the [1, height] range, and θ is rescaled to [1, width]. real_length is the difference between minimum and maximum l values before rescaling.
Refer to [1], [2] for more details.
Keywords
use_cuda=cuda_is_functional(): it is possible to use CUDA to speed up the computation.
LogHeightmaps.filter_point_cloud — Methodfilter_point_cloud(data; kws...)Filter $d × n$ matrix of log point cloud points from noise, where $n$ is the number of points and $d$ is the dimensionality. If $d=3$, assumes that the points are in cartesian coordinates. If $d ≥ 4$, assumes that the first axis corresponds to a number of layer (for a line scanners) and the next 3 are coordinates. It is assumed that the log is oriented along the $z$ axis.
Returns a tuple of (points_filter, circles), where points_filter is a bitarray specifying which points are left after the filtering, and circles is a 4 × m array containing layer number (cross-section index), center x, center y and radius values, and m is the number of layers (cross-sections).
Keywords
snake_size=180: number of points to use for active contoursnake_kwparams=(α=0.01, β=0.5, γ=10, σ=20, dist_α=1): keyword parameters for the active contour algorithm defined as a NamedTuplemin_radius=75: minimum radius of a log cross-sectionmax_radius=200: maximum radius of a log cross-sectionmax_resiudal=4: maximum residual errorpoints_threshold=300: minimum number of points per cross-sectionfiltered_threshold=200: minimum number of points to remain after filtering per cross-section.max_distance=10: maximum distance from snake.max_rad_diff=20: maximum difference in estimated radii.snake_coverage=0.8: the required proportion of active contour points that are near the final points.snake_iterations=10: iterations for the active contour estimation.max_skipped_layers=5: if more layers are skipped, it is assumed that the end of the log has been reached.debug_plots=false: specifies whether to plot each layer with filtering information. RequiresGLMakiepackage to be installed.
LogHeightmaps.from_heightmap_coordinates — Functionfrom_heightmap_coordinates!(points, centerline, width, height, minX=nothing, maxX=nothing)Convert $3 × n$ matrix of 3D cartesian points to the heightmap coordinates (logcentric coordinates scaled to the size of the heightmap). Applies rescale_points_back and from_logcentric_coordinates.
LogHeightmaps.from_heightmap_coordinates! — Functionfrom_heightmap_coordinates!(points, centerline, width, height, minX=nothing, maxX=nothing)In-place version of the from_heightmap_coordinates function. Convert $3 × n$ matrix of 3D cartesian points to the heightmap coordinates (logcentric coordinates scaled to the size of the heightmap). Applies rescale_points_back and from_logcentric_coordinates.
LogHeightmaps.from_logcentric_coordinates! — Methodfrom_logcentric_coordinates!(points, centerline)In-place version of the from_logcentric_coordinates function. Convert 3 × n matrix of logcentric coordinates $l, θ, ρ$ to 3D cartesian points.
Refer to [1], [2] for more details. Note that this conversion differs from the published version and does not approximate centerline as line segments, but works with cubic splines directly.
LogHeightmaps.from_logcentric_coordinates — Methodfrom_logcentric_coordinates(points, centerline)Convert 3 × n matrix of logcentric coordinates $l, θ, ρ$ to 3D cartesian points.
Refer to [1], [2] for more details. Note that this conversion differs from the published version and does not approximate centerline as line segments, but works with cubic splines directly.
LogHeightmaps.get_length — Methodget_length(spl::SmoothingSpline3D, x; segment_length=false)Function that returns the length of spline spl at given x. Uses 5-point Gaussian quadratures to approximate the length.
Note: if given x is less than the first control point of spline, the returned value will be negative (because this is used for coordinate transformation).
Keywords
segment_length=false: whether to compute the length from the first control point or only the length of the segment that containsx
LogHeightmaps.predict_points — Methodpredict_points(spl::SmoothingSpline3D, x)Evaluate spline spl at points x. Returns a tuple (X, Y, Z) of evaluated coordinates. If multiple values of x were provided, returns Y and Z as vectors of corresponding sizes.
LogHeightmaps.rescale_calculate_heightmap — Functionrescale_calculate_heightmap(logcentric_points, α, width, height, min_l=nothing, max_l=nothing, real_length=nothing; use_cuda=cuda_is_functional())Calculate heightmap from the points in log-centric coordinate system. logcentric_points must be a 3×n AbstractMatrix, where the rows correspond to l, θ, ρ values respectively, α is a smoothing parameter. min_l and max_l are minimum and maximum values of l. If not provided explicitly, estimated from points. real_length is the estimated real length of long. If not provided explicitly, calculated as max_l - min_l.
Refer to [1], [2] for more details.
Keywords
use_cuda=cuda_is_functional(): it is possible to use CUDA to speed up the computation.
LogHeightmaps.rescale_calculate_heightmap! — Functionrescale_calculate_heightmap(logcentric_points, α, min_l=nothing, max_l=nothing, real_length=nothing; use_cuda=cuda_is_functional())In-place version of rescale_calculate_heightmap function. Calculate heightmap from the points in log-centric coordinate system. logcentric_points must be a 3×n AbstractMatrix, where the rows correspond to l, θ, ρ values respectively, α is a smoothing parameter. min_l and max_l are minimum and maximum values of l. If not provided explicitly, estimated from points. real_length is the estimated real length of long. If not provided explicitly, calculated as max_l - min_l.
Refer to [1], [2] for more details.
Keywords
use_cuda=cuda_is_functional(): it is possible to use CUDA to speed up the computation.
LogHeightmaps.rescale_points — Functionrescale_points!(points, width, height, min_l=nothing, max_l=nothing)Rescale log-centric points to so that $l ∈ [1, height], θ ∈ [1, width]$. points must be a 3×n AbstractMatrix, where the rows correspond to l, θ, ρ values respectively. min_l and max_l are minimum and maximum values of l. If not provided explicitly, estimated from points.
LogHeightmaps.rescale_points! — Functionrescale_points!(points, width, height, min_l=nothing, max_l=nothing)In-place version of rescale_points function. Rescale log-centric points to so that $l ∈ [1, height], θ ∈ [1, width]$. points must be a 3×n AbstractMatrix, where the rows correspond to l, θ, ρ values respectively. min_l and max_l are minimum and maximum values of l. If not provided explicitly, estimated from points.
LogHeightmaps.rescale_points_back! — Methodrescale_points_back!(points, width, height, min_l, max_l)In-place version of rescale_points_back function. Rescale log-centric points from $l ∈ [1, height], θ ∈ [1, width]$ to $l ∈ [min_l, max_l], θ ∈ [-π, π]$. points must be a 3×n AbstractMatrix, where the rows correspond to l, θ, ρ values respectively.
LogHeightmaps.rescale_points_back — Methodrescale_points_back(points, width, height, min_l, max_l)Rescale log-centric points from $l ∈ [1, height], θ ∈ [1, width]$ to $l ∈ [min_l, max_l], θ ∈ [-π, π]$. points must be a 3×n AbstractMatrix, where the rows correspond to l, θ, ρ values respectively.
LogHeightmaps.segment_branches — Methodsegment_branches(I, branch_radius, real_size)Segment branches from the heightmap image using Difference of Gaussians. branch_radius specifies approximate radius of the branch on the surface in mm. real_size is a tuple containing an estimate of the real size of the heightmap, usually calculated as (real_height, 2π * mean(heightmap)).
LogHeightmaps.to_heightmap_coordinates — Functionto_heightmap_coordinates(points, centerline, width, height, minX=nothing, maxX=nothing)Convert 3 × n matrix of 3D cartesian points to the heightmap coordinates (logcentric coordinates scaled to the size of the heightmap). Applies to_logcentric_coordinates and rescale_points.
LogHeightmaps.to_heightmap_coordinates! — Functionto_heightmap_coordinates!(points, centerline, width, height, minX=nothing, maxX=nothing)In-place version of the to_heightmap_coordinates function. Convert 3 × n matrix of 3D cartesian points to the heightmap coordinates (logcentric coordinates scaled to the size of the heightmap). Applies to_logcentric_coordinates and rescale_points.
LogHeightmaps.to_logcentric_coordinates! — Methodto_logcentric_coordinates!(points, centerline)In-place version of the to_logcentric_coordinates function. Convert 3 × n matrix of 3D cartesian points to the logcentric coordinates $l, θ, ρ$.
Refer to [1], [2] for more details. Note that this conversion differs from the published version and does not approximate centerline as line segments, but works with cubic splines directly.
LogHeightmaps.to_logcentric_coordinates — Methodto_logcentric_coordinates(points, centerline)Convert 3 × n matrix of 3D cartesian points to the logcentric coordinates $l, θ, ρ$.
Refer to [1], [2] for more details. Note that this conversion differs from the published version and does not approximate centerline as line segments, but works with cubic splines directly.
- [1]
- F. Zolotarev, T. Eerola, L. Lensu, H. Kälviäinen, T. Helin, H. Haario, T. Kauppi and J. Heikkinen. Modelling internal knot distribution using external log features. Computers and Electronics in Agriculture {179} (2020).
- [2]
- F. Zolotarev. Computer Vision for Virtual Sawing and Timber Tracing. Ph.D. Thesis, Lappeenranta-Lahti University of Technology LUT (2022).