Class: Vissen::Output::Filter::Gamma

Inherits:
Object
  • Object
show all
Includes:
Vissen::Output::Filter
Defined in:
lib/vissen/output/filter/gamma.rb

Overview

Applies gamma correction to the given PixelGrid.

Instance Attribute Summary collapse

Attributes included from Vissen::Output::Filter

#context

Instance Method Summary collapse

Constructor Details

#initialize(*args, value: 2.2) ⇒ Gamma

Returns a new instance of Gamma.

Parameters:

  • value (Float) (defaults to: 2.2)

    the gamma correction value.



15
16
17
18
19
20
21
# File 'lib/vissen/output/filter/gamma.rb', line 15

def initialize(*args, value: 2.2)
  super(*args)

  @value = value

  freeze
end

Instance Attribute Details

#valueFloat (readonly)

Returns the gamma correction value.

Returns:

  • (Float)

    the gamma correction value.



11
12
13
# File 'lib/vissen/output/filter/gamma.rb', line 11

def value
  @value
end

Instance Method Details

#apply(pixel_buffer) ⇒ Object

Applies the filter to the given pixel cloud.

Parameters:

  • pixel_buffer (PixelBuffer)

    the pixel buffer to perform the filter operation on.

See Also:



28
29
30
31
32
33
34
# File 'lib/vissen/output/filter/gamma.rb', line 28

def apply(pixel_buffer)
  pixel_buffer.each do |pixel|
    pixel.r = pixel.r**@value
    pixel.g = pixel.g**@value
    pixel.b = pixel.b**@value
  end
end