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,221
    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 Images Attached Images
    Last edited by Redrobes; 09-29-2008 at 05:52 PM.

  2. #2
    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.

  3. #3
    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.

  4. #4

    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

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

    Post

    Quote Originally Posted by Midgardsormr View Post
    Do you happen to be able to explain in general terms how the different resampling algorithms work?
    Ok, first let me say that all of these resamples work separately in X and Y so think of it doing a stretch in width followed by a stretch in height and the same process is applied in each case. So we can talk about just a stretch in one direction. Often the PC will do both at once for performance reasons tho.

    Well the first is the simplest and quickest and you have seen that it often produces the worst results but can be the best in certain circumstances and that is the point sampled. Often called nearest neighbor or sometimes a pixel resize.

    Say your going up from 100 pixels to 140 pixel image - thats a multiply by 1.4. What the PC does is loop over the 140 pixels and divide the pixel number by 1.4 and then look up the nearest pixel in the original image and use that. What that means also is that occasionally it will hit the same original pixel a few times duplicating the result and you can see that in the 997 to 1000 stretch example. Occasionally theres a double black or double white line. When you use this stretch the output is always blocky in appearance.

    Linear resampling takes the same approach and runs over the 140 pixels and divides the position by 1.4 so that it will give a value of say 86.3. What the PC does is look at pixels 86 and 87 and take 70% of 86 and 30% of 87 and adds them up. Its a straight up linear interpolation.

    For cubic its harder to describe but it does the same loop and get the same 86.3 value. Now it looks at 4 pixels. 85,86,87, and 88. It applies a cubic weighting function over the top of the four and adds them up. The cubic curve in the middle is like an S shape so that its a smoother blend at the known source pixels.

    Lanczos is a windowed sinc function. That means its a sinc which is just sin(x) / x but restricted to a window of either 5 or 7 pixels (either side) depending on whether your using Lanczos5 or Lanczos7. It just so happens (lots of math) that a sinc function is the perfect function to use for resampling but that a sinc function goes on and on and never ends so they suppress it inside a smaller window. Anyway I think Lanczos5 will look at 9 pixels, multiply with a windowed sinc function and then add them all up.

    Its called bilinear, and bicubic because the function is applied in two directions at once so whats actually happening is that a patch of pixels are being processed at once.

    There are more types but they are all much the same style. Look at a patch of source pixels and interpolate a new destination pixel based on that patch. You can get better image results the more you know about what was going on in the location around the source.

    Edit -- just fact checking, it seems the 5 or 7 is not either side but the total amount of points so either 2 or 3 either side.
    Last edited by Redrobes; 07-28-2008 at 10:25 AM.

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
  •