How does bitmap oversampling work?

Post questions on how to use or achieve an effect in Inkscape.
eyerouge
Posts: 2
Joined: Sun Dec 06, 2009 9:52 pm

How does bitmap oversampling work?

Postby eyerouge » Wed Jan 05, 2011 11:27 am

We're in love with inkscape and are using it to create an open source card game, but have ran into some problems:

1. How exactly, when and on what does bitmap oversampling work?

Image 1: http://chaosrealm.net/wtactics/files/pi ... mpling.png

Look at the above two images. (Please don't don't look at them zoomed out if your browser shrinks them- would miss out on the glory of this post ; ) The archer is the same bitmap that was imported, and also exported with the same settings in Inkscape, with the only difference that one had oversampling shut off, while other has it activated and high. The bitmaps were in their original sizes in Inkscape. Yet, the oversampled one is blurry, for no apparent reason since its size hasn't been touched in any way.

However, while importing a bitmap and using Inkscape to scale it down while it sits on the Ink canvas, it seems very wise to have a high oversamplign activated: Behold, image 2: http://chaosrealm.net/wtactics/files/pi ... ample2.png
Personally I can't actually see a difference between the 8x8 and 16x16 oversampling in this scenario. Is it just my supposedly normal vision that plays a trick on me?

2. Should oversampling only be activated if one plans to resize (downwards) bitmaps within Inkscape? Or is it meaningful to have it activated even if they're 1:1 when exporting etc?
3. Does high oversampling setting activated slow down inkscape while I'm still working in it? (Meaning, not only on export but while actually editing stuff?)

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: How does bitmap oversampling work?

Postby brynn » Fri Jan 07, 2011 1:16 am

Definitely awesome graphics!
The 2nd one anyway. I'm getting the red X on the first one though (http://chaosrealm.net/wtactics/files/pi ... mpling.png).

niabot
Posts: 37
Joined: Wed Aug 11, 2010 10:43 pm

Re: How does bitmap oversampling work?

Postby niabot » Fri Jan 07, 2011 10:23 am

eyerouge wrote:1. How exactly, when and on what does bitmap oversampling work?

Any image aside from vector graphics uses pixels which are at best seen as a grid of "squares" with different colors. If you have 100% zoom then every pixel of the image is mapped to a single pixel and anything works fine. But as you rotate or scale such an image not every pixel of the image is mapped to 1 pixel of the screen. In the very basic way some pixels would be left out (especially if the image is displayed smaller then the original) and some pixels will be repeated multiple times. In the last case you will see the squares if you rotate an image and zoom in. Oversampling alone only helps to display images better that are scaled down. Instead of searching the pixel inside the image that matches to screen it takes multiple samples for every pixel. Every "screen pixel" will be divded in 4x4, 8x8, 16x16 Pixels. Then for every "subpixel" the color is determined. The result on the screen is the average color of the subpixels. This method is known from rendering programs but has one disadvantage. It can't scale up images without showing the squares. In fact the squares will only get antialiased edges with this method. Another disadvantage becomes visible if an image contains a fine grid, a chessboard pattern. Then oversampling will also have it's limitations while displaying this scaled down image, since the average might be a false assumption.

For example if you have chessboard pattern and you are using 2x2 oversampling, you can have the case that the all 4 subpixel might be white, missing the black pixel between them. The result will be a white pixel, which is wrong. Higher oversampling reduces this effect, but can't avoid it if the number of pixel inside one screenpixel is higher then half of the subsamples. (For further information see Moiré pattern)

eyerouge wrote:Yet, the oversampled one is blurry, for no apparent reason since its size hasn't been touched in any way.

This strongly depends on the alignment of the picture inside the inkscape document. Align it exactly with the pixel-grid and you won't have the problem. Worst case would be an image that is placed at x.5 and y.5 (where x and y is any number). With oversampling every pixel of the will have its part in four neighboring pixels. This will result in bluring by with a 2x2 Matrix and is not desired. So move the image to x.0 and y.0 to avoid this effect.

eyerouge wrote:Personally I can't actually see a difference between the 8x8 and 16x16 oversampling in this scenario. Is it just my supposedly normal vision that plays a trick on me?

Not necessarily. If the image is in case not placed on the pixel grid it will be unsharp in both cases. If it's a exact case of x+0.5 and the image is displayed at 1:1 ratio, then there isn't even a difference to 2x2 sampling.

eyerouge wrote:2. Should oversampling only be activated if one plans to resize (downwards) bitmaps within Inkscape? Or is it meaningful to have it activated even if they're 1:1 when exporting etc?

If you export exactly on 1:1 ratio and also don't use rotation/shearing then there is no optical difference between this settings. If you plan to scale down images then you should activate it. Otherwise you will get artifacts (see explanation above). Zooming will always create artifacts in Inkscape. Then its better to scale the image up in another software and then use it inkscape.

eyerouge wrote:3. Does high oversampling setting activated slow down inkscape while I'm still working in it? (Meaning, not only on export but while actually editing stuff?)

It does. Not as heavily as you might think, since rendering an image is generally fast, but it does. ;-)


Return to “Help with using Inkscape”