Current version

v1.10.4 (stable)

Navigation

Main page
Archived news
Downloads
Documentation
   Capture
   Compiling
   Processing
   Crashes
Features
Filters
Plugin SDK
Knowledge base
Contact info
Forum
 
Other projects
   Altirra

Search

Archives

01 Dec - 31 Dec 2013
01 Oct - 31 Oct 2013
01 Aug - 31 Aug 2013
01 May - 31 May 2013
01 Mar - 31 Mar 2013
01 Feb - 29 Feb 2013
01 Dec - 31 Dec 2012
01 Nov - 30 Nov 2012
01 Oct - 31 Oct 2012
01 Sep - 30 Sep 2012
01 Aug - 31 Aug 2012
01 June - 30 June 2012
01 May - 31 May 2012
01 Apr - 30 Apr 2012
01 Dec - 31 Dec 2011
01 Nov - 30 Nov 2011
01 Oct - 31 Oct 2011
01 Sep - 30 Sep 2011
01 Aug - 31 Aug 2011
01 Jul - 31 Jul 2011
01 June - 30 June 2011
01 May - 31 May 2011
01 Apr - 30 Apr 2011
01 Mar - 31 Mar 2011
01 Feb - 29 Feb 2011
01 Jan - 31 Jan 2011
01 Dec - 31 Dec 2010
01 Nov - 30 Nov 2010
01 Oct - 31 Oct 2010
01 Sep - 30 Sep 2010
01 Aug - 31 Aug 2010
01 Jul - 31 Jul 2010
01 June - 30 June 2010
01 May - 31 May 2010
01 Apr - 30 Apr 2010
01 Mar - 31 Mar 2010
01 Feb - 29 Feb 2010
01 Jan - 31 Jan 2010
01 Dec - 31 Dec 2009
01 Nov - 30 Nov 2009
01 Oct - 31 Oct 2009
01 Sep - 30 Sep 2009
01 Aug - 31 Aug 2009
01 Jul - 31 Jul 2009
01 June - 30 June 2009
01 May - 31 May 2009
01 Apr - 30 Apr 2009
01 Mar - 31 Mar 2009
01 Feb - 29 Feb 2009
01 Jan - 31 Jan 2009
01 Dec - 31 Dec 2008
01 Nov - 30 Nov 2008
01 Oct - 31 Oct 2008
01 Sep - 30 Sep 2008
01 Aug - 31 Aug 2008
01 Jul - 31 Jul 2008
01 June - 30 June 2008
01 May - 31 May 2008
01 Apr - 30 Apr 2008
01 Mar - 31 Mar 2008
01 Feb - 29 Feb 2008
01 Jan - 31 Jan 2008
01 Dec - 31 Dec 2007
01 Nov - 30 Nov 2007
01 Oct - 31 Oct 2007
01 Sep - 30 Sep 2007
01 Aug - 31 Aug 2007
01 Jul - 31 Jul 2007
01 June - 30 June 2007
01 May - 31 May 2007
01 Apr - 30 Apr 2007
01 Mar - 31 Mar 2007
01 Feb - 29 Feb 2007
01 Jan - 31 Jan 2007
01 Dec - 31 Dec 2006
01 Nov - 30 Nov 2006
01 Oct - 31 Oct 2006
01 Sep - 30 Sep 2006
01 Aug - 31 Aug 2006
01 Jul - 31 Jul 2006
01 June - 30 June 2006
01 May - 31 May 2006
01 Apr - 30 Apr 2006
01 Mar - 31 Mar 2006
01 Feb - 29 Feb 2006
01 Jan - 31 Jan 2006
01 Dec - 31 Dec 2005
01 Nov - 30 Nov 2005
01 Oct - 31 Oct 2005
01 Sep - 30 Sep 2005
01 Aug - 31 Aug 2005
01 Jul - 31 Jul 2005
01 June - 30 June 2005
01 May - 31 May 2005
01 Apr - 30 Apr 2005
01 Mar - 31 Mar 2005
01 Feb - 29 Feb 2005
01 Jan - 31 Jan 2005
01 Dec - 31 Dec 2004
01 Nov - 30 Nov 2004
01 Oct - 31 Oct 2004
01 Sep - 30 Sep 2004
01 Aug - 31 Aug 2004

Stuff

Powered by Pivot  
XML: RSS feed 
XML: Atom feed 

§ Very high quality Fant bitmap scaling

After seeing an interesting discussion about image scaling quality in Windows Presentation Foundation (WPF) I decided to take a look at its "High Quality" setting. It's documented in the BitmapScalingMode enum as being a synonym for "Fant" scaling:

http://msdn.microsoft.com/en-us/library/system.windows.media.bitmapscalingmode.aspx

Unfortunately, being sourced from academic literature, trying to find anything direct on Fant's algorithm results in a maze of links to paywalls and abstracts. After digging around a bit, though, I found enough detailed references and code fragments to figured it out, and also spent some time trying it out in a WPF application. (By the way, the WPF Designer is soooooo slooooooowwwwwww!) Now, WPF essentially supports three bitmap scaling modes: nearest, linear, and Fant. Nearest and linear are, as you'd expect, just point sampling and linear interpolation. Linear (bilinear) mode is restricted to a 2x2 kernel and does not use mipmaps, so it will start aliasing once you get below 70% or so. The Fant algorithm, however, is described as very high quality. Sounds interesting, right?

Well, not really.

It turns out that Fant's algorithm is... a box filter. More specifically, it is equivalent to linear interpolation for enlargement along an axis and a box filter for decimation. From what I gather, Fant's algorithm was originally interesting because of the way that the box filter was implemented, which was amenable to hardware implementation. By modern standards and implemented in software, though, it's unremarkable. I tried it out with some decimation settings on some test images and particularly a zone plate image, and it showed more aliasing than a conventional triangle filter (precise bilinear in VirtualDub) or bicubic decimation filter -- not too surprising for a box filter.

I don't know WPF very well, but from what I can gather, Fant's algorithm was made available because that's what the Windows Imaging Component (WIC) has available under the hood. Thing is, besides the mediocre quality, a box filter doesn't make sense when you are trying to support accelerated rendering since it's more expensive to implement than generating mipmaps and using trilinear filtering, which is already implemented directly in the texture sampling hardware. Box filtering isn't, which means it has to be done manually, which is slower... assuming that WPF even bothers accelerating it. It's also a somewhat awkward limitation since .NET has already had decent bilinear and bicubic decimation support available through System.Drawing (GDI+). Therefore, if you sometimes need to downscale images in your WPF based UI, you might consider prescaling them through GDI+ instead to get better quality.

Comments

Comments posted:


You just became number one hit on Google for some "Fant xxx" search strings. An interesting SEO observation.

tobi - 11 04 10 - 10:18


Sheesh, that was fast. I only posted this about 12 hours ago.

The funny thing about appearing high in Google searches is that people sometimes unknowingly send me links to my own web site. It's also sometimes annoying when I try searching for something and I keep getting links to myself complaining about not being able to find something.

Phaeron - 11 04 10 - 10:31


When you enter the actual words "fant xxx" you cannot find this site because there are other seemingly more relevant matches for the keyword xxx. Sorry I just put you in bad neighborhood ;-)

tobi - 11 04 10 - 22:08


"... four bitmap scaling modes: nearest, linear, and Fant" I count only 3? Nearest: 1, Linear: 2, Faint: 3. What did I miss?

Best regards
Mads

Mads - 14 04 10 - 16:20


Just a typo I made while going over the list. There are a lot of enum values corresponding to various modes, but some of them map to others.

Phaeron - 14 04 10 - 18:04


Avery, box filter is implemented for anti-aliasing in hardware. If I remember correctly you could anti-alias bitmap with box filter using framebuffer objects (render to FBO with AA). That is unless the user sets another AA mode in driver control panel such as tent, wide tent, or edge-detect.

Igor Levicki (link) - 15 04 10 - 05:21


You can set an AA mode, but only for very specific ratios, and you have no guarantee or even way of knowing whether the AA filter is a box filter. In fact, it frequently isn't; 2x AA, for instance, is often two samples diagonally skewed, like on a d6. The filter kernel also frequently overlaps between adjacent pixels. In practice, the FSAA filter is generally poor enough that you can do a much better job with manual texture samples (you can get some useful 4x4 filter kernels with four samples). You also avoid some of the annoying restrictions on older hardware with AA color surfaces.

Phaeron - 15 04 10 - 15:38

Comment form


Please keep comments on-topic for this entry. If you have unrelated comments about VirtualDub, the forum is a better place to post them.
Name:  
Remember personal info?

Email (Optional):
Your email address is only revealed to the blog owner and is not shown to the public.
URL (Optional):
Comment: /

An authentication dialog may appear when you click Post Comment. Simply type in "post" as the user and "now" as the password. I have had to do this to stop automated comment spam.



Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.