Page 1 of 2 12 LastLast
Results 1 to 10 of 60

Thread: [Award Winner] Bitmapped Images - The technical side of things explained.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,201
    Blog Entries
    8

    Post Antialiasing

    Ok so we have an aliasing issue, what we need is an aliasing busting technique - cue antialiasing.

    Antialiasing is all about doing stuff at a higher sample rate than the final, filtering and then resampling to the final rate. The idea is that the effects that would have been present from the undersample will be beyond the filter and therefore not in the final image. So were back to our zebra. If the camera had filtered off any higher frequencies than the pixel sample rate then as the stripes on the leg of the zebra got thinner then eventually they would blur out and become a solid mid gray color. And then as it got farther away still the whole animal would become solid gray but would at least look better than the new stripes from the earlier example.

    So, always work at a higher resolution than the final. Make a copy of the high resolution image and blur it just a little so that a few pixels blur together and then resample it smaller to final size. If going 2 to 1 then blur just enough for two pixels to look like a single blob and then make half the size, if going 10 to 1 then blur so that 10 pixels become one blob and then make one tenth the size.

    This form of antialising is known as "super sampling" it is the type also known as "Full Screen Antialiasing" (FSAA) when setting up video cards for games.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Zebra_AA.png 
Views:	409 
Size:	474.9 KB 
ID:	5510  
    Last edited by Redrobes; 07-27-2008 at 11:43 AM.

  2. #2
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,201
    Blog Entries
    8

    Post Resampling

    This means changing the image resolution or the number of pixels. The idea is to preserve the original image in the best possible way. The techniques involved are split depending on whether going up or down.

    Down means taking a big image and making it smaller. Your going to lose information and what we would like to do is lose the least amount. Although all paint packages have the ability to do it a few key presses and one pass they all seem to be universally useless at it. If your going from 1000 to 800 then the best way is to upsample from 1000 to a large multiple of 800 like 3200, or 4000 and then blur and downsample to a 1/4 or 1/5. If changing in much larger ratios like 1000 to 173 or something like that then find a nice multiple of 173 larger than 1000 - i.e. 1730 and upsample to that first then blur 10 pixels into one and then down sample by 1/10th. Many people say - oh always use Bicubic or always use Lanczos but I disagree and I will show the results here with bicubic from 1000 down to 173. Maybe you disagree. Mathematically a sinc resample should be the best possible but I dont think the paint apps implement the full sinc and the windowing makes the resample less effective as more scaling is applied.

    Up means taking a small image and making it bigger and here the paint apps seem to do it as well as can be expected so just picking the right algorithm is all thats needed. Again here, people often say that Bicubic or Lanczos is the best and for most images I would agree but there are exceptions. For general work including maps and photos I think its true and below is a sample sheet.

    Where the situation changes is with noise and ringing and with small scales. If you are resampling from 997 to 1000 or something very very close to what you want then I would use a pixel/point/nearest neighbor based resample because for about 99% of that image the pixels will not change. Below is a set of lines resampled up very slightly.

    You will have to save and zoom up this last image to see whats happening. My monitor makes all three pretty much gray.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Resample_Down.png 
Views:	150 
Size:	155.6 KB 
ID:	5511   Click image for larger version. 

Name:	Resample_Up.png 
Views:	183 
Size:	267.8 KB 
ID:	5512   Click image for larger version. 

Name:	Resample_Close.png 
Views:	124 
Size:	2.8 KB 
ID:	5513  
    Last edited by Redrobes; 07-27-2008 at 11:28 AM.

  3. #3
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,201
    Blog Entries
    8

    Post Resampling and its effect on color

    We can clearly see in many cases of resampling that some pixels are made from the average of several others. This is particularly true in upsample using cubic weighting. We have also said earlier that averaging two pixels in any color space can cause some odd results so this section is some gotchas to look out for and what to do about them. This is an area that I am least familiar with since I only use RGB and dont bother trying to fix these but its worth knowing anyway.

    We noted that a blend from red to blue in RGB color space would give deep mauve - ok but look at this. This is an up sample of some colors which have some issues. Some of the corners here are pure green but the other is red & blue (magenta). When we average these two colors together the red & blue from one image drop halfway and the green from the other drops halfway. End result - all halfway to give mid gray ! Now its worth noting that for resample types that dont allow blends like the nearest neighbor then you dont get the issue. Also, it turns out that if you apply a gamma adjustment to the image, resample with a cubic and the apply and reverse gamma adjustment then the problem gets fixed. I havent fully convinced myself why this is true but I am assured it is.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Resample_Color.png 
Views:	164 
Size:	13.8 KB 
ID:	5514  
    Last edited by Redrobes; 07-27-2008 at 10:57 AM.

  4. #4
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,201
    Blog Entries
    8

    Post Upsampling curvy black and white stuff

    Reserved space - but this one came up recently too.
    EDIT -- actually this comes up a lot and again today so here we go again... how to resample up just B&W stuff.

    First, upsample anyway you like in factors of double (200%) in stages until one more is less than double (say 1.7).
    For each stage double the size of the image which makes it pixellated - a nearest neighbor / pixel resize is fine.
    Next, blur it - preferably using gaussian blur. The amount of blur radius can be experimented with but about a factor of 3 pixels or so.
    Then use contrast to clamp it back to being B&W again. Actually I use about 95% or so not 100% but its up to you. Dont brighten it or darken it when you do it, just up the contrast.
    Keep doing this in stages until the last stage is <200% in which case you might want slightly less blur than usual but not by much.
    Here is the results. Everything is cool except for where there is an acute internal angle where it tends to start filling in depending on the amount of blur used. So less blur helps, but more blur is better to get rid of pixellation. You have to experiment with it.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	BWResample.png 
Views:	122 
Size:	9.0 KB 
ID:	6738  
    Last edited by Redrobes; 09-29-2008 at 05:52 PM.

  5. #5
    Community Leader jfrazierjr's Avatar
    Join Date
    Oct 2007
    Location
    Apex, NC USA
    Posts
    3,057

    Post

    *Head 'sploid*


    Thanks for spending ALL the time to explain all this. Unfortunatly, my head just can't comprehend 90% of it, so I stopped reading at half of the first article. Sooooo I gave you a rating and rep, cause even if it won't help me, I am 100% sure someone will read it and get some help from the work.

    Joe
    My Finished Maps
    Works in Progress(or abandoned tests)
    My Tutorials:
    Explanation of Layer Masks in GIMP
    How to create ISO Mountains in GIMP/PS using the Smudge tool
    ----------------------------------------------------------
    Unless otherwise stated by me in the post, all work is licensed under a Creative Commons Attribution-Noncommercial 3.0 United States License.

  6. #6
    Community Leader Facebook Connected Ascension's Avatar
    Join Date
    Jun 2008
    Location
    St. Charles, Missouri, United States
    Posts
    8,392

    Post

    At least I now comprehend why the anomalies happen even though I need much much more practice in fixing them, as explained here, to be really comfortable with actually doing them and fully understanding them. Thanks Red, very informative.

  7. #7

    Post

    Awesome! Thank you so much, Redrobes.

    Do you happen to be able to explain in general terms how the different resampling algorithms work? I would love to be able to choose one based on an understanding of what it's going to do rather than trying to rely on an imprecise rule of thumb.

    It's so nice to have a programmer around who knows how to talk down to my level!
    Bryan Ray, visual effects artist
    http://www.bryanray.name

  8. #8

    Post

    This turorial is Great, and answers many questions I have had wrt imaging terms. Thank you for posting it.

    While I am still something of a dummy (at least a newbie) when it comes to imaging software in general, I am less of a dummy when it comes to electronics.

    Quote Originally Posted by Redrobes View Post
    it turns out that if you apply a gamma adjustment to the image, resample with a cubic and the apply and reverse gamma adjustment then the problem gets fixed. I havent fully convinced myself why this is true but I am assured it is.
    Since I was also curious about gamma correction, I looked up gamma correction in search engine and found following document:
    http://www.cgsd.com/papers/gamma_intro.html


    Based on this, I think that gamma correction does nothing to the image data itself, it is simply a setting for when image is displayed on monitor. So if you first halve the original value, and later double it for a separate image, the new image ends up with the original value, and at no point is the image data altered by changing the gamma setting.

    I'm not sure if this helps to understand the issue or not. I would need to be a bit more familiar with sampling methods.

    Edit: Warning! The attempt at insight contained in this post, is most likely either dead wrong or completely irrelevant to this topic. Every line after I thank Red Robes for posting this tutorial, should probably be disregarded.
    Last edited by yu gnomi; 07-29-2008 at 04:16 AM.

  9. #9
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,201
    Blog Entries
    8

    Post

    Quote Originally Posted by yu gnomi View Post
    I think that gamma correction does nothing to the image data itself, it is simply a setting for when image is displayed on monitor.
    You can apply color correction and gamma adjustment globally at the video card stage and this would affect everything and not affect the pixel values but to do that color fix up with resampling, you have to apply a gamma function to the pixels first and then apply the stretch and then apply the inverse gamma function. Although in the example provided the first gamma function does nothing because all of the colors start saturated if you tried to do it to a photo then you need that first gamma adjustment if your going to apply an inverse one later. Your right in that gamma adjustments are used to compensate for the effects of monitors - esp CRT type. Why this process works to fix this problem I am not sure. I am not sure if a different compensation curve would also work.

  10. #10

    Post

    http://www.ononesoftware.com/product...e_fractals.php

    This is a link to program that does an incredible job at up scaling images

    I can not tell you how much I wish I had this program at my current job

    I am sick of getting 15 kb .jpg logo files

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •