Figure 1. Main program window with test_he.jpg and a vector layer
Raster image or bitmap (image), raster, (digital) photo are considered
here as synonyms and mean an array of binary values having such attributes as width
and height.
Gray scale or halftone image is the image with only one channel (intensity)
with values distributed from zero to max value.
Image depth: the number of bits per pixel. An image with a higher image depth
has a greater number of possible intensity values, which improves the quality of
processing.
Binary image or black and white, binary, mask, duotone, bitone, boolean
are raster images with only two intensity values - zero and maximum (e.g. 255 for
8-bit image).
Vectors or contours, vector layer, drawing layer are considered here
as synonyms and mean the data that describes geometric figures and their attributes.
Text labels are also included.
In the program all contours are presented as poly lines with two attributes - thickness
and color.
Tracing or vectorization, contour producing are considered here as
synonyms and mean the process of making contours from a black and white image with
edges.
To get started with the program an image should be opened by the Image/Open button. An image could be in the JPEG, TIF, BMP, PNG or GIF formats, true color 3 channels, or gray scale with 8 or 16-bit (for gray scale) unsigned integer depth. Many images could be loaded at once by the same button with multiple selection (using Ctrl key). To switch between images use the Layers Tree on the Contours tab. Close button on the top right side of the main window closes current image and all the vector layers assiciated with it. The pull down list near Image/Open button is a short cut for a last loaded image.
A vector layer could be loaded on top of a raster image by the Contours/Open button from a YML or DXF file. To toggle vector layer visibility select the check box near its name in the Layers Tree. [X] button in this tab is for closing currently selected vector layer. The vector layers are bound to the correspondent background raster images.
The View tab and the Edit tab are at the top line of the main window. The View tab is for controlling viewing parameters such as magnification and placing a text label. To zoom in/out - click small buttons [+][-] in this tab. There are also Fit to window, zoom to All and 1/1 zoom scale buttons. The Print and Clip button are for printing/clipping the view content. To cut off unnecessary parts of an image use the Crop button. The cropping could be done manually by Pointing coordinates of a cropping rectangle or mannualy typing its top-left corner coordinates, width, height in the fields next to the button and then hit Enter in the last edit field. To place a Label with a text - type in the text in the Label edit field, then push Place button near the field and point and click appropriate place on a canvas. To delete a label use Delete button on the Label group.
The buttons on the Bitmap tab perform color or gray scale image processing. Most of operations (excluding Invert, ToGray and Normal) allow real time tuning of an operation strength parameter. When tuned, the Left mouse click accepts an operation, the Right click is for cancel. Sometimes, micro photos or scanned images need Radial or Linear shading correction. To do linear correction, select proper direction by clicking two points on an image. For radial correction the only operation strength is needed. After an image is made uniform, smooth it by Gaussian Smooth. Use Contrast stretch and Brightness adjustment for better visual perception. Sometimes, intensity Normalization could help to estimate bad lighting conditions. To reduce intensity levels Posterize an image. Select foreground color with the Color selection tools. The first button Color-> allows picking selection color from an image, the other button Color? brings the predefined colors selection dialog. Use the FloodFill button for filling connected regions of selected intensities with the white color. Point a seed point first. Then select a range of intensities to fill. Convert an image into gray scale by the ToGray button. And finally use the Threshold or Adaptive threshold buttons to produce a binary image from a gray scale. Hist.On check box on this tab is used to render three histograms for each color channel and another histogram for intensity. There is also color convertion tools. They convert an image from one color space to another.
Mathematical morphology operations could be performed on a color or gray scale image, but typically they are used to correct binary images before tracing. To complete a blob the MorphOp button with Close option is used. To separate two blobs in touch the Open option for this button is used. The Erosion or Dilation options of the MorphOp button are used to eliminate pitting noise and other small objects. The Tracing operation is the last raster processing step. There is the check box Extern near the Trace button. This box is important if we are looking only for external objects, not their internal structure. But we could be disturbed if an image has a border and we produce only a border contour. To get rid of this border, use the Border button. After that, make Canny Edge (optional) and hit the Trace. The common fault is the bad blob separation. To handle it, try the Map button that converts a binary image back to gray scale one that would have more smooth gradients. Then on the Bitmap tab, more carrefully select Threshold to do right blob separation.
The objects boundaries are exactly represent foreground objects if they are precisely distinct from uniform background. The program shows the histogram of several geometric values of the contours produced. These four values are the Area, the perimeter(Len), the nonconvexity Defect (the difference of the contour and its convex hull areas) and the Eccentricity (It is 0 for a perfectly round object and 1 for a line shaped object). Contours could be Filtered Out/b> by the Range button and the checkbox nearby to select a part (smaller or greater) to preserve.
The Edit tab is used for manual contours drawing and edition. The PolyLine button is used to draw open polyline contour. When drawing - click Right mouse button to stop. The Polygon button is used to draw closed polyline contour. Again, Right click is the stopper. The Rect button interactively draws a rectangle by selecting upper left and lower right corners. The Oval tool places ellipses of selected size into a canvas point selected. When a new contour is created the New option selected by the check box will help to place this contour into a new layer or to add into active one. The Delete button is for removing selected contour. The Transform Select tool is used for moving/rotating a contour selected. The mode of transformation is chosen by the pull down list nearby (Rotate, Rotat90, Move)). The contour outline color and width are chosen from the pull down list and up-down arrow control at the Edit tab. Text labels are drawing using a color selected from the pull down list at the View tab.
The Script tab is used for managing script facilities of the program. The
script is a text string used for recording each important action a user performs.
By the Save button on this tab current script is saved into a text file in
Forth like syntax. The current working folder is set up by the Folder
button. This folder is scanned for the script files available and their names are
inserted into the pull down list. This list is used to launch scripts selected.
The current script listing appears in the multi line read only edit field below.
The single line edit field on top of the read only field could be used to type a
command. To execute this command - hit Enter. Consult Forth programming
language syntax please, before experimenting with the scripts. In addition to the
common Forth commands, the program makes the following data read/writing,
layers housekeeping drawing and image processing commands available: (OpenCV
Forth)
loadimage saveimage loadyml saveyml loaddxf
chnglayer chngvec delvec dellayer delcont colorsel veccolor
line oval rectangle rotmove label crop
bright poster flood thresh smooth inv stretch linear radial pyramid athresh histeq
togray border colcvt split merge
canny trace distmap erode dilate morex range watershed sobel laplace convol logpolar