Gino D's GIMP Scripts:
This script enables you to remove the holes of a selection, if by hole we mean every unselected or partially selected area of the image which is surrounded by a fully selected area.
In order to understand how the script works, we have to focus on the selection mask, that is the channel related to the selection (you can view it by either activating the Quick Mask or saving the selection as a channel). Referring to this mask, the script eliminates every area that is composed from non-white pixels and is completely enclosed by a fence of white pixels; the elimination consists in filling such areas of the selection mask with white, so that the corresponding holes of the selection will disappear. Therefore, a black and gray region of the selection mask which is contiguous to the image's borders across at least one pixel is not supposed to be a hole, because not all of its edges are adjacent to white pixels.
Activating the script
Once installed, you can launch this script from the image menubar through
"Select -> Remove Holes...".
- Normalize initial selection
When this box is checked, the contrast of the selection mask will be initially stretched, causing the lightest pixels to become white and the darkest pixels to become black; this way it is often possible to remove some holes even from selections whose masks are devoid of white pixels, which are essential for circumscribing any possible hole. The following illustration shows how this initial improvement helps at least to eliminate the holes in the letters G and M, which could not be removed otherwise.
- Apply threshold to initial selection
By activating this checkbox, the selection mask will be initially transformed into a black and white channel without anti-aliasing. This feature is useful to boost the action of removal, especially when the selection is provided with soft borders and blurred zones, as shown in the illustration below.
- White threshold
Defines the extent of the white areas produced by checking the “Apply threshold to initial selection” box.
Values vary within a range of 0 to 255.
- Feather resultant selection
When this box is checked, it is possible to reduce the sharpness of the borders of the eventual selection.
- Radius of feather (in pixels)
Allows you to set the amount of blur affecting the selection borders when the "Feather resultant selection" checkbox is activated.
Values vary within a range of 0 to 32767.