Skip to content

imresize/imrotate fixed point #121

@johnnychen94

Description

@johnnychen94

I think it makes sense to introduce the concept of fixed point to better enhance the imresize function.

A fixedpoint p is where imgr[p] == img[p] holds.

Three new methods will be introduced as new API:

const FixedPointType = Union{Dims, CartesianIndex}

imresize(img, sz, p::FixedPointType)
imresize(img, inds, p::FixedPointType)
imresize(img, p::FixedPointType; ratio)

There are many use cases of this, I'll just list one thing that made me propose the idea:


With this, we can improve (change) the behavior to OffsetArray. Currently, when the input is an OffsetArray:

using OffsetArray

x = OffsetArray(rand(5, 5), -3, -3)

imresize(x, (-5:5, -5:5)) |> axes # (-5:5, -5:5)

imresize(x, (10, 10)) |> axes # (1:10, 1:10)
imresize(x; ratio=2) |> axes # (1:10, 1:10)

This loss the axes information of our OffsetArray, we could change the behavior of it to

imresize(img::OffsetArray, sz::Dims) = imresize(img, sz, topleft(img))
imresize(img::OffsetArray; ratio) = imresize(img, topleft(img); ratio)

Use top left point as the default value because it is consistent with the case that the fixed point for imresize(img::Array, sz) is also the topleft. (1-based indexing).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions