All examples are from S. Knapp 2013.
In the monogram above (Figure 8.) and many others, the height data for the scale bar is directly below the line.
In the monogram above (Figure 18.) and many others, the height data is in the middle of the scale bar.
As the detection of these lines are already done when image-to-text algorithm is done, the following function was used for when height data was directly below - as in Figure 8.
def getHeightandVerticalLine(contours, height_predictions, x_increase:int=0, y_increase:int=100):
boxes = []
for (label, box) in height_predictions:
sorted_x = np.sort(box[:, 0])
min_xs = sorted_x[:2]
sorted_y = np.sort(box[:, 1])
min_ys = sorted_y[:2]
# max_ys = sorted_y[2:]
for i, point in enumerate(box):
if point[0] in min_xs:
box[i] = point - np.array([x_increase, 0])
if point[1] in min_ys:
box[i] = point - np.array([0, y_increase])
boxes.append(box)
distance_array = getDistanceArrayHeight(contours, height_predictions)
min_distances = np.argmin(distance_array, axis=0)
return min_distances, boxes
The presumed scale bar height in pixels with some error is recorded to y_increase, and the prediction box of height data is expanded to include the line. This will not work for examples such as Figure 18.
Instead of going from image-to-text predictions to scale bars, line detection may be used to find these lines. If there are any issues with line detection it will be created as another issue.
All examples are from S. Knapp 2013.
In the monogram above (Figure 8.) and many others, the height data for the scale bar is directly below the line.
In the monogram above (Figure 18.) and many others, the height data is in the middle of the scale bar.
As the detection of these lines are already done when image-to-text algorithm is done, the following function was used for when height data was directly below - as in Figure 8.
The presumed scale bar height in pixels with some error is recorded to
y_increase
, and the prediction box of height data is expanded to include the line. This will not work for examples such as Figure 18.Instead of going from image-to-text predictions to scale bars, line detection may be used to find these lines. If there are any issues with line detection it will be created as another issue.