Skip to content
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

[Feature request] Float coordinates for Letterbox (and possibly AddBorders) #433

Open
DTL2020 opened this issue Mar 25, 2025 · 0 comments
Open

Comments

@DTL2020
Copy link

DTL2020 commented Mar 25, 2025

It is good to have float coordinates input and new transient positioning relative to sampling grid.

Example of the left border float coordinate for LetterBox:

Function LetterBoxLeftFloatP(clip c, float left, int flt_rad)
{
  left_int=Int(left)
  pad=1
  l_padded=AddBorders(c,pad, 0,0,0)
  unflt=LetterBox(l_padded, 0, 0, x1=left_int+pad)
  frac=Frac(left)
  flt=GaussResize(unflt, unflt.width, unflt.height, p=8, b=2.71828, s=0, force=1, src_left=(0.0-frac))
  uf_internal=Crop(l_padded, left_int+flt_rad+pad, 0, l_padded.width-(left_int+flt_rad+pad), l_padded.height)
  proc_padded=Overlay(flt, uf_internal, x=left_int+flt_rad+pad, y=0)
  return Crop(proc_padded,pad,0,0,0).SubTitle(Format("left={left}"))
}

BlankClip(10000, 200, 200, color=$7F7F7F, pixel_type="YV24")

Animate(last, 0, 10000, "LetterBoxLeftFloatP",\
-0.5, 3,\
Float(last.width/2), 3)

LanczosResize(width*2, height*2, taps=16)

For LetterBox() with fixed frame size it may be natural to control its placement measured from the border of the frame with float-precision with current left/top/right/bottom parameters without changing parameters count.
But it is also nice to have float-precision transient placement control in AddBorders and it has less natural control because it adds a new number of integer sample count to the frame with integer dimensions. So addition of the float format of left/top/right/bottom may be harder to understand and also the required control of the shifting of transients from the current 'in-between old and new sample' is only +-0.5 max. But as we have 4 borders with separate control it may require up to 4 new parameters to control also sub-sampling shifting. If LetterBox uses AddBorders it may be a better solution ?

Some use cases of Animate(LetterBox()) - when user adjust the anti-ringing filtering it can show the very small residual ringing in dynamics when it cycle many possible positions of transient relative to sampling grid. It may be not very good visible in static imaging. Also may be used for compression testing.

Addition: The script solution in this post is not perfect because it also shifts part of the original image. Will try to think if it possible to make better example later. But with small flt_rad (about 2..3) the shifting of the part of image may be not greatly visible so it work as good enough demo.
Other possible way without shifting but with limited precision (at this implementation) may be:
For 0.01 precision/stepping: (for processed part of the frame)

1. LanczosResize(width*100, height) #may be not best - need testing with Point or Bicubic or Spline ?
2. LetterBox(Int(fractional_part*100)) #set position of transient in integer form with 1/100 precision (in original size)
3. FilteredDownsize(width/100, height) #using provided by user filter kernel

May be this method may be redesigned for higher (unlimited float) precision. Like combining of 1+2+3 operations into single filtering-convolution operation if possible. Though even 0.01 sample granularity is already very good.

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

No branches or pull requests

1 participant