Class: PhotoUtils::Exposure

Inherits:
Object
  • Object
show all
Defined in:
lib/photo_utils/apex.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Exposure

Returns a new instance of Exposure.



47
48
49
50
51
# File 'lib/photo_utils/apex.rb', line 47

def initialize(params={})
  params.each do |key, value|
    send("#{key}=", value)
  end
end

Instance Attribute Details

#apertureObject

doug.kerr.home.att.net/pumpkin/APEX.pdf

http://en.wikipedia.org/wiki/APEX_system
http://en.wikipedia.org/wiki/Exposure_value
http://en.wikipedia.org/wiki/Light_meter#Exposure_meter_calibration

basic APEX formula:
  Ev = Tv + Av = Sv + Bv

logarithmic to linear equations:
  2^Av = N^2 (N is f-Number)
  2^Tv = 1/T (T in seconds)
  2^Sv = S/π (S is ASA film speed, now ISO)
  2^Bv = Bl (Bl in foot-lamberts) = B/π (B in candles per square foot)

base values:
  Tv = 0 for a time (shutter speed) of one second.
  Av = 0 for an aperture of f/1.
  Sv = 0 for a film speed of ISO 3.125 arithmetic (and hence Sv = 5 for ISO 100).
  Bv = 0 for a scene brightness of 1 foot-lambert.

calculate time from exposure and aperture
  Tv = Ev - Av

calculate time from brightness, sensitivity, and aperture
  Tv = (Sv + Bv) - Av

calculate brightness from Ev and sensitivity
  Bv = Ev - Sv

calculate Ev from aperture, time, and film speed
  Ev = (Tv + Av) - Sv


41
42
43
# File 'lib/photo_utils/apex.rb', line 41

def aperture
  @aperture
end

#compensationObject

Returns the value of attribute compensation.



45
46
47
# File 'lib/photo_utils/apex.rb', line 45

def compensation
  @compensation
end

#lightObject

Returns the value of attribute light.



44
45
46
# File 'lib/photo_utils/apex.rb', line 44

def light
  @light
end

#sensitivityObject

Returns the value of attribute sensitivity.



43
44
45
# File 'lib/photo_utils/apex.rb', line 43

def sensitivity
  @sensitivity
end

#timeObject

Returns the value of attribute time.



42
43
44
# File 'lib/photo_utils/apex.rb', line 42

def time
  @time
end

Instance Method Details

#avObject



142
143
144
# File 'lib/photo_utils/apex.rb', line 142

def av
  aperture.to_v
end

#brightnessObject



112
113
114
115
116
117
118
119
120
# File 'lib/photo_utils/apex.rb', line 112

def brightness
  if @light
    Brightness.new_from_v(lv)
  elsif @aperture && @time && @sensitivity
    Brightness.new_from_v(av + tv - sv + cv)
  else
    raise "Need aperture/time/sensitivity to compute brightness"
  end
end

#bvObject



154
155
156
# File 'lib/photo_utils/apex.rb', line 154

def bv
  brightness.to_v
end

#cvObject



166
167
168
# File 'lib/photo_utils/apex.rb', line 166

def cv
  @compensation ? @compensation.to_v : 0
end

#evObject



170
171
172
# File 'lib/photo_utils/apex.rb', line 170

def ev
  exposure
end

#ev100Object



174
175
176
# File 'lib/photo_utils/apex.rb', line 174

def ev100
  ev - sv - Sensitivity.new(100).to_v
end

#exposureObject



132
133
134
135
136
137
138
139
140
# File 'lib/photo_utils/apex.rb', line 132

def exposure
  if @aperture && @time
    av + tv
  elsif @sensitivity && @light
    sv + lv + cv
  else
    raise "Need aperture/time or sensitivity/light to compute exposure"
  end
end

#illuminanceObject



122
123
124
125
126
127
128
129
130
# File 'lib/photo_utils/apex.rb', line 122

def illuminance
  if @light
    Illuminance.new_from_v(lv)
  elsif @aperture && @time && @sensitivity
    Illuminance.new_from_v(av + tv - sv + cv)
  else
    raise "Need aperture/time/sensitivity to compute illuminance"
  end
end

#ivObject



158
159
160
# File 'lib/photo_utils/apex.rb', line 158

def iv
  illuminance.to_v
end

#lvObject



162
163
164
# File 'lib/photo_utils/apex.rb', line 162

def lv
  light.to_v
end


197
198
199
200
201
202
203
204
205
206
# File 'lib/photo_utils/apex.rb', line 197

def print(io=STDOUT)
  io.puts "EXPOSURE:"
  io.puts "            light: #{light} (#{light.format_value})"
  io.puts "      sensitivity: #{sensitivity} (#{sensitivity.format_value})"
  io.puts "         aperture: #{aperture} (#{aperture.format_value})"
  io.puts "             time: #{time} (#{time.format_value})"
  io.puts "     compensation: #{@compensation ? compensation.format_value : '--'}"
  io.puts "         exposure: #{to_s}"
  io.puts
end

#stepped_exposures(steps = 7, increment = 0.3) ⇒ Object



178
179
180
181
182
183
184
185
# File 'lib/photo_utils/apex.rb', line 178

def stepped_exposures(steps=7, increment=0.3)
  n = increment * (steps / 2)
  (-n..n).step(increment).map do |adjustment|
    new_exposure = dup
    new_exposure.compensation = PhotoUtils::Compensation.new_from_v((@compensation ? @compensation.to_v : 0) + adjustment)
    new_exposure
  end
end

#svObject



150
151
152
# File 'lib/photo_utils/apex.rb', line 150

def sv
  sensitivity.to_v
end

#to_sObject



187
188
189
190
191
192
193
194
195
# File 'lib/photo_utils/apex.rb', line 187

def to_s
  "%s = %s + %s = %s + %s" % [
    "Ev:#{ev.format(10)}",
    aperture.format_value,
    time.format_value,
    sensitivity.format_value,
    light.format_value,
  ]
end

#tvObject



146
147
148
# File 'lib/photo_utils/apex.rb', line 146

def tv
  time.to_v
end