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