Con
October 14th, 2009, 02:41 AM
Masked Surface Blur Sharpening
A problem often encountered is blurriness of images when they're scaled up many times their original size. While it's impossible to create more detail out of the blurriness, we can try to sharpen edges as an illusion. The surface blur filter (filter/blur/surface blur) groups sections of the image within a certain threshold, then blurs the section within its borders with a specified blur radius. The advantage of this filter is that it creates hard edges from blurry ones, but the disadvantage is that this filter works with one specified threshold, and subtle details and edges can be lost. While blurry and compressed once-vector images can usually benefit from a single application of the filter, the method breaks down on more complex images with varying edge thresholds, such as photographs.
Consider this tulip blown up many times its original size:
http://con.modacity.net/tutorial/original.jpg
The edges are no longer sharp and appear both blurred and jagged.
Applying a surface blur yields the following result:
http://con.modacity.net/tutorial/surface%20blur%2025,%2050.jpg
As you can see, I was able to adjust the parameters to sharpen the top of the tulip, but you can see the areas where details fell within the threshold and were blurred to nothing.
Instead, apply the surface blur on its own layer and give that layer a mask:
http://con.modacity.net/tutorial/createmask.jpg
Create a layer mask (1)
Select the layer mask (2)
Set foreground colour to black (D)
Use the paint bucket (G) to fill the mask with black
Use a soft brush (B) and set foreground to white (X)
Draw over the edges that I pointed to with green arrows. There's no use using the red ones.
You should now have a black layer mask with white lines on it. Some edges will be sharp, while others will remain blurry:
http://con.modacity.net/tutorial/stufftodo.jpg
It's a good start, but we need to fix those other edges.
Duplicate (Ctrl + J) your original blown up layer.
Apply a surface blur to this new layer, using different parameters this time:
http://con.modacity.net/tutorial/afterstuff.jpg
The goal here is to bring out other edges that the first surface blur missed. Just like before, we're going to give this new layer a mask so only these good edges show up.
Repeat until you're happy with it:
http://con.modacity.net/tutorial/final.jpg
Not the best, and it could use a little more work, but it's a great improvement over both the blown up original and the original with a surface blur only. This is also a pretty bad case, the source image is quite small:
http://pictopia.com/pub2/images/photo-tulips.png
The Lazy Method
If the scene is pretty big and has a lot of edges, or you're lazy.
http://con.modacity.net/tutorial/tut/worst.jpg
Fuckin thing sucks.
http://con.modacity.net/tutorial/tut/2.jpg
Again, applying a surface blur gets rid of certain details like the splashes, but it helps to sharpen the high contrast edges. Like in the previous example, we're going to use a mask... but this time we're going to make the mask differently.
Duplicate your original base layer and give it a surface blur that brings detail to key edges
Duplicate the base layer again, only this time apply the find edges filter (filter/stylize/find edges)
Desaturate this layer (Ctrl + Shift + U)
Invert this layer (Ctrl + I)
You should have something like this:
http://con.modacity.net/tutorial/tut/3.jpg
In case you're wondering, the faint grid is caused by the block artifacts in JPEG compression.
Now adjust the levels (Ctrl + L) of this layer:
http://con.modacity.net/tutorial/tut/5.jpg
Apply a gaussian blur (filters/blur/gaussian blur) that blends the solid white areas into their surroundings, but not too much. Finally, adjust the exposure (image/adjustments/exposure) so the centers of these lines are completely white.
The next step is to switch over into the channels window and Ctrl + click the RGB icon. This will convert the image intensity into a selection; in other words, bright areas will be selected:
http://con.modacity.net/tutorial/tut/mask.jpg
Now with this selection made, create a layer mask on the surface blur layer.
Here's a comparison:
http://con.modacity.net/tutorial/tut/lazyfinal.jpg
My method keeps the low contrast splashes in the image, but also sharpens the edges. Unfortunately, the JPEG artifacts are only slightly diminished. Removing them would require the combination of this quick method with the previous.
Removing Aliasing
The above method for sharpening blurry images can also be used in removing aliasing from game screenshots. We can use the fact that the surface blur filter anti-aliases its regions to our advantage. This is not a quick process, and the time it takes depends on the desired quality and the image itself.
http://con.modacity.net/tutorial/aa/32screenshot00.jpg
You can easily see the aliasing here, so what we can do is duplicate the source layer and apply a gaussian blur. The radius of the blur will be just enough to remove any hint of "steps" from the edges.
Now, work with this blurred layer as if it were a blown up image using the above tutorial on masked surface blur sharpening. The more time you spend specializing for each edge threshold the better. For the purpose of this tutorial, I used one surface blurred layer:
http://con.modacity.net/tutorial/aa/2.jpg
And just like the above tutorial, we'll create a mask for this layer so it only shows up where we want the anti-aliasing. I don't recommend using the quick and lazy method, but rather taking a small brush (~3 px) and drawing the mask yourself. Once you're done, you can expect something like this:
http://con.modacity.net/tutorial/aa/3.jpg
A problem often encountered is blurriness of images when they're scaled up many times their original size. While it's impossible to create more detail out of the blurriness, we can try to sharpen edges as an illusion. The surface blur filter (filter/blur/surface blur) groups sections of the image within a certain threshold, then blurs the section within its borders with a specified blur radius. The advantage of this filter is that it creates hard edges from blurry ones, but the disadvantage is that this filter works with one specified threshold, and subtle details and edges can be lost. While blurry and compressed once-vector images can usually benefit from a single application of the filter, the method breaks down on more complex images with varying edge thresholds, such as photographs.
Consider this tulip blown up many times its original size:
http://con.modacity.net/tutorial/original.jpg
The edges are no longer sharp and appear both blurred and jagged.
Applying a surface blur yields the following result:
http://con.modacity.net/tutorial/surface%20blur%2025,%2050.jpg
As you can see, I was able to adjust the parameters to sharpen the top of the tulip, but you can see the areas where details fell within the threshold and were blurred to nothing.
Instead, apply the surface blur on its own layer and give that layer a mask:
http://con.modacity.net/tutorial/createmask.jpg
Create a layer mask (1)
Select the layer mask (2)
Set foreground colour to black (D)
Use the paint bucket (G) to fill the mask with black
Use a soft brush (B) and set foreground to white (X)
Draw over the edges that I pointed to with green arrows. There's no use using the red ones.
You should now have a black layer mask with white lines on it. Some edges will be sharp, while others will remain blurry:
http://con.modacity.net/tutorial/stufftodo.jpg
It's a good start, but we need to fix those other edges.
Duplicate (Ctrl + J) your original blown up layer.
Apply a surface blur to this new layer, using different parameters this time:
http://con.modacity.net/tutorial/afterstuff.jpg
The goal here is to bring out other edges that the first surface blur missed. Just like before, we're going to give this new layer a mask so only these good edges show up.
Repeat until you're happy with it:
http://con.modacity.net/tutorial/final.jpg
Not the best, and it could use a little more work, but it's a great improvement over both the blown up original and the original with a surface blur only. This is also a pretty bad case, the source image is quite small:
http://pictopia.com/pub2/images/photo-tulips.png
The Lazy Method
If the scene is pretty big and has a lot of edges, or you're lazy.
http://con.modacity.net/tutorial/tut/worst.jpg
Fuckin thing sucks.
http://con.modacity.net/tutorial/tut/2.jpg
Again, applying a surface blur gets rid of certain details like the splashes, but it helps to sharpen the high contrast edges. Like in the previous example, we're going to use a mask... but this time we're going to make the mask differently.
Duplicate your original base layer and give it a surface blur that brings detail to key edges
Duplicate the base layer again, only this time apply the find edges filter (filter/stylize/find edges)
Desaturate this layer (Ctrl + Shift + U)
Invert this layer (Ctrl + I)
You should have something like this:
http://con.modacity.net/tutorial/tut/3.jpg
In case you're wondering, the faint grid is caused by the block artifacts in JPEG compression.
Now adjust the levels (Ctrl + L) of this layer:
http://con.modacity.net/tutorial/tut/5.jpg
Apply a gaussian blur (filters/blur/gaussian blur) that blends the solid white areas into their surroundings, but not too much. Finally, adjust the exposure (image/adjustments/exposure) so the centers of these lines are completely white.
The next step is to switch over into the channels window and Ctrl + click the RGB icon. This will convert the image intensity into a selection; in other words, bright areas will be selected:
http://con.modacity.net/tutorial/tut/mask.jpg
Now with this selection made, create a layer mask on the surface blur layer.
Here's a comparison:
http://con.modacity.net/tutorial/tut/lazyfinal.jpg
My method keeps the low contrast splashes in the image, but also sharpens the edges. Unfortunately, the JPEG artifacts are only slightly diminished. Removing them would require the combination of this quick method with the previous.
Removing Aliasing
The above method for sharpening blurry images can also be used in removing aliasing from game screenshots. We can use the fact that the surface blur filter anti-aliases its regions to our advantage. This is not a quick process, and the time it takes depends on the desired quality and the image itself.
http://con.modacity.net/tutorial/aa/32screenshot00.jpg
You can easily see the aliasing here, so what we can do is duplicate the source layer and apply a gaussian blur. The radius of the blur will be just enough to remove any hint of "steps" from the edges.
Now, work with this blurred layer as if it were a blown up image using the above tutorial on masked surface blur sharpening. The more time you spend specializing for each edge threshold the better. For the purpose of this tutorial, I used one surface blurred layer:
http://con.modacity.net/tutorial/aa/2.jpg
And just like the above tutorial, we'll create a mask for this layer so it only shows up where we want the anti-aliasing. I don't recommend using the quick and lazy method, but rather taking a small brush (~3 px) and drawing the mask yourself. Once you're done, you can expect something like this:
http://con.modacity.net/tutorial/aa/3.jpg