chinese-hershey-font
Convert Chinese Characters to Single-Line Fonts using Computer Vision
A fast Python implementation of Seam Carving for Content-Aware Image Resizing.
git clone https://github.com/andrewdcampbell/seam-carving.gitandrewdcampbell/seam-carvingA fast Python implementation of Seam Carving for Content-Aware Image Resizing (2007), including the improved energy algorithm described in Improved Seam Carving for Video Retargeting (2008).
python seam_carving.py (-resize | -remove) -im <IM_PATH> -out <OUTPUT_IM_NAME>
[-mask <MASK_PATH>] [-rmask <REMOVAL_MASK_PATH>] [-dy <DY>] [-dx <DX>]
[-vis] [-hremove] [-backward_energy]
The program is run via the command-line. There are two modes of operations: resize or remove. The former is for resizing an image vertically or horizontally and the latter is for removing an object as specified by a mask.
For both modes:
-im: The path to the image to be processed.-out: The name for the output image.-mask: (Optional) The path to the protective mask. The mask should be binary and have the same size as the input image. White areas represent regions where no seams should be carved (e.g. faces).-vis: If present, display a window while the algorithm runs showing the seams as they are removed.-backward_energy: If present, use the backward energy function (i.e. gradient magnitude) instead of the forward energy function (default).For resizing:
-dy: Number of horizontal seams to add (if positive) or subtract (if negative). Default is 0.-dx: Number of vertical seams to add (if positive) or subtract (if negative). Default is 0.For object removal:
-rmask: The path to the removal mask. The mask should be binary and have the same size as the input image. White areas represent regions to be removed.-hremove: If present, perform seam removal horizontally rather than vertically. This will be more appropriate in certain contexts.There are some additional constants defined at the top of the code seam_carving.py that may be modified.
DOWNSIZE_WIDTH, or set SHOULD_DOWNSIZE to False to disable downsizing completely.SEAM_COLOR array (in BGR format).The input image is on the left and the result of the algorithm is on the right.
Animated gif:
In general, forward energy gives better results than backward energy. The result of resizing using backward energy (left) and forward energy (right) is shown below.
For more information on how the algorithm works, see my blog post.
Many parts of the code are adapted/optimized versions of functionality from other implementations:
more like this
Convert Chinese Characters to Single-Line Fonts using Computer Vision
🎥🤟 8 minimalistic templates for tfjs mediapipe handpose and facemesh
meine 🌒 - A CLI file manager and system utility built with Textual. It combines intuitive command parsing with rich t…
search projects, people, and tags