Package: gyakujinton
Gyaku JintonOpenCV wrapper to handle shapes and images.InstallationJust execute the command below and do the jutsus below!pipinstallgyakujintonPre-requisitesPython 3.6.1 or higherOpenCVI suggest to check OpenCV'stutorialson installation to help you.ProgrammaticDrawing a polygon on imageGiven an image path, by identifying points in the image, you can draw line based on given point.Ifcoloris added as argument, it will also draw those lines by that color. The color is in RGB format.Ifoutput_pathis not defined, the application will create an application window with the modified image.fromgyakujintonimportdraw_on_imagedraw_on_image(image_path="/path/to/file.filetype",output_path="/path/to/output-file.filetype",#optionalpoints=[[INT,INT],...,[INT,INT]],# points on a 2D planecolor=(0,0,0)# in RGB; optional)Distorting an imageGiven 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.Apatchparameter 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.Ifoutput_pathis not defined, the application will create an application window with the modified image.fromgyakujintonimportskew_imageskew_image(image_path="/path/to/file.filetype",output_path="/path/to/output-file.filetype",#optionalpatch=[[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 InterfaceThe 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.gyakujintondraw_on_image/path/to/file.filetype--points100,100200,100200,200100,200We can also define an output path by adding the argument-oor--output_pathfollowed by the file path.gyakujintondraw_on_image/path/to/file.filetype--points100,100200,100200,200100,200--output_path/path/to/output-file.filetypeDistorting an image (CLI)A proof-of-concept is created within the application to distort the skew the input image.gyakujintondistort/path/to/file.filetype--patch10,1010,400400,400400,10Similar 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.SampleTo test out the application, we'll be using animage by Samantha Gadestaken 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:gyakujintondraw_on_imagesample/samantha-gades-unsplash.jpg--points150,150150,250250,250250,150Again, 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.gyakujintondraw_on_imagesample/samantha-gades-unsplash.jpg--points100,100100,150180,200250,150250,100180,50-ooutput-2.jpgWe can also test out the created function for image distortion.gyakujintondistortsample/samantha-gades-unsplash.jpg--patch10,1010,400400,400400,10-ooutput.distort.jpgName InspirationSource: naruto.fandom.com/wikiWhen thinking of a name for the app, the first thing that came into mind is Ohnoki'sParticle Style (or Dust Release) Atomic Dismantling JutsufromNarutowhich is a technique that has a sphere in the center contained by a geometric object. In the series, dust release is calledJintonwhich 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 byGoogle Translate) was added to signify making of shapes and images rather than dismantling them.Hence, the app nameGyaku Jinton.AuthorAlmer Mendoza