Skip to content

Image processing tools

Functionality can be accessed via endpoints with tools/ path. Main functionality

  • trim_image- trim padded image

tools/trim_image

The tools/trim_image accepts url-safe base64 encoded image, performs trimming and returns result with same format. Method is robust regarding different background colors and small watermarks in the background. endpoint has several parameters ```json { "id": 0, "image": url_safe_b64_image, "norm_thresh": 5000, "initial_thresh": 10 } ````

Logic

  1. Check, whatever the given direction(top,bottom,left,right) is need to be trimmed (cropped).
    1. For each direction, get average color of the first vector (ex` upper vector for top direction) and construct dummy vector with that color
    2. Compare dummy vector with initial vector, if the euclidian distance of the vectors with smaller than initial_thresh for that direction trimming will be performed.
  2. For the selected direction the initial will be compared with all the following vectors of the image.
    1. If the euclidian distance between initial_vector and current_vector is smaller than norm_thresh the current row will be removed from image.