We define a simple computer vision definition for the graduations on a ruler, in our system, as the region in any RulerImage or TemplateWindow with the highest uniform spatial frequency pattern. The spatial frequency

f is defined below as the number of graduations or ticks under a line given the width of black pixels

${w}_{i}$ within a threshold

t.

To search for this region, we start by creating an array or line with

N number of points where

$150<=N<=500$, the exact value is the width of the TemplateWindow. This value is found in

Section 2.3.1. We chose this range based on the variable image size in our database and therefore each TemplateWindow is between

$150\phantom{\rule{3.33333pt}{0ex}}\times \phantom{\rule{3.33333pt}{0ex}}150$ and

$500\phantom{\rule{3.33333pt}{0ex}}\times \phantom{\rule{3.33333pt}{0ex}}500$ pixels. The lower bound of 150 we select to maintain a level of fidelity in the image which should be considered when initially capturing the image. The upper bound of 500 was selected because it is big enough to perform a thorough search on large images and small enough to still execute quickly. The search is repeated for each of the corners in the TemplateWindow such that each corner searches in a 90 degree arc about the image. This is demonstrated in

Figure 2 as the InitalSearch. Each of the search parameters are based on the size of the image, where the number of searches is equal to

where

X is the width of the image,

N is the image width of the target image size,

R is the quotient of N over 500, and

i is the search iterator. The value

i is used to incrementally reduce the search space this is because we expect to iteratively improve. Every search has a window or width equal to:

where

m is a constant based on the target image size. We selected the constant

m based on the target RulerImage size such that the number of searches and search windows would be proportional to the size of the RulerImage. These constants ensures that even if a TemplateWindow is very small, i.e.,

$150\phantom{\rule{3.33333pt}{0ex}}\times \phantom{\rule{3.33333pt}{0ex}}150$ pixels, the image will still get searched. After each iteration of the search, the window size and searches per window decreases.

Figure 3a presents the combined rendering of the Deep Search method. In

Figure 3b each of the regions have been rendered separately noting the empty or white areas where the search stopped or skipped searching altogether. In

Figure 3c the rendering shows two zoomed arbitrary regions of

Figure 4a where the ticks on the ruler are located, noting the increased number of searches in this small region.

After each search the list of results is filtered to determine if the average number of graduations or spatial frequencies has improved. The first filter will remove results that were less than the average uniform spatial frequency, from Equation (

1), in the most recent search. The second filter removes results with a large slope with respect to both the vertical and horizontal axis. The two filters will drop on average half of the search results. The deep search is looking for the improved spatial frequency over each iteration of results. The conclusion of the search will occur when either of the following is true: (1) the search has gone on for too long or (2) the average uniform spatial frequency has not changed. The limited number of searches is meant to provide an extensive yet deterministic result as there could be marginal improvement over many searches. From experimentation, the first condition typically means there was no good result to pick. Meaning the image was not very clear. An unchanged average uniform spatial frequency or the same number of measured graduations is the desired outcome of the deep search where there will either be only one spatial frequency, or a set of spatial frequencies equivalent to the average. In the worst case, the average spatial frequency could decrease after a search. In this scenario, we resort to memoization (

https://en.wikipedia.org/wiki/Memoization) and expect the best result to exist in the previous search. When the search exhausts all the available options we retrieve a single spatial frequency. The red line in

Figure 4 is the final resulting line and its corresponding spatial frequency is below. In the final calculation we consider both the black and white values for width in the length of a single graduation. We measure the value for a single graduation as

${M}_{f}$ where

${M}_{f}$ is the sum of the modes for the black spatial frequency

${M}_{b}$ and white spatial frequency

${M}_{w}$.

where we expect

${M}_{f}$ is one millimeter in the metric system or

$\frac{1}{16}$ of an inch in the imperial system.