Skip to content

Image.centerOrigin() off by half a pixel #85

@ReignOfError

Description

@ReignOfError

To find the center of an image, Image.centerOrigin() divides the image's width and height by two; since indexing starts at 0, the numerators should be width-1 and height-1.

This doesn't affect even image dimensions (e.g., for an image with a side length of 4, 4/2 = 2 is equivalent to (4-1)/2 = 1.5 since the latter rounds to 2) but the center point ends up being one pixel off the actual midpoint for sides with an odd length (e.g., 3/2 = 1.5 isn't equivalent to (3-1)/2 = 1 since the former rounds to 2). So, for a 3 x 3 image, this function will place the origin at (2,2) instead of at the centre point located at (1,1).

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