Code Monkey home page Code Monkey logo

icosahedral_sampler's Introduction

Unwrapped Icosahedral Maps 🗺️

My humble attempt to create unwrapped icosahedral maps from equirectangular images. Insipration taken from here. If you find this useful, please consider giving it a star ⭐ image

Installation

This code was developed using python 3.8, however it should run on anything that has >= python 3.6.

To install the requirements, one can simply run:

$ pip install -r requiremets.py

Usage

The base class that one can use is the IcosahedralSampler class. Sample usage:

from ico_sampler import IcosahedralSampler

eq_image = imread('./assets/0.png')
ico_sampler = IcosahedralSampler(resolution = 600)

# generate unwrapped maps (as presented above)
unwrapped_image = ico_sampler.unwrap(eq_image, face_offset=0)

# generate unwrapped maps and shift they faces are put into the final panorama
unwrapped_image = ico_sampler.unwrap(eq_image, face_offset=2)


# create the image of the triangular face
face_image = ico_sampler.get_face_image(face_no=0, eq_image=eq_image)

# sample face colors from an eq image
face_colors = ico_sampler.get_face_rgb(face_no=0, eq_image=eq_image)

One can run the provided sample notebook to see exactly how the code works. One can create shift the output image by specifying the face_offset when calling ico_sampler.unwrap():

im

Command line

This repository also contains a command line utility program that can convert an equirectangular image to an incosahedral projection map:

$ python unwrap.py --input=<path to input> \ 
                   --output=<path to output> \
                   --face_resolution=600 \ 
                   --face_offset=0

TODOs

A list of TODOs that might be implemented in the future:

  • add interpolation when sampling the colors (current method: nearest) - this can cause grainy images, but increasing the face resolution (>600px) should diminish this effect
  • add a tutorial like notebook to go over spherical projections

References

During the creation of this repository I hhave found the following articles to be useful:

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.