Cosine-sum filters for resampling

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
Post Reply
Piotr Grochowski
Posts: 8
Joined: 2019-08-27T21:27:33-07:00
Authentication code: 1152

Cosine-sum filters for resampling

Post by Piotr Grochowski » 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?

User avatar
fmw42
Posts: 25559
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cosine-sum filters for resampling

Post by fmw42 » 2019-08-30T09:43:28-07:00

I have not heard of anything like that for resampling. Can you point to some reference?

snibgo
Posts: 12153
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Cosine-sum filters for resampling

Post by snibgo » 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.
snibgo's IM pages: im.snibgo.com

Piotr Grochowski
Posts: 8
Joined: 2019-08-27T21:27:33-07:00
Authentication code: 1152

Re: Cosine-sum filters for resampling

Post by Piotr Grochowski » 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.

User avatar
fmw42
Posts: 25559
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cosine-sum filters for resampling

Post by fmw42 » 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?

Piotr Grochowski
Posts: 8
Joined: 2019-08-27T21:27:33-07:00
Authentication code: 1152

Re: Cosine-sum filters for resampling

Post by Piotr Grochowski » 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".

User avatar
magick
Site Admin
Posts: 11063
Joined: 2003-05-31T11:32:55-07:00

Re: Cosine-sum filters for resampling

Post by magick » 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.

Piotr Grochowski
Posts: 8
Joined: 2019-08-27T21:27:33-07:00
Authentication code: 1152

Re: Cosine-sum filters for resampling

Post by Piotr Grochowski » 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.

Post Reply