No project description provided
Project description
Gyaku Jinton
OpenCV wrapper to handle shapes and images.
Installation
Just execute the command below and do the jutsus below!
pip install gyakujinton
Pre-requisites
- Python 3.6.1 or higher
- OpenCV
I suggest to check OpenCV's tutorials on installation to help you.
Programmatic
Drawing a polygon on image
Given an image path, by identifying points in the image, you can draw line based on given point.
If color
is added as argument, it will also draw those lines by that color. The color is in RGB format.
If output_path
is not defined, the application will create an application window with the modified image.
from gyakujinton import draw_on_image
draw_on_image(
image_path="/path/to/file.filetype",
output_path="/path/to/output-file.filetype", #optional
points=[[INT, INT], ..., [INT, INT]], # points on a 2D plane
color=(0, 0, 0) # in RGB; optional
)
Distorting an image
Given an image path, this image will be the basis for distortion. The distortion will be from mimimum distortion of 10% to a maximum distortion of 40%. This number is identified in randomly.
A patch
parameter can be defined to focus on an area in an image. This will "crop" the image based on the input patch. This patch should be a rectangle for a proper distortion to take place.
If output_path
is not defined, the application will create an application window with the modified image.
from gyakujinton import skew_image
skew_image(
image_path="/path/to/file.filetype",
output_path="/path/to/output-file.filetype", #optional
patch=[[INT, INT], ..., [INT, INT]], # points on a 2D plane
)
Note: The window that will be created will not consider alpha values. As such, to see transparency it is recommended to save the file in PNG format.
Command-line Interface
The application also allows executions through the CLI.
Drawing a polygon on image (CLI)
The example below gets the image based on the path given and will draw a polygon based on the input points.
gyakujinton draw_on_image /path/to/file.filetype --points 100,100 200,100 200,200 100,200
We can also define an output path by adding the argument -o
or --output_path
followed by the file path.
gyakujinton draw_on_image /path/to/file.filetype --points 100,100 200,100 200,200 100,200 --output_path /path/to/output-file.filetype
Distorting an image (CLI)
A proof-of-concept is created within the application to distort the skew the input image.
gyakujinton distort /path/to/file.filetype --patch 10,10 10,400 400,400 400,10
Similar to previous functions, an output path can be set to write the image into a file.
Note: The window that will be created will not consider alpha values. As such, to see transparency it is recommended to save the file in PNG format.
Sample
To test out the application, we'll be using an image by Samantha Gades taken from Unsplash. We have this beautiful and simple original image.
We can draw a polygon near the clock by doing the following in the command-line:
gyakujinton draw_on_image sample/samantha-gades-unsplash.jpg --points 150,150 150,250 250,250 250,150
Again, we are not restricted with the polygon that we want to create. It all depends on where we put the points and how they are ordered when lines are to be drawn.
gyakujinton draw_on_image sample/samantha-gades-unsplash.jpg --points 100,100 100,150 180,200 250,150 250,100 180,50 -o output-2.jpg
We can also test out the created function for image distortion.
gyakujinton distort sample/samantha-gades-unsplash.jpg --patch 10,10 10,400 400,400 400,10 -o output.distort.jpg
Name Inspiration
Source: naruto.fandom.com/wiki
When thinking of a name for the app, the first thing that came into mind is Ohnoki's Particle Style (or Dust Release) Atomic Dismantling Jutsu from Naruto which is a technique that has a sphere in the center contained by a geometric object. In the series, dust release is called Jinton
which was chosen due to how amazed I am on the shapes happening.
Now, with the points above, the technique is used to dismantle atoms to dust. Gyaku
(or reverse as taught to me by Google Translate) was added to signify making of shapes and images rather than dismantling them.
Hence, the app name Gyaku Jinton
.
Author
Almer Mendoza
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gyakujinton-0.4.0.tar.gz
.
File metadata
- Download URL: gyakujinton-0.4.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.2 CPython/3.6.8 Darwin/19.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a28f6199be786aa34f08aacec72d1c77b3a90fddce5438b3075d858eda31e33 |
|
MD5 | 95ec1db10b3571c69bc34bb25f95762c |
|
BLAKE2b-256 | eb4ab89651f79703dce1a802fbf002d444647fa44782bf7f05c4d76ea283e053 |
File details
Details for the file gyakujinton-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: gyakujinton-0.4.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.2 CPython/3.6.8 Darwin/19.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89a62a8c7f2ed730373d5d08a1daaa0aad7b8f84ce6f776a1e1f806e633fec57 |
|
MD5 | ec1db2962ddd6e9036fea93a42d711ad |
|
BLAKE2b-256 | fea04d29ad3144c95498215f41b2e81019dfb43a4c295a5e04eca103d0a4f0ee |