Implementing LBG algorithm

Hi, I’m new to Julia and wondering how to loop through the generated voronoi cells to implement the MLBG algorithm.

using GLMakie
using DelaunayTriangulation
using Interpolations
using Plots

function perform_computations(axis, time_range, mean_data, std_data, mean_color, fig)
    # band!(time_range, mean_data - std_data, mean_data + std_data, color=GLMakie.RGBA(mean_color, 0.6), label="Error")

    lines!(axis, time_range, mean_data, color=GLMakie.RGBA(mean_color, 1.0), label="Mean")
    # xlims!(axis, [0, 50])
    time_range_dense = range(1, stop=length(time_range), length=length(time_range) * 20)

    itp_mean = interpolate((time_range,), mean_data, Gridded(Linear()))

    itp_lower = interpolate((time_range,), mean_data - std_data, Gridded(Linear()))
    itp_upper = interpolate((time_range,), mean_data + std_data, Gridded(Linear()))

    plot_ys_mean = [itp_mean(t) for t in time_range_dense]
    plot_ys_lower = [itp_lower(t) for t in time_range_dense]
    plot_ys_upper = [itp_upper(t) for t in time_range_dense]
    ax = Axis(fig[1, 2])

    GLMakie.scatter!(axis, time_range_dense, plot_ys_mean, color=:blue, label="Interpolation", markersize=3)

    error_ranges = plot_ys_upper .- plot_ys_lower

    tri = DelaunayTriangulation.triangulate(points; rng)

    vorn = voronoi(tri)



I need to loop through each of voronoi cells check if the density is lesser and update

stippleList ← initialize stipple list repeat
vd ← computeVoronoiDiagram(stippleList) newStippleList ← empty list
for all Voronoi cell vc ∈ vd do
density ← vc.sumDensity if density < Tl then
// remove point
else if density < Tu then
// keep point
// split point
splitPoints ← splitCell(vc) newStippleList.add(splitPoints)
end if end for
stippleList ← newStippleList until no splitting or merging

Can anyone help me with this

What is the MLBG algorithm? It’s not clear to me what you want to do exactly. And P.S. NaturalNeighbours.jl might be a more natural choice for your interpolation (if I’m reading your code right?) since it’s directly built on top of DelaunayTriangulation.jl.

MLBG is [LindeBuzoGrayStippling Algorithm]. I’m trying to create stipples for the error bands using voronoi cells in order to avoid overlap when there are multiple time series data. Do you know How i can loop through the voronoi cells?

The documentation has examples of iterating over the Voronoi cells: Voronoi Tessellations · DelaunayTriangulation.jl. If anything there is unclear feel free to let me know and I’ll also update the documentation to address it.

1 Like

@DanielVandH thank you very much!

1 Like