JuliaImages / JuliaImages/ImageBase.jl

Adding Gaussian Pyramid

Open
#39 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
4
Forks
2
PR merge metrics
No merged PRs in 30d

Description

After I couldn't find a gaussian pyramid implementation in Julia I quickly made a simple implementation:

struct Pyramid{T,M<:AbstractMatrix{T}} <: AbstractMatrix{T}
    data::Vector{M}
end

function Pyramid(data::AbstractMatrix; min_resolution=1024, mode=Linear())
    ranges(d) = (LinRange(1, size(data, 1), size(d, 1)), LinRange(1, size(data, 2), size(d, 2)))
    ET = ImageBase.restrict_eltype(first(data))
    resized = convert(Matrix{ET}, data)
    pyramid = [interpolate(eltype(ET), ET, ranges(resized), resized, Gridded(mode))]
    while any(x -> x > min_resolution, size(resized))
        resized = restrict(resized)
        interp = interpolate(eltype(ET), ET, ranges(resized), resized, Gridded(mode))
        push!(pyramid, interp)
    end
    Pyramid(pyramid)
end

function (p::Pyramid)(x::LinRange, y::LinRange)
    xystep = step.((x, y))
    maxsize = size(p.data[1])
    val, idx = findmin(p.data) do data 
        steps = step.(LinRange.(1, maxsize, size(data)))
        norm(xystep .- steps)
    end
    level = p.data[idx]
    return level(x, y)
end

function Base.size(p::Pyramid)
    return size(p.data[1])
end
function Base.show(io::IO, ::MIME"text/plain", p::Pyramid)
    show(io, p)
end
function Base.show(io::IO, p::Pyramid)
    println(io, "Pyramid with levels: $(size.(p.data))")
end

Is this something we want to add to ImageBase?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the proposed Pyramid implementation and the ImageBase APIs it uses, especially restrict and interpolate. The issue names no target file or tests; if accepted, done should include an agreed API and verified pyramid construction, level selection, sizing, and display behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
computer-vision
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.