Software Engineering, Web Development and 3D Design

Blender Calculator

Here is a secret Blender feature. A calculator. No, there is no calculator window and no, I am not talking about the Interactive Python Console. This secret Blender feature can be found in every numeric input box and every slider button. Every input box can solve arithmetic problems just by entering in the equation and pressing enter. Simply click on the box and enter a problem like .8/3 and press enter.

This may seem like a worthless feature. A calculator? Why would I need that? If you have never used this feature it may seem pointless. However, this feature can dramatically speed up your workflow and once you have used this feature you won’t be able to live with out it! Here’s an example.

Say you are working with a material with a reflection value of .941 and you figure it is about one-tenth too reflective. Now you can guess a value. Somewhere ‘round .85, right? Or you can use the calculator. All you do is just left click on the slider, and then to the right of the number left click and enter the multiplication symbol * and then enter .9 and press enter. That’s it! You have now just lowered the reflection value by exactly 10%.


It can even solve algebraic equations like this: (I have no clue why you would need to do this.)

Algebra equation in inputbox

The Blender “calculator” will always round it’s answer to the nearest one-thousandth (unless your dealing with an integer value like the frame number, in which case it will be rounded to the nearest integer) and the results will not exceed the minimum and maximum values of the input box. Usually 1 is the maximum value and 0 is the minimum ( in some case there are no min’ and max’ values).

Hopefully, you can see the advantages to using mathematical operators in Blender’s “calculator” to perform quick, accurate changes to the value of a parameter. Once you get use to it, it will save a significant amount of time and greatly speed up your workflow. It eliminates the need of a calculator for complex problems.

Premutliplied Alpha in GIMP

Watch Premulitplied Alpha in GIMP
This tutorial is 3.5 minutes long.

If you have ever rendered an image in Blender and decided to do the final composition in GIMP you may have discovered that when you placed your foreground layer over the background layer a nice fuzzy black line (fringe) appeared around the edges of your foreground objects. This is because you were using premultiplied alpha in Blender. GIMP does not have a way to handle premultiplied alpha and it causes the foreground layer to have fringe around the edges. I have spent hours trying to get rid of black fringe on images with premultiplied alpha in GIMP. In this tutorial I will share a solution of removing the fringe caused by premultiplied alpha.

Here I have the foreground image with a white monkey on a transparent premultiplied alpha background and a white background image.

foreground_layer background layer

First load both the foreground and background layers into GIMP, making sure the background layer is on the bottom. You can see here the black fringe clearly visible against the white background.

fringe closeup

Now hide the background layer and view the channels. Select the alpha channel and drag it down to the box below. You now should have a copy of the alpha channel. Before you do the next step switch the background and the foreground colors so that the background color is black, as shown.

background and foreground colors

In the layer tab, right click on the foreground layer and click “Remove Alpha Channel”. Now add a layer between the background and the foreground layers and fill it with black. Now right click on the middle layer and select “Add Layer Mask”. A dialog will come up with several different masking options, choose “Channel” and select the layer we just copied from the drop-down menu. Now make all the layers visible. Select the foreground layer and set the blending mode to “Add”. Your setup should look like this.

final layer setup

Now you will still probably have some fringe, so click on the middle layer’s mask and use the Curves tool to remove the fringe. Click on center of the curve and pull it down some until you don’t see any fringe. If you pull it down too far you will see white fringe.

curve setting

That’s It! you should now have a fringe free white foreground on a white background!

fringe free border

Autotracing Is Not for Every Image

Autotracers are great time-saving tools that can save you hours of monotonous hand tracing, but they are often misused. In this tutorial we will look at two real world autotracing examples using Inkscapes built-in autotracer (also known as a bitmap tracer). Our goal in all of these examples is to create a clean black and white vector. You will see that autotracers are very limited in what they can do.

Tracing Basics

Before we start looking at examples let’s first get familiar with Inkscapes autotracer. Open up Inkscape, click on the “Path” menu and select “Trace Bitmap”.A sidebar will appear on the right. On the right of the dialog there is a preview window, if you select a bitmap and click the Preview button it will show a preview of what the tracing will look like. This is very useful when you are tracing complicated images that take along time to trace.

On the left there are different tracing methods, the top three create only a single path. There are several different ways of tracing a bitmap. The first option, Brightness Cutoff, works similar to GIMP’s Threshold tool. It creates only one a black path of the areas of the image that are darker than the threshold value. By adjusting the Threshold value you can control what is considered black and what is not. The second tool is Edge Detection. This tool uses an algorithm to determine what parts of the image are edges and what are not. If part of the image is considered an edge it becomes part of the black path. By adjusting the threshold value you can control what is considered an edge and what is not. Higher value mean less of the image is consider an edge. The third option is Color Quantization this option creates adds a path where the colors in the image change. By adjusting the the Color value you control how many different colors the image should be considered. The bigger the color value the more outlines it creates.

The next three options create multiple paths. The first method for creating multiple paths is Brightness Steps. This divides the image into different increments of brightness and covers each one with a path of the appropriate brightness. The next option is Colors, this option creates a path for each area color. The third option is Grays, this option divides the image into different increments of brightness and covers each one with a path of the appropriate color, this option works very similar to the Brightness Steps. By adjusting the amount of scans you control the how many increments of brightness there are.

There are several more miscellaneous options for tracing. There is the Smooth option that smooths the curves after being traced. The Stack Scans options stacks the brightest paths over the darker ones, as opposed to cutting out the darker paths. The Remove Background option removes the lowest, or darkest, scan from the tracing. The Invert image checkbox inverts the image before being traced, I bet your glad I explained that one!

Now if you click on the Options tab on the top you will see three more options. Suppress Speckles, this option suppresses speckles in the bitmap by ignoring small details in the tracing. The bigger the Size value the smoother the tracing (and the less detail). The second option is Smooth Corners, this option smooths the sharp corners of the path. A higher threshold means smoother corners. The last option is Optimize Paths, this option uses an algorithm to create the paths with the least amount of nodes necessary, i.e. cleaner paths. Always leave this option on if you are not going to manually edit the path later.

There are no perfect settings. Each image you trace will need slightly different settings based on the quality and type of image.

Tracing a Photograph

Mouse on desk

Here we have a relatively high contrast image with fairly clean lines. Our goal is to make a black and white tracing of the mouse and cord. It seems like Autotracing is the way to go. So lets autotrace this image and see what happens. Import the image into to Inkscape and click on the path menu and select “Trace Bitmap”(Note: the image being traced is a higher resolution than the one you see above). Select the image and click the preview button in the Autotrace dialog. I chose Brightness Cutoff as scanning method. Adjust the threshold value up or down if necessary and click the preview button to see the results. Once you have got it the way you want it click ok. Then delete the image. Now let’s zoom in and inspect the path. Zooming in to where the button on the mouse meets the front of the mouse we see a weird outline. Not only does this not look correct it also is impossible to edit.

Mouse tracing Nodes on Path

A path should have relatively few control points and be fairly simple. Lets view the control points or nodes as they are called in Inkscape. Click on the edit tool and then select the path to see the nodes. There are so many nodes the path impossible see, let alone edit!


This image cannot be traced correctly by the autotracer. This is a relatively simple image that will only take a few minutes to manual trace. If you tried to clean up the autotraced path you would spend more time cleaning up the path than you would just tracing it manually, and you would end up with a poorly traced path. Manually trace this image.

Tracing a 3D Image


A 3D image like this one is not a whole lot different than a photograph. The only major difference is there is less noise and the image is a lower resolution. Due to the low amount of contrast in this image we will not be able to use Brightness Cutoff, in fact we will not be able to use any of the single path tracing options. I found that for this image that the Colors and Grays options worked the best. Of course our goal was to create a black and white vector image, so I had to do a little manual editing of the paths to make them black and white.

Badminton Path

Now lets zoom in and inspect the path. The path is fairly accurate and has a good amount of detail, there are no funny outlines like we saw in the photograph and the outline is easy to recognize. Now let’s select the edit tool and click on the path. The path is covered in nodes and is way too cluttered. It is nearly impossible to edit and is not much better than the tracing of the photograph.

Path Nodes


The best way to trace this image would be to do it manually, but with all the detail it would take hours. You would probably be better off if you just spent an hour or so cleaning up the autotrace manually. Either way you could not use the autotrace alone.

The Best Way to approach Tracing

I feel that the best way to approch tracing an image is to first try autotracing (or just previewing it if you have detailed image) with all the different different tracing methods. If you find one that gives fairly acceptable results go with autotracing and do a little cleaning up of the nodes manually. If you find no acceptable tracing method, manually trace the image yourself. What ever method you choose always check the path for excess nodes and do editing if necessary.** Manually tracing always produces better results.** Do it if you can afford to spend a couple hours tracing!