Log in

View Full Version : AreaResize


Sakura
23rd February 2020, 07:51
Hello! I port AreaResize to VapourSynth, based on the original AviSynth verison (http://csbarn.blogspot.com/2012/08/arearesize.html) by Chikuzen and the modified AviSynth version (https://forum.doom9.org/showthread.php?t=175297) by Aktan.

AreaResize is an area average downscale resizer:
Support 8-16 bit and 32 bit sample type.
Support YUV and RGB color family.
Downscaling in 8-16 bit RGB with gamma corrected.

Usage
core.area.AreaResize(clip clip, int width, int height[, float gamma=2.2])

# Parameter "gamma" is for gamma corrected, only using for 8-16 bit RGB input


Github: https://github.com/Kiyamou/VapourSynth-AreaResize
Download: https://github.com/Kiyamou/VapourSynth-AreaResize/releases

There is known bug for special target size, such as 1920x1080 -> 1200x700 for 8~16bit YUV and 8bit RGB.

Lypheo
24th February 2020, 02:29
Could you perhaps explain the algorithm behind this? How does it differ from conventional convolution-based resizers?

Sakura
25th February 2020, 15:05
Could you perhaps explain the algorithm behind this? How does it differ from conventional convolution-based resizers?
I have something, causing me reply slowly.

This algorithm is simple, just calculating the average of pixel. (So it is fast.)
For example, 1080p->720p, greatest common divisor: (1920,1280)=640, 1920/640=3, 1280/640=2.
So calculate the value of dst like this:
y_dst[0] = (y_src[0] + y_src[0] + y_src[1]) / 3
y_dst[1] = (y_src[1] + y_src[2] + y_src[2]) / 3
...
After calculating, the width of clip is changed from 1920 to 1280. And then use the same method to calcuate for height.

Compared other conventional convolution-based resizers, firstly it can be only used to downscale.
From the aspect of effect, I think AreaResize is better than Bicubic, while Spline and Lanczos is better than AreaResize.