Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement aesthetic options for "colour.plotting.RGB_chromaticity_coordinates_chromaticity_diagram_plot_*" definitions. #391

Closed
tashdor opened this issue Mar 2, 2018 · 20 comments

Comments

@tashdor
Copy link

tashdor commented Mar 2, 2018

It would be great to have control over some parameters when plotting RGB samples on a CIE1931 diagram:
style (x, +, or circle)
fill color (black, white, rgb source color)
size (relative or width in pixels)

@KelSolaar KelSolaar changed the title Implement aesthetic options for RGB_chromaticity_coordinates_chromaticity_diagram_plot_CIE1931 Implement aesthetic options for "colour.plotting.RGB_chromaticity_coordinates_chromaticity_diagram_plot_*" definitions. Mar 2, 2018
@KelSolaar KelSolaar added this to the v0.3.12 milestone Mar 2, 2018
KelSolaar added a commit that referenced this issue Mar 2, 2018
@KelSolaar
Copy link
Member

KelSolaar commented Mar 2, 2018

So I have added a scatter_parameters argument which get passed to pylab.scatter directly with defaults yielding the following plot:

Defaults

a = np.random.random((32, 32, 3))
RGB_chromaticity_coordinates_chromaticity_diagram_plot_CIE1931(a)

image

and with some customisations:

Custom Parameters

RGB_chromaticity_coordinates_chromaticity_diagram_plot_CIE1931(
    a,
    scatter_parameters={'c': 'black', 'marker':'+', 'alpha': 0.5}
)

image

This is available in latest develop branch.

@nick-shaw
Copy link
Contributor

Nice. I've ended up temporarily editing the parameters in the module before, to make the points more visible. Probably not an advised approach!

@KelSolaar
Copy link
Member

We might want to fine tune the defaults, the points were fine when plotting in Jupyter notebook but they are a tad big from command line right now.

@WilliamCoulter
Copy link

WilliamCoulter commented Mar 2, 2018 via email

@KelSolaar
Copy link
Member

@Willingo : Do you have an example image of what you are thinking about?

Cheers,

Thomas

@WilliamCoulter
Copy link

WilliamCoulter commented Mar 2, 2018 via email

@WilliamCoulter
Copy link

WilliamCoulter commented Mar 2, 2018 via email

@KelSolaar
Copy link
Member

@Willingo : Just to confirm, did you have something like that in mind?

image

image

@tashdor
Copy link
Author

tashdor commented Mar 2, 2018 via email

@KelSolaar
Copy link
Member

You could try RGB[::2, ::2, 3], RGB[::4, ::4, 3] to take every second or fourth pixels in the image, akin to nearest neighbour interpolation in Nuke or Photoshop. The clean way would be to resample the array with scipy.misc.imresize although I noticed it is on its way to deprecation.

@tashdor
Copy link
Author

tashdor commented Mar 2, 2018 via email

@KelSolaar
Copy link
Member

Sorry, my array slicing is incorrect, try something like that: RGB[::2, ::2]

@KelSolaar
Copy link
Member

I have updated the overall plotting and diagrams generation code, notable things:

  • The colour.plotting.DEFAULT_PLOTTING_COLOURSPACE attribute can be overriden to define the colourspace used to render the relevant figures colours.
  • The Chromaticity Diagram generation has been refactored so that tuning the Spectral Locus is easier:
import numpy as np
from colour.plotting import *

colour_plotting_defaults()

RGB = np.random.random((32, 32, 3))

RGB_colourspaces_chromaticity_diagram_plot_CIE1931(
    ['ITU-R BT.709', 'ACEScg', 'S-Gamut', 'Pointer Gamut'])

RGB_chromaticity_coordinates_chromaticity_diagram_plot_CIE1960UCS(
    RGB,
    'ITU-R BT.709',
    colourspaces=['ACEScg'],
    show_diagram_colours=False,
    spectral_locus_colours='RGB')

RGB_chromaticity_coordinates_chromaticity_diagram_plot_CIE1976UCS(
    RGB,
    'ITU-R BT.709',
    colourspaces=['ACEScg'],
    show_diagram_colours=False,
    spectral_locus_colours='RGB',
    spectral_locus_labels=[])

image

image

image

@tashdor
Copy link
Author

tashdor commented Mar 3, 2018

Thanks! This is fantastic!

@KelSolaar
Copy link
Member

Thanks @tashdor! If you need anything else, let me know, I haven't implemented @Willingo suggestions yet as I'm not sure about what he wanted.

@KelSolaar
Copy link
Member

Oh and I removed most (still a few to go through) of the unneeded hardcoded styling elements, thus you can override globally marker size, line width, etc...:

import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np

from colour.plotting import *

plt.style.use(['dark_background'])
mpl.rcParams['lines.linewidth'] = 1
mpl.rcParams['lines.markersize'] = 2

RGB = np.random.random((32, 32, 3))

RGB_chromaticity_coordinates_chromaticity_diagram_plot_CIE1960UCS(
    RGB,
    'ITU-R BT.709',
    colourspaces=['ACEScg'],
    spectral_locus_colours='white',
    grid=False)

image

@tashdor
Copy link
Author

tashdor commented Mar 3, 2018

Very cool. Is there a way to produce a diagram with alpha channel and with out the frame, header, or axes?

@KelSolaar
Copy link
Member

Something like that should do:

import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np

from colour.plotting import *

plt.style.use(['dark_background'])
mpl.rcParams['lines.linewidth'] = 1
mpl.rcParams['lines.markersize'] = 2

RGB = np.random.random((32, 32, 3))

figure = RGB_chromaticity_coordinates_chromaticity_diagram_plot_CIE1960UCS(
    RGB,
    'ITU-R BT.709',
    colourspaces=['ACEScg'],
    spectral_locus_colours='white',
    grid=False,
    title='',
    standalone=False,
    legend=False)

figure.patch.set_visible(False)
figure.gca().axis('off')
figure.tight_layout()

with open('/Users/kelsolaar/Downloads/diagram.png', 'w') as png_file:
    figure.canvas.print_png(png_file)

Chromaticity Diagram

@tashdor
Copy link
Author

tashdor commented Mar 3, 2018

Perfect!

@KelSolaar KelSolaar added P2 and removed Normal labels Mar 6, 2018
@KelSolaar
Copy link
Member

Closing this one for now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants