Skip to content

Expanded functionality of oiiotool --resize #3751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2023

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Jan 12, 2023

Currently, --resize takes a single argument giving an "image geometry" (like "640x480") that designates the size of the result image, and the rescaling specifically maps the "full size" (a.k.a. display window) of the input image to the output.

This experimental change extends --resize to accept additional new optional modifiers:

  • ":from=" Overrides the default of the full window of the source.

  • ":to=" Overrides the default of the full window of the destination.

  • ":offset=+x+y" Adds an additional offset transformation to the destination.

  • ":edgeclamp=<0|1>" Turns on and off some special edge sample clamping to try to reduce certain ringing artifacts. (Experimental.)

Unlike the output resolution, which like all image sizes must be an integer resolution, the overrides on the source and destination windows and the offset is allowed to be floating point, that is, allowing for fractional pixel sizes or offsets.

The from and to windows do not restrict the boundaries of pixels computed, but rather, simply define the transformational mapping between the two images: the transformation will be chosen such that the float-valued coordinates of the source image correspond exactly to the float-valued coordintes within the destination image. In both cases, coordinates refer to the true continuous coordinates in the image plane, with (0.0, 0.0) being the "upper left" corner, and pixel centers being at half-unit positions such as (ipixel+0.5, jpixel+0.5).

For example,

oiiotool in.exr -resize:from=100x50.3+50+20 1000x503 -o out.exr

creates a 1000x503 pixel image where the full output image is a resized version of the 100x50.3 pixel window starting at coordinates (50,20) in the input image.

This is mostly implemented (when it doesn't end up equivalent to the old style resize) in terms of the existing IBA::warp() function. I needed to add a new variety of warp() to avoid some artifacts, but I do this tentatively and so currently do not expose it as part of the public API. I want to gain some experience with the oiiotool usage by the users who requested this, then will return later to exactly how it should be exposed directly as IBA functions.

Currently, --resize takes a single argument giving an "image geometry"
(like "640x480") that designates the size of the result image, and the
rescaling specifically maps the "full size" (a.k.a. display window) of
the input image to the output.

This experimental change extends --resize to accept additional new
optional modifiers:

- ":from=<geom>" Overrides the default of the full window of the
  source.

- ":to=<geom>" Overrides the default of the full window of the
  destination.

- ":offset=+x+y" Adds an additional offset transformation to the
  destination.

- ":edgeclamp=<0|1>" Turns on and off some special edge sample
  clamping to try to reduce certain ringing artifacts. (Experimental.)

Unlike the output resolution, which like all image sizes must be an
integer resolution, the overrides on the source and destination
windows and the offset is allowed to be floating point, that is,
allowing for fractional pixel sizes or offsets.

The from and to windows do not restrict the boundaries of pixels
computed, but rather, simply define the transformational mapping
between the two images: the transformation will be chosen such that
the float-valued coordinates of the source image correspond exactly to
the float-valued coordintes within the destination image. In both
cases, coordinates refer to the true continuous coordinates in the
image plane, with (0.0, 0.0) being the "upper left" corner, and pixel
centers being at half-unit positions such as (ipixel+0.5, jpixel+0.5).

For example,

    oiiotool in.exr -resize:from=100x50.3+50+20 1000x503 -o out.exr

creates a 1000x503 pixel image where the full output image is a
resized version of the 100x50.3 pixel window starting at coordinates
(50,20) in the input image.

This is mostly implemented (when it doesn't end up equivalent to the
old style resize) in terms of the existing IBA::warp() function. I needed
to add a new variety of warp() to avoid some artifacts, but I do this
tentatively and so currently do not expose it as part of the public API.
I want to gain some experience with the oiiotool usage by the users who
requested this, then will return later to exactly how it should be
exposed directly as IBA functions.
@lgritz lgritz merged commit fd05534 into AcademySoftwareFoundation:master Jan 12, 2023
@lgritz lgritz deleted the lg-resizedcut branch January 13, 2023 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant