utils module¶
A collection of utility classes for manipulating asparagus images
-
utils.binarize(img, thres)¶ binarizes an image based on thresshold
-
utils.downsample(img)¶ quickly downsamples image through mean interpolation
-
utils.erode(img)¶ run vanilla erosion on image
-
utils.find_angle(img)¶ Finds the angle of rotation of the asparagus piece in the image. returns that angle
-
utils.find_bounds(img)¶ Finds the upper and lower limit of the nonzero box, that is: Where the asparagus piece starts and where it ends.
returns: upper and lower, the limits of the asparagus piece
- WARNING: the image rows are numbered from top to bottom, so the first = highest
row of the image is row 0 and the last = lowest is 1200. Therefore, upper is the limit at the head of the asparagus piece, lower is at the bottom of the asparagus piece. BUT: this means that the value of lower is higher than the value of upper.
-
utils.head_finder(img)¶ Cut image to only display the head of the asparagus. :param img: the image
- Returns
the image cropped around the head
- Return type
head
-
utils.rotate_to_base(img)¶ Finds out what the asparagus angle is, zeroes image by rotating it to 0°