Class: Abachrome::Converters::LrgbToLms

Inherits:
Base
  • Object
show all
Defined in:
lib/abachrome/converters/lrgb_to_lms.rb

Instance Attribute Summary

Attributes inherited from Base

#from_space, #to_space

Class Method Summary collapse

Methods inherited from Base

#can_convert?, #convert, find_converter, #initialize, raise_unless, register

Constructor Details

This class inherits a constructor from Abachrome::Converters::Base

Class Method Details

.convert(lrgb_color) ⇒ Abachrome::Color

Converts a color from linear RGB color space to LMS color space.

This method converts linear RGB to XYZ first, then to LMS cone response space. The LMS color space represents the response of the three types of cone cells in the human eye (Long, Medium, Short wavelength sensitivity).

the same alpha as the input color

Parameters:

Returns:

Raises:

  • (ArgumentError)

    If the input color is not in linear RGB color space



16
17
18
19
20
21
22
23
24
# File 'lib/abachrome/converters/lrgb_to_lms.rb', line 16

def self.convert(lrgb_color)
  raise_unless lrgb_color, :lrgb

  # Convert linear RGB to XYZ first
  xyz_color = Converters::LrgbToXyz.convert(lrgb_color)

  # Then convert XYZ to LMS
  Converters::XyzToLms.convert(xyz_color)
end