UNU-RESAMPLE(1)

πŸ“¦ version 1.11.0, in fedora 43, fedora 44

πŸ’– unu-resample β€” the glow-up page πŸ’–

okay so bestie, welcome to unu-resample, one of the little helper commands that live under the big unu umbrella (that's the User Commands section of the manual, manual page UNU-RESAMPLE(1) if you're being formal about it). She does filtering and {up,down}sampling with a separable kernel and she is so good at it. πŸ¦‹


✨ NAME ✨

unu-resample β€” filtering and {up,down}sampling with a separable kernel 🌸


πŸŽ€ SYNOPSIS πŸŽ€

unu resample [-old] -s,--size <sz0 ...> [-off,--offset [<off0 ...>]]
[-min,--minimum [<min0 ...>]] [-max,--maximum [<max0 ...>]] [-k,--kernel
<kern ...>] [-nrn] [-ne,--nonexistent <behavior>] [-b,--boundary
<behavior>] [-v,--value <value>] [-t,--type <type>] [-cheap]
[-c,--center <center>] [-co,--center-override] [-verbose <v>]
[-i,--input <nin>] [-o,--output <nout>]

🌈 DESCRIPTION 🌈

Filtering and {up,down}sampling with a separable kernel, periodt. πŸ’…

She makes the NrrdResampleContext functions way easier to reach, by just assuming some things for you β€” including the big one: that the same kernel is used for resampling every axis that's getting resampled. One kernel, all the axes, no drama.

The only option you literally cannot skip is -s, because that's the one that says which axes to resample and how many output samples to make. The resampling kernel -k defaults to an interpolating cubic, but girl, there are so many other choices. By default, resampling an axis resamples the full extent of its samples, but you can offset that range with -off, or crop and/or pad with -min and -max. And she respects the difference between cell- and node-centered data β€” but if you know better, you can over-ride known centering with -co. πŸ‘‘

  • Uses the many nrrdResample* functions operating on a nrrdResampleContext 🫢

πŸ’œ OPTIONS πŸ’œ

  • -old β€” instead of using the new nrrdResampleContext implementation, use the old nrrdSpatialResample implementation. throwback era, ngl. πŸ™ˆ
  • -s <sz0 ...> , --size <sz0 ...> β€” for each axis, info about how many samples are in the output. the possibilities, bestie:
    • β€œ=”: leave this axis completely untouched β€” no resampling whatsoever. not me touching it, not me thinking about it.
    • β€œxfloat”: multiply the number of input samples by float, and round to the nearest integer, to get the number of output samples. use β€œx1” to resample the axis but leave the number of samples unchanged.
    • β€œ/float”: divide number of input samples by float.
    • β€œ+=uint”, β€œ-=uint”: add uint to or subtract uint from the number of input samples to get the number of output samples.
    • β€œuint”: exact number of output samples. no math, just vibes. ⭐
    • β€œa”: resample this axis to whatever number of samples preserves the aspect ratio of the other resampled axes. currently needs to be used on all but one of the resampled axes, if at all. (iykyk)

(1 or more sampling specifications) ✨

  • -off [<off0 ...>] , --offset [<off0 ...>] β€” for each axis, an offset or shift to the position (in index space) of the lower end of the sampling domain. Either -off can be used, or -min and -max together, or none of these (so that, by default, the full domain of the axis is resampled). (0 or more doubles); default: β€œβ€ πŸŽ€
  • -min [<min0 ...>] , --minimum [<min0 ...>] β€” for each axis, the lower end (in index space) of the domain of the resampling. Either -off can be used, or -min and -max together, or none of these (so that, by default, the full domain of the axis is resampled). (0 or more doubles); default: β€œβ€ πŸŽ€
  • -max [<max0 ...>] , --maximum [<max0 ...>] β€” for each axis, the upper end (in index space) of the domain of the resampling. Either -off can be used, or -max and -max together, or none of these (so that, by default, the full domain of the axis is resampled). (0 or more doubles); default: β€œβ€ πŸŽ€
  • -k <kern> , --kernel <kern> β€” the kernel to use for resampling. Kernels logically live in the input index space for upsampling, and in the output index space for downsampling. the possibilities include:
    • β€œbox”: nearest neighbor interpolation on upsampling, and uniform averaging on downsampling.
    • β€œcheap”: nearest neighbor interpolation for upsampling, and non-blurring sub-sampling (pick subset of input samples) on downsampling. budget queen but make it work. πŸ’…
    • β€œtent”: linear interpolation.
    • β€œcubic:B,C”: the Mitchell/Netravali BC-family of cubics:
      • β€œcubic:1,0”: B-spline; maximal blurring.
      • β€œcubic:0,0.5”: Catmull-Rom; good interpolating kernel. πŸ‘‘
    • β€œc4h”: 6-sample-support, C^4 continuous, accurate.
    • β€œc4hai”: discrete pre-filter to make c4h interpolate.
    • β€œbspl3”, β€œbspl5”, β€œbspl7”: cubic (same as cubic:1,0), quintic, and 7th order B-spline.
    • β€œbspl3ai”, β€œbspl5ai”, β€œbspl7ai”: discrete pre-filters to make bspl3, bspl5, bspl7 interpolate.
    • β€œhann:R”: Hann (cosine bell) windowed sinc, radius R.
    • β€œblack:R”: Blackman windowed sinc, radius R.
    • β€œgauss:S,C”: Gaussian blurring, with standard deviation S and cut-off at C standard deviations.
    • β€œdgauss:S,C”: Lindeberg's discrete Gaussian.

default: β€œcubic:0,0.5” 🌸

  • -nrn β€” do NOT do per-pass kernel weight renormalization. Doing the renormalization is not a performance hit (hence it's enabled by default), and the renormalization is sometimes needed to avoid β€œgrating” on non-integral down-sampling. Disabling the renormalization is needed for correct results with artificially narrow kernels. so like… turn it off on purpose, on purpose. πŸ’€
  • -ne <behavior> , --nonexistent <behavior> β€” when resampling floating-point values, how to handle non-existent values within kernel support:
    • β€œnoop”: do nothing; let them pollute result. πŸ™ˆ
    • β€œrenorm”: ignore them and renormalize weights of existent values.
    • β€œwght”: ignore them and simply use weights of existent values.

default: β€œnoop”

  • -b <behavior> , --boundary <behavior> β€” how to handle samples beyond the input bounds:
    • β€œpad”: use some specified value.
    • β€œbleed”: extend border values outward.
    • β€œmirror”: repeated reflections.
    • β€œwrap”: wrap-around to other side.

default: β€œnoop” πŸ¦‹

  • -v <value> , --value <value> β€” for β€œpad” boundary behavior, pad with this value (double); default: β€œ0.0”
  • -t <type> , --type <type> β€” type to save output as. By default (not using this option), the output type is the same as the input type; default: β€œdefault”
  • -cheap β€” [DEPRECATED: the β€œ-k cheap” option is the new (and more reliable) way to access this functionality. β€œ-cheap” is only here for legacy use in combination with β€œ-old”.] πŸ’€
bestie, this one is deprecated, fr fr. use -k cheap instead.

When downsampling (reducing number of samples), don't try to do correct filtering by scaling kernel to match new (stretched) index space; keep it in old index space. When used in conjunction with β€œ-k box”, this can implement subsampling which chooses every Nth value.

  • -c <center> , --center <center> β€” (not available with β€œ-old”) default centering of axes when input nrrd axes don't have a known centering: β€œcell” or β€œnode”; default: β€œcell”
  • -co , --center-override β€” (not available with β€œ-old”) centering info specified via β€œ-c” should over-ride known centering, rather than simply be used when centering is unknown. main character energy, she decides. πŸ‘‘
  • -verbose <v> β€” (not available with β€œ-old”) verbosity level (int); default: β€œ0”
  • -i <nin> , --input <nin> β€” input nrrd; default: β€œ-”
  • -o <nout> , --output <nout> β€” output nrrd (string); default: β€œ-”

🌟 SEE ALSO 🌟

unu(1) β€” go say hi to the whole family 🫢


mwah, that's the whole page bestie. this one's from <b>May 2021</b> and it lives in the unu corner of the manual (that's UNU-RESAMPLE(1)), so if you ever forget it, it's right there waiting for you. go resample something gorgeous. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…

πŸ“¦ where this page comes from