ghostwriternr / Lowpolify
Programming Languages
Projects that are alternatives of or similar to Lowpolify
lowpolify
โIโve been waiting for you, Obi-Wan. We meet again, at last. The circle is now complete. When I left you, I was but the learner; now I am the master.โ ๐๐๐
PS. Formal introductions are yet to begin, in case you were wondering. ๐
Introduction
The goal of lowpolify is quite simple. Generate low poly versions of any given image.
Now what is 'low poly' you may ask.
Here's what Wikipedia has for you: Low poly is a polygon mesh in 3D computer graphics that has a relatively small number of polygons. Low poly meshes occur in real-time applications (e.g. games) and contrast with high poly meshes in animated movies and special effects of the same era. The term low poly is used in both a techni... yada yada yada you get the idea. Basically objects composed of only polygons. ๐๐
If you'd like to skip all the chit chat, here's the DEMO. Arr, matey, thar be ye booty!
https://lowpolify.ghostwriternr.me/
Approach
Take an image, lowpolify it and poof!! ๐ฅ LOW POLY, BABY!! ๐๐
Here's an ELI5 TLDR ๐ถ :
- Pre-process the input image to remove noise and reduce image size
- Detect edges in the input image
- If the image contains humans faces, detect facial features as well
- Choose a random subset of the above detected points / edges
- Triangulate using Delaunay Triangulation
- Fill the triangles with the mean value of all pixels contained by it (in parallel for faster computation)
- LOW POLY, BABY! ๐๐
Sample output
Lo and Behold!
High-poly input | Low-poly output |
---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Screenshots
Now everybody loves to see the master at work, right? Right?? AMIRITE???
Dependencies
- Node.js
- Python3 (Along with the following python modules):
- cv2
- numpy
- scipy
- sharedmem
- dlib
How to use
If you only need to run the script
- Download the core script from here.
wget https://raw.githubusercontent.com/ghostwriternr/lowpolify/master/scripts/lowpolify.py
-
Download and extract the .dat file from dlib for facial features detection. Place the extracted file under
scripts
(the same directory as thelowpolify.py
script). -
Run the python script as:
python lowpolify.py <input-image> <output-image> <cFraction>
Here, cFraction denotes the fraction of points from original edges to be taken for triangulation.
If you would like to use the webapp
- Clone the repo
git clone https://github.com/ghostwriternr/lowpolify
- Navigate into the cloned repository
cd lowpolify
- Install all
npm
modules
npm install
- Create a file
secrets.json
under theapp/secrets/
directory. The structure of the file should look like this:
{
"apiKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
You can create your own apiKey at your Clarifai Developer account page.
-
Download and extract the .dat file from dlib for facial features detection. Place the extracted file under
scripts
(the same directory as thelowpolify.py
script). -
Start the server using
node
node server.js
- Marvel at the beauty served hot at http://localhost:8080/
License
MIT ๐
Psst
In case you too got bored reading this README, foxy here wants to give you a hugsy!