Skip to content

Rusching/polygonize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polygonize

An algorithm to polygonize images. Make images more concise, an effect like paper cut in photoshop. Also support to fix the direction of edges to make them more regular.

wave_fix

The Great Wave off Kanagawa, Katsushika Hokusa, 1831

the_starry_night

The Starry Night, Vincent van Gogh, 1889

portrait_of_unknown_woman_squ

Portrait of an Unknown Woman, Ivan Kramskoi, 1889

Core ideas:

  • Using Superpixel to segment images
  • Create region adjacency graph
  • Merge adjacent regions base on certain thershold
  • Extract separate fused regions and their colors
  • Polygonize each area
  • [Fix directions]

Requierments

  • Python 3.x
  • opencv-python > 4.5
  • skimage
  • numpy

Usage

python main.py input.jpg output.jpg [-d fix-option]
fix-option == 1: create octagon like polygons, with all lines vertical or horizontal or 45 degrees oblique
fix-option == 2: create rectangle like polygons, with all lines vertical or horizontal

Support SVG format output 😋

Next

  • Add more polygon edge diretion fix options
  • Add pre-processing to increase the contrast to make the segmentation effect more obvious
  • Remove noise

About

An algorithm to polygonize images

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages