assafshocher / ResizeRight

The correct way to resize images or tensors. For Numpy or Pytorch (differentiable).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The antialiasing operation in downsampling

Luciennnnnnn opened this issue · comments

commented

Hi, I wonder how does you implement antialiasing. Could you please explain these lines explicitly?

cur_interp_method = (lambda arg: scale_factor *
                       interp_method(scale_factor * arg))
cur_support_sz = support_sz / scale_factor

AA is about "stretching" the continuous kernel (interp method function) to act as low-pass-filter. However, When you do so, the field of view gets bigger and you grant weights to more pixels. This means the total sum got bigger. you need to renormalize it so the total sum is 1. So for interp_method f you want: s * f(s * x). The internal multiplication stretches the function but makes its integral also 1 / scale_factor times bigger (considering the next line that also widens the support) (keep in mind that scale_factor < 1). The outer multiplication then renormalizes the total sum. Hope that's clear

commented

Yeah. Your explanation is very clear and understandable, also I found that the idea seems to come from "GENERAL FILTERED IMAGE RESCALING".