GithubHelp home page GithubHelp logo

imclab / magiceye-solver Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thearn/magiceye-solver

0.0 2.0 0.0 1.73 MB

A python code to automatically "solve" magic eye autostereograms

License: Other

magiceye-solver's Introduction

Alt text

magiceye-solve

Build Status

A python code that demonstrates how to automatically "solve" a magic eye autostereogram by estimating a projection of the underlying image. This provides a decent contour outline of the hidden object, though most finer detail tends to be lost.

Requirements:

  • Python 2.7+
  • Numpy 1.5+
  • Scipy 0.12+

Optional:

  • scikit-image 0.8+ (code will attempt to import filtering functions for additional post processing, but will not raise an error if library is not available)

Installation:

There are two ways to install magiceye_solve.

It's recommended that you install Numpy, Scipy, and Matplotlib first, either using binary installers (windows) or using a package manager (apt-get, homebrew, etc.).

Installing straight from PyPI:

Run pip install magiceye-solve.

Installing from Source:

Run python setup.py build install to install.

Either method will also install the command line script magiceye_solver into the Python/Scripts directory.

Automatic tests can be performed by running magiceye_solve/test/test_stl.py.

Examples

This code can be used in two different ways.

Run directly from the command line:

Run magiceye_solver with the filename of the image that you would like to process passed as an argument:

For example:

$ magiceye_solver image.jpg

This will produce an output file named image-solution.png which displays the solution of the autostereogram. The output filename can also be specified directly:

$ magiceye_solver image.jpg -o image_output.png

Imported and used as a library:

The magiceye_solver() and 'The magiceye_solver_file() functions can also be imported and used in your own application like any other image/array processing function:

from magiceye_solve import magiceye_solver, magiceye_solver_file
import pylab #matplotlib plotting

image = pylab.imread("image.jpg") #load magiceye image

solution = magiceye_solver(image) #solve it

pylab.imshow(solution, cmap = pylab.cm.gray) #plot the solution

pylab.show() #show the plot

"""
Or, we can process the file and produce a corresponding output directly:
"""

magiceye_solver_file("image_2.jpg")

magiceye_solver_file("image_3.jpg", output_name="image_3_output.png")

How it works:

  • For each of the R, G, and B channels of a magic eye image:
    1. An autocorrelation is computed (via FFT) to find strong horizontal periodicities in the inputted image
    2. The sum of all horizontal translative shifts of the image up to the peak autocorrelation shift is computed. That is, the entire image is "smeared" horizontally by the distance determined in step 1.
    3. An edge detection and uniform filter is applied to clean up the resulting sum and help separate the cumulated noise from useful objective information.

The processed R, G and B channels are then concatenated into a single grayscale image, as output.

Notes / todo list:

  • The post-process filtering should be improved to clean up the output a bit more. The solutions are kind of grainy.
  • This certainly seems to work better for some autostereogram images than others, but still seems to give generally useful output for the test images I've been able to collect so far.
  • Good alternative solution methods are likely to exist, so there is still plenty of experimentation left to do with this.
  • I experimented with PCA and ICA (both as pre-processing the R, G, B channels and as post-processing of the results), but this didn't improve the results very much.

Example results

Alt text

Alt text

Alt text

Alt text

Alt text

Alt text

Alt text

magiceye-solver's People

Contributors

thearn avatar

Watchers

 avatar  avatar

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.