jerith / depixel Goto Github PK
View Code? Open in Web Editor NEWDepixeling tool, based on "Depixelizing Pixel Art".
License: MIT License
Depixeling tool, based on "Depixelizing Pixel Art".
License: MIT License
This is an implementation of the "Depixelizing Pixel Art" algorithm: http://research.microsoft.com/en-us/um/people/kopf/pixelart/ This code is provided under the MIT license, the full text of which is in the LICENSE file. As far as I know, the algorithm is not covered by any patents or restrictive copyright. This is very much a work in progress at present. My primary aim is to build a tool to generate outline fonts from low-resolution bitmap fonts, but that isn't ready yet. So far I have the basic pixel grid deformation, shape outline extraction and somewhat wonky curve smoothing implemented and I can write representations of the intermediate steps to PNG and SVG. (The curve smoothing is pretty experimental, and probably full of exciting bugs. It also operates on each shape individually, so there's weirdness along the edges.) There is a handy script to depixel PNGs in the `depixel/scripts` directory, and there are unit tests covering some of the code. I like to keep dependencies small and light, but there are some useful bits I've pulled in (or will pull in) to make life easier: * I use `networkx` to do the graph stuff, because implementing it myself was getting messy. Switching to a more special-purpose graph library might give some performance benefits, but that's fairly low down my priority list at present. * I use `pypng` to do the PNG reading and writing, but that's isolated in the things that need it and the actual depixeling code works fine without it. * I use `svgwrite` to do the SVG writing, but that's isolated in the things that need it and the actual depixeling code works fine without it. * I'm probably going to need `bdflib` once I start working with fonts. Like the PNG stuff, I'll restrict its use to the places that need it. Since BDF is a fairly simple format and this library doesn't play nice with pip, I may rewrite the bits I need here as well. * I use Twisted's trial testrunner to run the tests, but that isn't required as long as you're happy to figure out how to discover and run the test cases yourself. (I think nose or something should work as well. I just like Twisted, and I had some editor hooks set up to use trial for other projects.)
AttributeError: 'Graph' object has no attribute 'nodes_iter'
OS: Mac10.12.6
Python: 2.7
Thanks for making this library! It seems to be very useful for me but I'm not sure how to get started after installing and running the test cases.
Is there any chance that you provide some simple examples for beginners to get started?
That would be very helpful. Thank you!
from depixelizer import Depixelize
Depixelize(input_image_path, output_dir).run()
???
Seems to get stuck in an infinite loop?
The original Microsoft research paper mentions sub second run times to process an image.
But this code runs for minutes at 100% CPU, and when I stop the script, this is the call stack I see:
$ time ./depixel_png.py --to-svg bt_02.png
Processing bt_02.png...
^CTraceback (most recent call last):
File "./depixel_png.py", line 83, in
main()
File "./depixel_png.py", line 79, in main
process_file(options, filename)
File "./depixel_png.py", line 55, in process_file
data.depixel()
File "/usr/local/lib/python2.7/dist-packages/depixel-0.1-py2.7.egg/depixel/depixeler.py", line 338, in depixel
self.add_shape_outlines()
File "/usr/local/lib/python2.7/dist-packages/depixel-0.1-py2.7.egg/depixel/depixeler.py", line 551, in add_shape_outlines
path = self.make_path(graph)
File "/usr/local/lib/python2.7/dist-packages/depixel-0.1-py2.7.egg/depixel/depixeler.py", line 538, in make_path
path = Path(graph)
File "/usr/local/lib/python2.7/dist-packages/depixel-0.1-py2.7.egg/depixel/depixeler.py", line 608, in init
self.path = self._make_path(shape_graph)
File "/usr/local/lib/python2.7/dist-packages/depixel-0.1-py2.7.egg/depixel/depixeler.py", line 625, in _make_path
for neighbor in shape_graph.neighbors(path[-1]):
File "/usr/lib/python2.7/dist-packages/networkx/classes/graph.py", line 977, in neighbors
return list(self.adj[n])
KeyboardInterrupt
real 5m57.368s
user 5m57.220s
sys 0m0.346s
ubuntu 14.04 lts
pyhton 2.7.6
networkx 1.8.1
source image:
bt_02.png: PNG image data, 42 x 14, 8-bit colormap, non-interlaced
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.