Alpha channel posterization in Paint .NET

Handy guides on how to do things, written by users for users.

Moderators: GZDoom Developers, Raze Developers

Forum rules
Please don't start threads here asking for help. This forum is not for requesting guides, only for posting them. If you need help, the Editing forum is for you.
User avatar
Koto
Posts: 156
Joined: Fri Aug 09, 2013 9:12 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: Southamerican sacrifice zone (Chile)

Alpha channel posterization in Paint .NET

Post by Koto »

For a long time I was looking for if it was possible to handle antialiasing levels in images, I mean, if it was possible to determine the level of it in order to have oblique lines without so many levels of transparency in the outline. And unfortunately I couldn't come up with a solution, until I discovered an option in one of the many image editing software I have on my PC.

This program is Paint .NET which, if you're not familiar with it, is a freeware exclusively for Windows with a very similar scheme to Photoshop, Gimp, or Krita. Which has, among many features that make it attractive to use, a much more robust posterization system than the listing ones.

While most offer to posterize the image simply with a slider that indicates the general level of the image, in Paint .NET we have 4 bars to set the level of posterization of an image: The red channel, the green channel, the blue channel, and the alpha.

This last channel is super useful for us when it comes to putting texts, symbols, or other drawings on our textures or sprites, so as not to use only opaque colors, or kill hours doing a decent antialiasing by hand.

For this tutorial, we are going to overlay an image with the alpha posterized on another image, which is readable and looks good with the vector or sector that our texture uses on the map. Let's go then.


1- Work area Preparation.

We'll open Paint .NET in addition to our regular image-editing software, in case you're unfamiliar with that program. In my case it's Krita, but any other can be used.


2- Image preparation.
:geek: (If instead of an image you want to work with text, skip to point 4)

For this exercise, we are going to download a PNG image with a transparent background from here. It's important that the background is transparent, otherwise the tutorial will not work for you.

The size may vary, but the ideal is that the image used should have a good resolution so as not to lose so much quality when resizing.

We open the image in Paint .NET from “File > Open…”, typing “Ctrl+O”, or simply dragging the image onto the program screen. In this last item, if we have more than one file open, they will offer us to open the image independently, or add it as a layer to the active file. Ideally, select the first.
Spoiler: Image open in Paint .NET
As the downloaded image is black, we invert the color to make it white (Ctrl+Shift+I). This is completely optional, in fact, you can color the image to your liking.


3- Resizing images with transparent background.

To optimally reduce the size of the image, we can go to “Image > Resize…” or type “Ctrl+R”, and this window will open with the options available to regulate the dimensions of our image.
Spoiler: Resize window
So that the image is not distorted, it is advisable to activate the "Maintain aspect ratio" box, and in terms of resampling, we can use any that guarantees a good definition when shrinking the image. In this case we will use bicubic sampling, and this is the result obtained by reducing the image to 64 pixels wide.
Spoiler: Resized image
It's recommended to add a background layer with a flat color that contrasts with the image we want to adjust.


4- Text preparation.
:geek: (If you come from editing an image, skip to the next step)

As for using texts, the steps are reduced, since we don't have to readjust anything in between. To start, I will create a file, with a 64 pixel square canvas, which will have a background of a flat color to suit the user. I'll paint it black.
Spoiler: Our Workspace for texts
The size of the canvas depends on the dimensions that we want to use to add text to a texture. So it can also help us to put our reference texture in which we want to put our text.

We add a new layer, select the Text tool (T), choose a color that contrasts with the background, put the cursor somewhere on the layer and write whatever we want.
Spoiler: Our text
After this, we can define the text format, the font, and the word size. And when we're ready, we press “Enter” to confirm our changes.


5- Alpha channel posterization.

We come to the most important point of the tutorial, and it's quite simple. Well then, we go to “Settings> Posterize...” (Ctrl+Shift+P), and the following menu will be displayed, where we deactivate everything except the alpha channel.
Spoiler: Posterize window
Moving the slider all the way to the left, we can see that the minimum level is 2, and the image will look to us as if we had adjusted the image with the nearest sampling. But if we start to increase the alpha level, we can see how the antialiasing gradually appears, leaving it at an acceptable level, in my case, 4.


6- Importing the result.

Once we have our new layer ready, we select it and copy directly (Ctrl+C), and we return to our usual software, pasting the result in the same way (Ctrl+V).

In some programs we will have to do additional steps such as selecting the color scheme, or if we want to paste it as a layer or file. The ideal is to paste it as a new layer, or if it is pasted on a layer that already has an image, we must make sure that we have an empty layer to paste our result. In addition to keeping the same color scheme in our files.

And this is what our result looks like in our workspace. You can see on one side the symbol and text by themselves, in the middle you can see the layers on top of the BRICK5 texture, and on the right we can see the same case, but the imported layers are blended into the texture (using Soft Light (IFS Illusions), and duplicating each layer so it can be noticed).
Spoiler: And we're done

7- Conclusion.

Hopefully in the future, the rest of the image editing tools will have posterization as advanced as in Paint .NET. Until then, unless you do everything in that program, if we want a quick method of limiting alpha channel levels, I can recommend this method.

I hope this tutorial will help you to make good textures and/or sprites without making them so blurry.

Adiós.
User avatar
RKD
Posts: 148
Joined: Sat Mar 19, 2022 9:52 am
Location: Argentina

Re: Alpha channel posterization in Paint .NET

Post by RKD »

Bookmarking this. You never know when it can come in handy.

Re piola, wn
User avatar
Caligari87
Admin
Posts: 6191
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him

Re: Alpha channel posterization in Paint .NET

Post by Caligari87 »

A novel solution, for sure!

I think what you're basically going for in this case is alpha channel contrast. This can be accomplished in GIMP with use of the levels tool, like so:


Another option if you don't have an alpha channel, is Color To Alpha, which allows setting thresholds for the transition between the intended color and anything else:


8-)
User avatar
Darkcrafter
Posts: 571
Joined: Sat Sep 23, 2017 8:42 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support

Re: Alpha channel posterization in Paint .NET

Post by Darkcrafter »

A nice tutorial, there must be a way to automate it all but excuse my, why would you need to posterize the ALPHA channel? Is it like GZDoom can benefit from that somehow?

Return to “Tutorials”