Coder Social home page Coder Social logo

kaiser34 / cmap_builder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mmesch/cmap_builder

0.0 2.0 0.0 33.62 MB

three blender scripts that allow to design 1d and 2d colormaps within a colorspace gamut

License: GNU General Public License v3.0

Python 100.00%

cmap_builder's Introduction

colormap2d

This python package provides a carefully designed set of 2D colormaps that live in the perceptually uniform colorspace CAM02-UCS (Luo et al., 2006; Smith et al., 2016). Functionality to use the colormaps with matplotlib is included, as well as scripts that can be used from the 3D animation software Blender to design them.

2D colormaps are used to visualise images of two parameters at the same time, e.g.:

  • a complex function's magnitude and argument as a function of its real and imaginary part
  • a spatial map of windspeed and direction
  • a time-frequency image of a signals strength and phase (spectrogram)
  • a spatial map of seismic source energy and frequency.

Features

  • a growing set of carefully designed 2D colormaps
  • matplotlib style python functions to plot data using the 2D colormaps
  • 2D colormap designer based on the 3D animation software blender

Installation

The module can be installed directly from github using:

pip install git+https://github.com/MMesch/cmap_builder.git

Example

import numpy as np
import matplotlib.pyplot as plt
from colormap2d import imshow2d

# complex input data
x = np.linspace(-5, 5, 100)
regrid, imgrid = np.meshgrid(x, x)
zgrid = regrid + 1j * imgrid

complex_function = (zgrid ** 2 - 2.) * (zgrid - 1 - 1j) ** 2 /\
                   (zgrid + 2j) / (zgrid**2 - 5 - 2j)


# assemble [2, nwidth, nheight] array
data = np.array([np.angle(complex_function),
                 np.log(np.abs(complex_function))])

# plot to screen
imshow2d(data, cmap2d='wheel')
plt.show()

simple example

Blender Colormap Designer

The associated blender script allows to generate colormaps in the uniform colorspace CAM02-UCS (thank you colorspacious) by drawing a 3d spline path or a 3d spline surface in blender.

The most common 2D colormap used varies linearly in HSV/HSL colorspace. This colormap is unfortunately not very smooth visually. The following image shows a colormap that has been designed in blender. It starts at white and then goes into the six corners of the CAM02-UCS Gamut.

brightwheel2d

Blender designed colormaps are much smoother than the classical HSV colormap. The following comparison shows a complex polynomial that has poles. HSV is shown in the top row as reference.

poles and zeros function

Click here to see more colormaps in 3d colorspace.

Click here to see how to install and use the script.

cmap_builder's People

Contributors

mmesch 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.