OpenCVTool quick start guide

 

1. Script loading

Let's reproduce the contouring procedure of the test_he.fr script from the distro. The script is a text file with commands recorded by the program during an action. The script file has a fr extension and consists of the standard Forth commands plus some commands added here for image processing, layer management, drawing and so on (see OpenCVTool Forth page for details). Let's open test_he.fr in the Notepad.
s" test_he.jpg" loadimage cr
-20 bright cr
6 radial cr
11 smooth cr
319 236 40 flood cr
togray cr
0 43 thresh
cr inv cr
1 border cr
1 trace cr
Now, we could execute this script. Go to the Script tab. Click the Folder to point to a directory of the script (it is something like C:\Program Files\OpenCVTool or C:\Documents and Settings\user\Application Data\OpenCVTool if you are working without Admin rights). Pull down the list box arrow button and select the test_he.fr line or just open (execute) the script file by the Open Image button. We should see red contours arround the cells nuclei and could count their number and geometric parameters.

2. Open the image


Now we could repeat all the procedures line by line. Restart the program. Open the image test_he.jpg. Click Image Open button on the top left corner and select the image file from the  installation directory of the program.
We've executed :
s" test_he.jpg" loadimage cr
It is helpful to see how a histogram of the image is changing during our work. Check the  Hist.On box if not checked. For the true color image this shows four histograms - 3 color channels(RGB) and the one (black) for the intensity or just one curve for a gray scale image.

3. Is lighting uniform?

Do we need a shading correction for the image? Click the Norm button. It has no parameters so there is no tracking mode. After normalization it is clear that the image is more bright in the center. So we need radial shading correction. Click the Undo button to cancel normalization.

4. Tracking

Next command is
-20 bright cr
It slighltly decreases image brightness. The aim of this operation will be clear on the next step. Click the Bright button on the Bitmap tab. By this button the program goes into tracking mode. This mode is ended by a Left mouse click and canceled by a Right mouse click. Now move the mouse pointer horizontally. During mouse tracking look at the Status line on the bottom right where all parameters of the currently issued command will be printed. We need to select the -20 bias. When it is riched - click the Left mouse button or the Right mouse button for canceling and try the operation again.
To perform this command
6 radial cr
use the Radial button and track the mouse horizontally for the case when strength parameter will be a 6 or so.
Every image has intensity fluctuations or noise. To eliminate them, use the Smooth button. As usual, the left mouse button to accept operation, the right - for cancel. We've made
11 smooth cr

5. Flood fill the background

We see dark objects (the cells nuclei) on the light background. So to completely flatten the background lets use the FloodFill tool. The command is
500 358 40 flood cr
the first two numbers are XY coordinates of a seed point for the flood filling. The last one is the strength. After clicking the button, click somewhere at the background, and select proper parameter by tracking a mouse. We could also execute this complicated command from the script console. To issue a command without mouse clicks and tuning, go to the Script tab, type the command in the field (or paste it from the Notepad if you are lasy) and hit Enter to execute it.

6. Thresholding

Our aim is to produce contours arround cells nuclei. But this operation works with a binary image. Till now we have a true color image. Now use the button ToGray to discard color information from the image and the Threshold to discard all gray scale information except two values (black and white).
togray cr
0 43 thresh cr

We see black blobs on a white background and could apply the tracing. But we should do other two steps for separating the blobs from the image border. Click the Invert button and use the Border tool to draw a black border around the image.
inv cr
1 border cr

7. Tracing

Now we are ready to make tracing - the key operation in this work. Go into the Binary tab. Check the box labeled Ext near the Trace Make button (if not checked) and click the Make. If all is right you should see red contours on the background of the original image. The program calculates the number of contours (116 in our case) and shows a distributions for some geometric characteristics of these contours.
Lets look at the histogramm footer. There are four lines. The Area with the mean area of the 380 sq pixels,the Len with mean perimeter length is 64.7 pixels, the nonconvexity Defect (25.7 sq pixels) and the first Eccentricity (mean is 0.0283). The second number is a deviation. The last one is the sum of correspondent values.