The main function of the GrabCut tool is to extract objects that are placed in the foreground of an image. It is based on a graph cut algorithm, and as such, it is not “intelligent” in the sense that our AI tools object detection and instance segmentation are. However, GrabCut can in many cases give you good instance segmentation results out of the box, especially in cases where there’s a high contrast between foreground and background. For those times when grab-cut selection is not 100% what you aim for, you can also use the tool’s interactive brushes to add or subtract from the selection.
The tool can be accessed by pressingin the toolbar or by pressing “G”.
To use this tool you first need to select an area to which the underlying algorithm will be applied. You can select the area by left-clicking once to place the first corner for the grab-cut area. The rest of the image will now become darker. When moving your mouse pointer, you will see that a lighter area is created from where you placed your first corner and where your mouse pointer is. This is your potential grab-cut area. When you are satisfied with the grab-cut area, left-click again.
Now that you have given the grab-cut tool an area to work in it will try to extract objects from the foreground. This might take a second or two, then you should see one or more red selection areas.
These are potential objects that the algorithm found. If you are happy with the selections, you can convert them to objects. Otherwise, you can manipulate the selection by using strokes.
If you are unhappy with your selection and want to start over, you can press “esc”.
When you are satisfied with your selection you can turn it into an object by pressing “enter”, or by clicking the “convert” button in the tool settings toolbar.
When you want to add or subtract something from the GrabCuts current selection, you can do so by the help of strokes. Strokes is a way for you as a user to paint areas which you want to include or exclude from the selection. Unlike other, similar tools that you might be familiar with, you don’t have to paint exactly the area you want to add or subtract. Just painting the outer edges of it will in many cases be enough. By doing this, the algorithm can do most of the heavy lifting.
There are two types of strokes available in Hasty.
We have positive strokes, which add to the selection. By painting something with positive strokes, you are telling the underlying algorithm that this part of the image belongs to the already existing selection. Positive strokes can be differentiated from negative ones in that they are red.
Then, we have negative strokes. These remove painted areas from the current selection. When you paint something with negative strokes, you are telling the algorithm that this part of the image is not interesting for you. Negative strokes can be differentiated from positive ones in that they are blue.
Positive strokes are the default for the grab-cut tool. However, if you used negative strokes you can reset back to positive strokes either by pressing in the tool settings bar or by pressing “shift”.
Positive strokes are applied by drawing the mouse pointer over the desired area while pressing and holding the left mouse button.
Negative strokes can be selected by pressing in the tool settings bar or by pressing “alt”.
Negative strokes are applied by drawing the mouse pointer over the desired area while pressing and holding the left mouse button.
To speed up the GrabCut process, there is also an automatic mode. When grab-cut tool is in auto mode, the type of stroke select will switch depending on if the mouse pointer is inside an existing selection, or if it is outside. If it is inside, negative strokes will be selected, so anything you paint will be subtracted. If it is outside, positive strokes will be selected, so anything you paint will be added.
The auto mode can be switch on/off by pressing the “auto” checkbox in the tool settings bar or by pressing “U”.
You can change the radius (i.e circular size) of a stroke in two ways. With the mouse, you drag the slider in the tool settings bar to adjust the value. With the keyboard, you can press “,” to reduce the value, and “.” to increase it.
If you managed to misplace a stroke but don’t want to start over from the beginning, you can use the eraser. The eraser allows you to erase strokes by “painting” over them. This is easily done by left-clicking at the desired location in the image.
The eraser can be selected by selecting eraser in the dropdown menu or by pressing “E”.