Class: Quadtone::Separator
- Inherits:
-
Object
- Object
- Quadtone::Separator
- Defined in:
- lib/quadtone/separator.rb
Instance Attribute Summary collapse
-
#luts ⇒ Object
Returns the value of attribute luts.
Instance Method Summary collapse
-
#initialize(curve_set) ⇒ Separator
constructor
A new instance of Separator.
- #separate(image) ⇒ Object
Constructor Details
#initialize(curve_set) ⇒ Separator
Returns a new instance of Separator.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/quadtone/separator.rb', line 7 def initialize(curve_set) @luts = {} curve_set.curves.each do |curve| color_map = Magick::Image.new(curve.num_samples, 1) do self.colorspace = Magick::GRAYColorspace end color_map.pixel_interpolation_method = Magick::IntegerInterpolatePixel color_map.view(0, 0, curve.num_samples, 1) do |view| curve.samples.each_with_index do |sample, i| value = ((1 - sample.output.value) * 65535).to_i view[0][curve.num_samples - 1 - i] = Magick::Pixel.new(value, value, value) end end @luts[curve.channel] = color_map end end |
Instance Attribute Details
#luts ⇒ Object
Returns the value of attribute luts.
5 6 7 |
# File 'lib/quadtone/separator.rb', line 5 def luts @luts end |
Instance Method Details
#separate(image) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/quadtone/separator.rb', line 24 def separate(image) images = {} @luts.each do |channel, lut| image2 = image.copy.clut_channel(lut) image2['Label'] = channel.to_s.upcase images[channel] = image2 end images end |