Page 1 of 1
Showing cardinal basis functions (resampling an impulse)
Posted: 2012-04-20T08:55:06-07:00
by NicolasRobidoux
Suggestion: When showing cardinal basis functions, that is, what happens to an impulse (e.g.
http://www.imagemagick.org/Usage/resize ... catrom.jpg), it is my opinion that it is better to use light gray instead of white as "foreground", and dark gray instead of black as "background", because then you will be able to see "ripples" which are clipped when using white and black.
Re: Showing cardinal basis functions (resampling an impulse)
Posted: 2012-04-21T07:49:36-07:00
by NicolasRobidoux
Actually, because reasonable filters only undershoot when resampling an impulse, it's enough to change black to (dark) gray.
P.S. ... reasonable filters SHOULD overshoot very little when resampling an impulse... See below!
Re: Showing cardinal basis functions (resampling an impulse)
Posted: 2012-04-22T20:25:46-07:00
by anthony
This is true. But at the time I was trying to showing more the difference in basic interpolation filter results between resize and distort filter rather than exact result of the filter.
However I'll re-work that examples to use gray values instead of black and white.
Technically I should also be converting from a linear RGB case to sRGB too
The Examples for those joining this discussion are actually located at the end of...
http://www.imagemagick.org/Usage/resize ... terpolated
Re: Showing cardinal basis functions (resampling an impulse)
Posted: 2012-04-22T20:38:42-07:00
by anthony
Well it seems that the 'ringing' effects show a much more marked difference between the use of equivelent resize and distort interpolation! Distort of course is more circular, but can also be more pronounced!
When these images appear the examples have been updated (give it an hour or so)
Resize (tensor) Catrom vs Distort (EWA) Catrom Filtering
Re: Showing cardinal basis functions (resampling an impulse)
Posted: 2012-04-23T05:09:06-07:00
by NicolasRobidoux
So I missed that in principle "reasonable" EWA filters could sharpen an impulse. A lot. Makes complete sense, and I "knew" it, but it's funny how seeing it makes you know it for real.
(Thank you. It's nice to "see" things.)
Re: Showing cardinal basis functions (resampling an impulse)
Posted: 2012-04-23T05:13:23-07:00
by NicolasRobidoux
If there was any need for proof that RobidouxSharp is pretty much as far as one should push a Keys cubic toward Catmull-Rom when using it as an EWA weight function...
Re: Showing cardinal basis functions (resampling an impulse)
Posted: 2012-04-23T19:05:42-07:00
by anthony
Cubic Keys Filters (named) in ImageMagick from very blurry cubic B=1.0 C=0.0 to sharp catrom B=0.0 C=0.5
generated using EWA distort to resize the result
Code: Select all
convert xc:gray80 -bordercolor gray20 -border 2 \
-filter $filter +distort SRT 20,0 dot_distort_$filter.png
cubic
robidoux
mitchell
robidoux_sharp
catrom
Note the three in the middle are quite close together in relation to the ones on the end.
Note while catrom is oversharp with a deep 'trough-like halo' surrounding it, none of them actually have 'ringing' effects
To complete the named Cubics... Hermite is a sharp cubic but without a trough. B=0.0 C=0.0
hermite
Re: Showing cardinal basis functions (resampling an impulse)
Posted: 2012-04-24T03:56:09-07:00
by NicolasRobidoux
anthony wrote:...
Note the three in the middle are quite close together in relation to the ones on the end.
...
And yet henriwho saw a very clear difference when downsampling between Robidoux (too blurry, in his opinion) and RobidouxSharp (too aliased).
Given how many pixels are touched by an EWA in comparison with a tensor implementation of the same "filter", it makes sense that small differences in filter values matter more with EWA.
Re: Showing cardinal basis functions (resampling an impulse)
Posted: 2012-04-24T03:57:16-07:00
by NicolasRobidoux
Hermite clearly has a "fat x watermark".
Re: Showing cardinal basis functions (resampling an impulse)
Posted: 2012-04-25T19:49:23-07:00
by anthony
NicolasRobidoux wrote:Hermite clearly has a "fat x watermark".
that 'watermark' is a reflection of the change in blending. It is an echo of the 'X' you get in a EWA
box filter.
You also see it in the filter between
box and
hermite....
triangle. Though there it is more of a '+' than and 'x' due to the larger support (discontinuity of slope)
It is also visible in Lagrange, where it is caused by the slope discontinuity that that interpolation filter produces. Lagrange filter can also generate
box,
triangle filters too by adjusting its 'order' via the filters support size.
Lagrange Interpolation Filters graph..
See IM Examples, Other Interpolation Filters
http://www.imagemagick.org/Usage/resize ... late_other
Re: Showing cardinal basis functions (resampling an impulse)
Posted: 2012-04-26T06:28:37-07:00
by NicolasRobidoux
anthony wrote:NicolasRobidoux wrote:Hermite clearly has a "fat x watermark".
I was not writing that there was a bug/error. I was observing that Hermite shows a really bad artifact right in the cardinal basis function plot. Like many others. But not, interestingly enough, the Keys cubics.
Re: Showing cardinal basis functions (resampling an impulse)
Posted: 2012-04-26T22:16:09-07:00
by anthony
Oh... Thats is because they have such a smooth curve, that you don't see the effect of pixels entering and leaving the support 'circle' (ellipse).
Look at 'support' which shows clearing this type of support generated artefact (internal and external) with a odd support window on a gaussian filter
http://www.imagemagick.org/Usage/resize/#filter_support
In orthogonal filtering such artefacts are rarely visible as any integer or half-integer support will ensure for every pixel that enters the support window, a pixel is also leaving (except at edges)
Re: Showing cardinal basis functions (resampling an impulse)
Posted: 2012-04-30T08:46:26-07:00
by NicolasRobidoux
anthony wrote:NicolasRobidoux wrote:Hermite clearly has a "fat x watermark".
...
that 'watermark' is a reflection of the change in blending. It is an echo of the 'X' you get in a EWA
box filter.
...
You also see it in the filter between
box and
hermite....
triangle. Though there it is more of a '+' than and 'x' due to the larger support (discontinuity of slope)
...
(Probably a bad)
idea: Blend EWA Triangle and EWA Hermite so as to minimize deviation from rotational symmetry, and consequently use the "+" to erase the "x", and vice versa. Or minimize the affine gradient reconstruction error.
This may get a halfway reasonable interpolatory EWA filter, with a really tight stencil.
Manana.
Re: Showing cardinal basis functions (re 'Pasampling an impu
Posted: 2012-04-30T18:33:31-07:00
by anthony
Not sure it is worth looking at.
However you can generate many new interpolating filters by using box with a support of 1.0, but then apply various Sinc windowing functions to that to 'shape' the box. You need to do it this way as only windowing functions are scaled to match the filters support.
I use this 'windowed box' technique to scale and extract the actual window function for graphing. See "filter:verbose" expert option notes. For example here I get the plot data of the 'Welsh windowing function'. This would produce a parabolic interpolation filter!
Code: Select all
convert null: -define filter:filter=Box \
-define filter:window=Welsh \
-define filter:support=1.0 \
-define filter:verbose=1 \
-resize 2 null: > window_welsh.dat
gnuplot
set grid
plot [0:1][0:1] "window_welsh.dat" with lines
And here I test it.
Code: Select all
convert xc:gray80 -bordercolor gray20 -border 2 \
-define filter:filter=Box -define filter:window=Welsh -define filter:support=1.0 \
+distort SRT 20,0 dot_distort_parabolic.png
And here is the image (which is slightly different but almost identify to hermite.
This means it is the 'sharp peak' that causes the Triangle 'x' artefacts.
Another unexpected result in my own tests is the use of a Gaussian with a small sigma (sigma=1/3 - my Gaussian interpolation)
As you can see a small gaussian sigma produces 'squarish' results as a cylindrical filter! Which as it remains 'separable' should produce the same result for resize. It may be why I like gaussian interpolators for some things
PS: you get similar results for a 'Parzen' (window scaled Cubic) window filter, using the same technique as the 'welsh - parabolic' interpolation filter above.
This sort of thing is actually why I added an expert settings to just about every control I could think of, when I re-developed resampling filters. For example I not only have a way to specify the normal support limits of the main weighting function, but then allow you to specify a different 'window_support' to the windowing function. It allows you to 'mix and match' how the two functions get 'multiplied together' to generate a whole array of filter curves to use, using just what has been implemented!