Page 1 of 1

Cosine-sum filters for resampling

Posted: 2019-08-30T00:50:31-07:00
Cosine-sum filters for resampling are filters that are designed as a sum of cosine functions, which is then truncated to a desired width.

An example formula for width-4 (range from -2 to 2) cosine-sum filters would be:

a+b×cos(90°×input)+c×cos(180°×input)+d×cos(270°×input)+e×cos(450°×input)+f×cos(540°×input)+g×cos(630°×input)+...

Omitting 360°, 720°, etc. because they don't produce a constant when tiled indefinitely. For width-6 filters use multiples of 60° instead of 90°.

Those parameters look like some sort of digitization of the Gaussian function: the digital Gaussian is a=0.25, b=0.375, c=0.15, d=0.025.

Those parameters produce a cardinal function (assuming "tensor" resampling) with the first derivative of points at -1 and 1 being set to 0.5 and -0.5 respectively: a=0.25, b=0.45458, c=0.25, d=0.045423

Are such filters already known and researched in the community?

Re: Cosine-sum filters for resampling

Posted: 2019-08-30T09:43:28-07:00
I have not heard of anything like that for resampling. Can you point to some reference?

Re: Cosine-sum filters for resampling

Posted: 2019-08-30T10:00:40-07:00
IM has "-filter Cosine" for resampling. I don't know if this is the same as the OP.

Re: Cosine-sum filters for resampling

Posted: 2019-08-30T21:13:06-07:00
snibgo wrote:
2019-08-30T10:00:40-07:00
IM has "-filter Cosine" for resampling. I don't know if this is the same as the OP.
"-filter Cosine" is using a Cosine window (made with a cosine function) to window the Sinc function to produce the filter. Cosine-sum filters are made by adding cosine functions to produce the filter. Those are not the same.
fmw42 wrote:
2019-08-30T09:43:28-07:00
I have not heard of anything like that for resampling. Can you point to some reference?
There are some window functions like Hann, Hamming and Blackman that have a cosine-sum structure. The same concept could be used for resampling filters.

Re: Cosine-sum filters for resampling

Posted: 2019-08-30T22:20:47-07:00
Yes, but can you point to some reference so that we can see what is being done or is this just some idea of yours with no current background or theory?

Re: Cosine-sum filters for resampling

Posted: 2019-08-30T23:08:07-07:00
fmw42 wrote:
2019-08-30T22:20:47-07:00
Yes, but can you point to some reference so that we can see what is being done or is this just some idea of yours with no current background or theory?
This page demonstrates various window functions of the cosine-sum structure: https://en.wikipedia.org/wiki/Window_fu ... um_windows

As for the use of the cosine-sum structure for resampling filters, this is indeed "with no current background or theory".

Re: Cosine-sum filters for resampling

Posted: 2019-08-31T05:34:42-07:00
We do include a Hann filter, a member of the cosine-sum family, however we do not currently support the generalized cosine window case. You are welcome to contribute a cosine-sum filter. Look for FilterFunctions in MagickCore/resize.c to get started.

Re: Cosine-sum filters for resampling

Posted: 2019-08-31T05:59:52-07:00
It would be interesting to research and find out if cosine-sum filters (whether "tensor" or "EWA") are any better than windowed Sinc filters and cubic filters.