Skip to content

idea: interpolate the fillvalue #68

Description

@johnnychen94

It would be nice to allow fill the region with multiple fillvalues:

  • a constant value
  • interpolating/extrapolate a list of values
  • calling a custom function like the etp here
using Interpolations, ImageCore, OffsetArrays, ImageShow
make_circle(r, fillvalues; kwargs...) = make_circle(eltype(fillvalues), r, fillvalues; kwargs...)
function make_circle(T, r, fillvalues::Vector)
    etp = extrapolate(interpolate(fillvalues, BSpline(Linear())), Line())
    sz = (2r+1, 2r+1)
    canvas = OffsetArrays.centered(Array{T, 2}(undef, sz))

    for i in CartesianIndices(canvas)
        d = sqrt(mapreduce(abs2, +, i.I))
        canvas[i] = etp(d)
    end
    return canvas
end

img = mosaic(
    mosaic(
        make_circle(256, collect(0:0.005:0.8)),
        make_circle(256, repeat(collect(0:0.002:0.8))),
        make_circle(256, repeat(collect(0:0.05:0.8), inner=30));
        rowmajor=true, nrow=1
    ),
    mosaic(
        make_circle(256, colormap("Blues")),
        make_circle(256, colormap("Blues", 256)),
        make_circle(256, colormap("Blues", 512));
        rowmajor=true, nrow=1
    )
)

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions