Git Product home page Git Product logo

depixelize's Introduction

README
Author: Cary Yang <[email protected]>

---------------------------------------------------------------------------
Overview
---------------------------------------------------------------------------

This project is a C++ implementation of Depixelizing Pixel Art, by Kopf and
Lischinski, SIGGRAPH 2011, written for my final project in CMU's 15-463,
Computational Photography.

This code has only been tested on the files in the images/ directory, it is
likely to contain bugs. Also, the optimization phase does not appear to
work correctly (output does not match paper's results).

What follows is instructions on building the code, running the program, and
a description of the source files.

This README and the CMake build system for this project were largely adapted
from projects in CMU's 15-462, Computer Graphics.

---------------------------------------------------------------------------
Prerequisites
---------------------------------------------------------------------------

There are some libraries required for this to compile, namely OpenCV (for
image reading/writing and colorspace conversion) and Boost (for the Voronoi
diagram and filesystem utilities).

---------------------------------------------------------------------------
Building the Code
---------------------------------------------------------------------------

This project uses the CMake build system (www.cmake.org). CMake is a kind of
"meta build-system," in that it creates a build system for you. It supports
many different build systems, ranging from Unix Makefiles to Visual Studio
projects to XCode projects.

1) If you don't have CMake installed, you should install it. If you're running
    Linux, it should be available through your disto's package manager
    (apt-get, pacman, ports, etc). Windows and OSX installers can be downloaded
    from http://www.cmake.org/cmake/resources/software.html
2) Open up a command prompt in the "build" directory and run "cmake ../src".
    CMake will generate the build system in the build directory. By default,
    CMake will generate Makefiles on Linux and OSX and a Visual Studio project
    on Windows. If you'd like to change that, you can pass a different
    "generator" to cmake with the -G flag. A full list of generators can be
    found at the bottom of the output generated by running "cmake". For
    example, "cmake -G 'Xcode' ../src" will generate an Xcode project on OSX.
3) You can now use the build system in the "build" directory. The default
    target will compile everything for you, and the "install" target will copy
    the executable to the main "final_project" directory.

NOTE: This project has only been tested on OS X Yosemite, compilation on other
targets is not gauranteed.

WARNING: This project will only compile with GNU-based compilers and will most
likely not run on Windows as the proper runtime libraries are not included.

---------------------------------------------------------------------------
Running the Program
---------------------------------------------------------------------------

./depixelize [options] input_filename
Program Options:
  -o  --output <FILENAME>
      Puts the resulting image into <FILENAME> (default: [input_filename]_out)
  -s  --scale  <INT>
      Scale the output image by this factor (default: 16)
  -h  --help
      This message
  input_filename
      The input image to depixelize

---------------------------------------------------------------------------
Source Files and Directory Structure
---------------------------------------------------------------------------

A description of the top-level directories and all source/header file pairs
follows.

README                   -- this file

images/                  -- a set of input images from the original paper
                             (C) Nintendo Co., Ltd

src/build/*              == Build system stuff.
    CMakeLists.txt       -- Compiler flags can be adjusted by editing the
                              list in here.

src/depixelize/          == Project-specific files.
    main                 -- Main function, and application backend.
    pixel_grid           -- An implementation of an 8-connected pixel grid
                              that can make itself planar and resolve
                              ambiguities.
    spline_optimizer     -- Extracts and optimizes splines from the Voronoi
                              diagram.
    color_util           -- Various color utility functions.
    math_util            -- Various math utility functions.
    voronoi_visual_utils -- Voronoi utilities, borrowed from the
                              voronoi_visualizer example in Boost.

src/geometry/            == Geometry related classes and functions
    bspline              -- Contains a B-spline implementation that can
                              find its own curvature and be integrated.
    edge                 -- Simple undirected-edge made from 2 points.
    point                -- Simple point implementation, with some math
                              utility operators implemented.
    shape                -- A shape, defined by a B-spline edge and a list
                              of internal color points.
    types                -- Various common types.

src/render/              == Rendering related classes
    renderer             -- Base interface for all renderers. Defines
                              rendering lists of shapes to arbitrary
                              formats.
    svg_renderer         -- SVG implementation of the renderer.
    simple_svg_1.0.0     -- An SVG rendering library from the Internets.

depixelize's People

Contributors

bsl avatar cyang1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

depixelize's Issues

Infinite loop or segmentation fault on every input

Hi, thanks for this repo. Unfortunately, I'm getting segfault or never ending loop on every input...

For input smw_mario_input, program running on 100% CPU and never ends. Here is a Valgrind output

==23787== Memcheck, a memory error detector
==23787== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==23787== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==23787== Command: ./depixelize -o out.svg images/smw_mario_input.png
==23787== 
==23787== Conditional jump or move depends on uninitialised value(s)
==23787==    at 0x6991A28: ippicvGetCpuFeatures (in /usr/local/lib/libopencv_core.so.3.0.0)
==23787==    by 0x68242B2: ippicvStaticInit (in /usr/local/lib/libopencv_core.so.3.0.0)
==23787==    by 0x53039F8: _GLOBAL__sub_I_deriv.cpp (in /usr/local/lib/libopencv_imgproc.so.3.0.0)
==23787==    by 0x4010139: call_init.part.0 (dl-init.c:78)
==23787==    by 0x4010222: _dl_init (dl-init.c:36)
==23787==    by 0x4001309: ??? (in /lib/x86_64-linux-gnu/ld-2.19.so)
==23787==    by 0x3: ???
==23787==    by 0xFFF00025E: ???
==23787==    by 0xFFF00026B: ???
==23787==    by 0xFFF00026E: ???
==23787==    by 0xFFF000276: ???
==23787== 
==23787== Conditional jump or move depends on uninitialised value(s)
==23787==    at 0x6991A28: ippicvGetCpuFeatures (in /usr/local/lib/libopencv_core.so.3.0.0)
==23787==    by 0x68242B2: ippicvStaticInit (in /usr/local/lib/libopencv_core.so.3.0.0)
==23787==    by 0x5303AA8: _GLOBAL__sub_I_sumpixels.cpp (in /usr/local/lib/libopencv_imgproc.so.3.0.0)
==23787==    by 0x4010139: call_init.part.0 (dl-init.c:78)
==23787==    by 0x4010222: _dl_init (dl-init.c:36)
==23787==    by 0x4001309: ??? (in /lib/x86_64-linux-gnu/ld-2.19.so)
==23787==    by 0x3: ???
==23787==    by 0xFFF00025E: ???
==23787==    by 0xFFF00026B: ???
==23787==    by 0xFFF00026E: ???
==23787==    by 0xFFF000276: ???
==23787== 
==23787== Conditional jump or move depends on uninitialised value(s)
==23787==    at 0x6991A28: ippicvGetCpuFeatures (in /usr/local/lib/libopencv_core.so.3.0.0)
==23787==    by 0x68242B2: ippicvStaticInit (in /usr/local/lib/libopencv_core.so.3.0.0)
==23787==    by 0x5303AF8: _GLOBAL__sub_I_imgwarp.cpp (in /usr/local/lib/libopencv_imgproc.so.3.0.0)
==23787==    by 0x4010139: call_init.part.0 (dl-init.c:78)
==23787==    by 0x4010222: _dl_init (dl-init.c:36)
==23787==    by 0x4001309: ??? (in /lib/x86_64-linux-gnu/ld-2.19.so)
==23787==    by 0x3: ???
==23787==    by 0xFFF00025E: ???
==23787==    by 0xFFF00026B: ???
==23787==    by 0xFFF00026E: ???
==23787==    by 0xFFF000276: ???
==23787== 
==23787== Invalid read of size 4
==23787==    at 0x97779A9: ??? (in /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0)
==23787==    by 0x9777F28: ??? (in /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0)
==23787==    by 0x4010139: call_init.part.0 (dl-init.c:78)
==23787==    by 0x4010222: _dl_init (dl-init.c:36)
==23787==    by 0x4014C6F: dl_open_worker (dl-open.c:577)
==23787==    by 0x400FFF3: _dl_catch_error (dl-error.c:187)
==23787==    by 0x40143BA: _dl_open (dl-open.c:661)
==23787==    by 0x8B3902A: dlopen_doit (dlopen.c:66)
==23787==    by 0x400FFF3: _dl_catch_error (dl-error.c:187)
==23787==    by 0x8B3962C: _dlerror_run (dlerror.c:163)
==23787==    by 0x8B390C0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
==23787==    by 0x66C9A17: (anonymous namespace)::opencl_fn3<58, int, unsigned int, _cl_platform_id**, unsigned int*>::switch_fn(unsigned int, _cl_platform_id**, unsigned int*) (in /usr/local/lib/libopencv_core.so.3.0.0)
==23787==  Address 0x93e7734 is 20 bytes inside a block of size 23 alloc'd
==23787==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==23787==    by 0x977796A: ??? (in /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0)
==23787==    by 0x9777F28: ??? (in /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0)
==23787==    by 0x4010139: call_init.part.0 (dl-init.c:78)
==23787==    by 0x4010222: _dl_init (dl-init.c:36)
==23787==    by 0x4014C6F: dl_open_worker (dl-open.c:577)
==23787==    by 0x400FFF3: _dl_catch_error (dl-error.c:187)
==23787==    by 0x40143BA: _dl_open (dl-open.c:661)
==23787==    by 0x8B3902A: dlopen_doit (dlopen.c:66)
==23787==    by 0x400FFF3: _dl_catch_error (dl-error.c:187)
==23787==    by 0x8B3962C: _dlerror_run (dlerror.c:163)
==23787==    by 0x8B390C0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
==23787==

For another image

commander keen

$ ./depixelize -o out.svg Commander\ Keen.png 
WARNING: Primary, infinite edge...
Segmentation fault

Any idea, what's wrong? Probably, some incompatibilities in shared libraries...

segfault in PixelGrid::get_components

Hi, thanks for working on this project. Your results are looking very promising!

On line 366 of pixel_grid.cpp, new_pos sometimes goes negative. Then it's used as an index into seen, and I get a segfault.

Speeding up optimize_splines

This seems to be the slowest part of the algorithm.. some ideas to speed it up (keep in mind I don't fully understand the workings of the algorithm):

Threading - Not sure if its possible, but perhaps its possible to do different sections of the image at a time.

Reducing iterations - The randomness of the optimizing seems to result in a high amount of iterations.. if there is a way to remove the random element from it then it should be possible to reduce the needed amount of iterations/guesses, as well as produce more consistent results.

I've already made a pull request that speeds it up quite a bit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.