Skip to content

recursive restrict as pyramid #29

Description

@johnnychen94

A second thought on JuliaImages/Images.jl#971 (comment)

gaussian_pyramid -> maybe ImageFiltering with new name build_pyramid and supports generic kernels. (EDIT @timholy: I don't think we can, gaussian_pyramid requires imresize from ImageTransformations. This might be a good candidate for remaining in Images.jl.)

It might be useful to define a more generic version of build_pyramid here with function f input.

# apply `f(restrict(img, dims))` recursively for `n_scales` times
build_pyramid(f=identity, img; dims::Dims, n_scales::Int)
# apply `f(restrict(img, dims))` recursively until `all(size(smallest_img) .< stop_size)` holds
build_pyramid(f=identity, img; stop_size)

When f(x) = imfilter(img, KernelFactors.IIRGaussian(sigma), NA()) then it becomes a gaussian pyramid.

The benefit is that we get a more generic version, and since we don't rely on either imresize or imfilter, we can keep this function in ImageBase.


FWIW, building pyramid also falls into the reduce diagram: build_pyramid(f, x::AbstractArray, n) = reduce((x,y)->push!(x, f(restrict(last(x)))), 1:n; init=[x])

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions