OpenImageIO icon indicating copy to clipboard operation
OpenImageIO copied to clipboard

add wrap mode arg to st_warp

Open splidje opened this issue 1 year ago • 6 comments

Is your feature request related to a problem? Please describe. The ImageBufAlgo.warp function provides the power to control the wrap mode - i.e. how to generate pixel values outside of the image's data window. However, st_warp doesn't provide this - or at least doesn't via the Python bindings.

Describe the solution you'd like Add warp mode to the ImageBufAlgo.st_warp function

Describe alternatives you've considered I was wondering about giving access to the Filter2D class in Python, or some new class which represents the combination of a filter and some other options like wrap mode. For any functions which use these options you just pass in an object holding all the option values.

Additional context While comparing warped images made by OIIO vs. Nuke, the former has darker edges, because black outside is the default for st_warp.

splidje avatar Jan 04 '24 11:01 splidje

I think you might be onto something here. I have a couple ideas to experiment with to see if this bundling of filtering parameters can work easily.

lgritz avatar Jan 06 '24 17:01 lgritz

if I find some time, I could have a play? Unless you're already on it.

If the former, what ideas do you have?

Off the top of my head, I guess it would be a class called something like FilterParameters and would need:

  • filter name
  • filter width
  • wrap mode

is that right?

splidje avatar Jan 09 '24 10:01 splidje

I've already got something prototyped, hopefully will get a chance to post a PR for people to look at.

lgritz avatar Jan 09 '24 16:01 lgritz

I took a stab at it over the weekend, meant to post before Monday, but I discovered and fixed an unrelated bug along the way and now I'm trying to separate the bug fix from the parameter passing change.

lgritz avatar Jan 09 '24 17:01 lgritz

btw, I've realised there is currently a workaround for this specifically for the "clamp" wrap mode.

You can clamp your ST map image values to half a pixel to 1 minus half a pixel.

And horizontally (the "S") half a pixel is: 0.5 / source image width and vertically (the "T") half a pixel is: 0.5 / source image height

splidje avatar Jan 11 '24 16:01 splidje

and for "black" to work properly use "crop" with a roi 1 pixel larger than the source image's roi_full in every direction (i.e. create a 1 pixel border - of any RGBA) and then clamp to - half a pixel to 1 + half a pixel (I think. Yet to test this)

splidje avatar Jan 11 '24 17:01 splidje