First crack at hack: .EV_calculator_01

Started by kbellis, January 22, 2014, 10:51:48 AM

Previous topic - Next topic

kbellis

Any help will be very greatly appreciated in my first attempt to make a little config hack that will:

1) report an image's EV
2) x,y coordinate pair for plotting where x is in time and y is an image's EV

The coordinate pair will allow anyone to map out the EV curve transitioning from before twilight's start, through sunrise to fully bright morning and better understand bulb ramping, a technique used in "flicker-free" timelapse photography. Ditto for going from bright afternoon, through sunset to twilight's end.

Thank you very much for any help.

Kelly

# Wednesday, January 22, 2014, 5:01 AM, VKB
# Notes on mapping EVs into a rectangular coordinate system to further study
# bulb ramping used in timelapse photography
#
# VALUE FOR x (time)
# In a spreadsheet, a cell would be specified which contains our Time
# for each image's origin expressed for example as G2 but for discussion
# shown here instead for clarity as hh:mm:ss
#
# Getting the time of day into a value for x
# Value_x=(((((SECOND(hh:mm:ss)/60)+MINUTE(hh:mm:ss))/60)+HOUR(hh:mm:ss)))/24*10000
#
# Note: There are 86,400 seconds in 24 hours so in the example above our
# integer values for x will be in increments equivalent to 8.64 seconds
# which will be fine with intervals between timelapse frame of 10 seconds
#
# That's fine for OpenOffice Calc, but how about getting this produced by ExifTool?
# And then the same question applies to the other intermediate steps listed below
# for y - how to write this in Perl and get it to work in ExifTool?
#
# First crack at custom tag hack for: .EV_calculator_01
# Many many thanks to Phil Harvey and ExifTool
#
# The %Image::ExifTool::UserDefined hash defines new tags to be added
# to existing tables.

%Image::ExifTool::UserDefined = (
    # All EXIF tags are added to the Main table, and WriteGroup is used to
    # specify where the tag is written (default is ExifIFD if not specified):
    'Image::ExifTool::Exif::Main' => {
        0xd000 => {
            Name => 'NewEXIFTag',
            Writable => 'int16u',
            WriteGroup => 'IFD0',
        },
        # add more user-defined EXIF tags here...
    },

# Composite tags are added to the Composite table:
  'Image::ExifTool::Composite' => {

      # We don't need the extension of the file, let's strip it off
         BaseName => {
            Require => {
                 0 => 'FileName',
            },
             # remove the extension from FileName
             ValueConv => '$val[0] =~ /(.*)\./ ? $1 : $val[0]',
        },

      # We'll need the time separated from the date
      # return the time from a date/time string
         Time => {
          Require => {
                 0 => 'DateTimeOriginal',
            },
             ValueConv => '$val =~ s/.* //; $val',
      },

# At this point it's quite murky and I have no idea how to deal with time
# in Perl, or even if it need be treated differently than any other number
# so maybe regex alone will do? ... FWIW, here's a leap into the leaf pile :)

     # Getting the time of day into a value for x
Time_into_x => {
   Require => {
    0 = 'Time',
   },
  # determine Time's fractional part of day and multiply by 10000
  #(((((ss/60)+mm)/60)+hh))/24*10000
    ValueConv => '$val =~ to be determined ',
},

# VALUE FOR y (EV corrected for ISO)
# In a spreadsheet, a cell would be specified which contains our ShutterSpeed
# and in another cell, Aperture for each image expressed for example as D2 and
# C2 but for discussion shown here instead for clarity as t and N respectively.
#
# First the EV_base value (otherwise displayed EV subscript 100)
# EV_base=LOG10(((N*N)/t))/LOG10(2)
#
# In a spreadsheet, a cell would be specified which contains our ISO value for
# each image expressed for example as E2 but for discussion shown here instead
# for clarity as ISO
#
# Second step is to calculate EV_ISO
# EV_ISO=EV_base-LOG10((ISO/100))/LOG10(2)
#
# Note: As of this writing, the Wikipedia page showing this calculation has the
# wrong algebraic sign. The main active author of that article has been notified.
# http://en.wikipedia.org/wiki/Exposure_value
#
# Further reading at photo.stackexchange found a much cleaner and clearer formula
# http://photo.stackexchange.com/questions/32359/why-does-ev-increase-as-iso-increases
# written by Matthew Miller in answer to the user's question:
#
# EV = log2(N²) + log2(1/t) - log2(100/S)
#
# And more tersely stated:
#
# EV = log2(N²/(t×(S/100)))
#
# For N we'll use 'aperturevalue', for t 'shutterspeedvalue' and for S 'ISO'

# First let's define EV
EV => {
   Require => {
    0 = 'aperturevalue',
    1 = 'shutterspeedvalue',
    2 = 'ISO',
},

# Again, I have no idea how to deal with doing this calculation with ExifTool and base 2 logs
# in Perl, or even if it's practical to consider doing so, but no harm in trying :)

# We'll use Matt's shorter formula: EV = log2(N²/(t×(S/100))) and adapt it to our tags:
# EV=(LOG10((aperturevalue*aperturevalue)/(shutterspeedvalue*(ISO/100))))/LOG10(2)
  ValueConv => '$val = to be determined ',
     }, 



# Now we can heighten or flatten the mapped EV curve for any given set of images as much as
# you like with a multiplier, shown here by a factor of 100 for the y coordinate

EV_into_y => {
   Require => {
    0 = 'EV',
},
  ValueConv => '$val = EV*100',
    },

);

kbellis

oops.. I think this was supposed to go at the end: 1;  #end

Phil Harvey

Hi Kelly,

ExifTool already has a built-in Composite:LightValue tag that does what I think you want your EV tag to do.

the "1;" at the end of the config file is not usually necessary, so you don't need to worry about it.  It is only required if the last expression in the file has a false value (which should never happen).

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

kbellis

Yes! Thank you so much :) That's great to hear - I'll look further into that.

First question
Is the built-in LightValue tag in the main program or the .ExifTool_config? and if it's in the main program is there anyway for me to look at the math being done?


Next question
I'm still wondering how to do this:

# Getting the time of day into a value for x
Time_into_x => {
   Require => {
    0 = 'Time',
   },
  # determine Time's fractional part of day and multiply by 10000
  #(((((ss/60)+mm)/60)+hh))/24*10000
    ValueConv => '$val =~ to be determined ', # <- help
},



Last question
and then there's my uncertainties about the last bit assuming the LightValue tag is appropriate:

# Now we can heighten or flatten the mapped EV curve for any given set of images as much as
# you like with a multiplier, shown here by a factor of 100 for the y coordinate

LightValue_into_y => {
   Require => {
    0 = 'LightValue',
},
  ValueConv => '$val = LightValue*100', <- is this form of incantation okay?
    },

);

Phil Harvey

Quote from: kbellis on January 22, 2014, 12:38:32 PM
First question
Is the built-in LightValue tag in the main program or the .ExifTool_config? and if it's in the main program is there anyway for me to look at the math being done?

It is in the main program.  See the Composite tags in Exif.pm.

QuoteNext question
I'm still wondering how to do this:


  ValueConv => 'my ($h,$m,$s) = split ":", $val; ((((($s/60)+$m)/60)+$h))/24*10000',


QuoteLast question


  ValueConv => '$val*100',


- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

kbellis

Awesome! I can't wait to get into this!!

Thank you very much Phil.

Kelly

kbellis

Quote from: Phil Harvey on January 22, 2014, 12:53:37 PM

It is in the main program.  See the Composite tags in Exif.pm.

The numbers look good :)

There is some behavior which strikes me a little odd.
If I call -LightValue, no ISO values are included.
If I call -ISO -LightValue, I get the ISO repeated three times. Weird, huh?


Phil Harvey

Quote from: kbellis on January 22, 2014, 07:06:27 PM
If I call -ISO -LightValue, I get the ISO repeated three times. Weird, huh?

This suggests that you have the example config file active, and that your file contains three ISO tags.  This config file enables the Duplicates option (like -a on the command line), otherwise only one would have been reported.

LightValue will be reported only if Aperture, ShutterSpeed and ISO all exist.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

kbellis

Yes, you nailed it exactly Phil and I've arrested the dupes with: Duplicates => 0, ... or at least until I'm instructed otherwise ;)

kbellis


Thank you Phil for all of your help. It's been tremendous fun! :)

I know that this may not look like much, but this graph is the 1st pair of coordinates created by ExifTool of the 120 images shot at 1 minute intervals on 1.19.2014 starting shortly before sunset and beyond twilight (16:18 - 18:18 EST). Briefly, the camera was in auto exposure mode (Av), single spot metering to document the EV (y) over time (x).

Details on this project still to come!

Kind regards,

Kelly


Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

kbellis

Thanks Phil.

We're getting closer and still some technical details to iron out; however, those issues seem suited to other avenues than ExifTool. But there is no question, none of these mad-scientist efforts could have been dreamed of without ExifTool.

I've written to Irfan Skiljan asking how it might be possible to get LightValue printed onto an image using IrfanView. He wrote back indicating that he'll try adding it to IrfanView's EXIF dialog/tags and asking for an image file with the imbedded LightValue saved in the Exif data - I'm not sure if ExifTool writes LightValue to the image file or just out.txt file - does it? - please let me know before I reply to Irfan. Thanks!

The second detail to be ironed out is in getting vector data plotted onto each image in the timelapse sequence. StarGeek mentioned ImageMagick and so I'm exploring that option as well.

Below is that same data set as above, but with the multiplier for y cut in half. This also shows a little more clearly where this study of transitioning EV curves is heading with many thanks to you Phil Harvey :)


Phil Harvey

Quote from: kbellis on January 23, 2014, 08:23:04 AM
I'm not sure if ExifTool writes LightValue to the image file or just out.txt file - does it?

LightValue is a Composite tag, calculated from the vales of other tags.  It is not a value stored in the image.  For a stored value, EXIF:BrightnessValue has a similar function.  See https://en.wikipedia.org/wiki/APEX_system#Use_of_APEX_values_in_Exif for more information.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

kbellis

Can a composite tag be stored in an image?

I can't seem to find BrightnessValue in this example - do I need a special call for it?
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\ExifTool>exiftool "C:\Users\V. Kelly Bellis\Pictures\1.19.2014 EV Session 1\jpg\4972.jpg"
ExifTool Version Number         : 9.46
File Name                       : 4972.jpg
Directory                       : C:/Users/V. Kelly Bellis/Pictures/1.19.2014 EV Session 1/jpg
File Size                       : 271 kB
File Modification Date/Time     : 2014:01:22 21:32:52-05:00
File Access Date/Time           : 2014:01:22 20:52:02-05:00
File Creation Date/Time         : 2014:01:22 20:52:02-05:00
File Permissions                : rw-rw-rw-
File Type                       : JPEG
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Exif Byte Order                 : Little-endian (Intel, II)
Make                            : Canon
Camera Model Name               : Canon EOS 5D Mark III
X Resolution                    : 300
Y Resolution                    : 300
Resolution Unit                 : inches
Software                        : Adobe Photoshop Camera Raw 8.1 (Windows)
Modify Date                     : 2014:01:22 20:52:02
Artist                          : V. Kelly Bellis
Copyright                       : Copyright - all rights reserved..Visit panocea.us for more info
Exposure Time                   : 3.2
F Number                        : 8.0
Exposure Program                : Aperture-priority AE
ISO                             : 1600
Sensitivity Type                : Recommended Exposure Index
Recommended Exposure Index      : 1600
Exif Version                    : 0230
Date/Time Original              : 2014:01:19 18:12:51
Create Date                     : 2014:01:19 18:12:51
Shutter Speed Value             : 3.2
Aperture Value                  : 8.0
Exposure Compensation           : 0
Max Aperture Value              : 4.0
Metering Mode                   : Partial
Flash                           : Off, Did not fire
Focal Length                    : 105.0 mm
Sub Sec Time Original           : 43
Sub Sec Time Digitized          : 43
Focal Plane X Resolution        : 80
Focal Plane Y Resolution        : 80
Focal Plane Resolution Unit     : mm
Custom Rendered                 : Normal
Exposure Mode                   : Auto
White Balance                   : Auto
Scene Capture Type              : Standard
Owner Name                      : V. Kelly Bellis
Serial Number                   : 022031004924
Lens Info                       : 24-105mm f/?
Lens Model                      : EF24-105mm f/4L IS USM
Lens Serial Number              : 000040cc16
Compression                     : JPEG (old-style)
Thumbnail Offset                : 1020
Thumbnail Length                : 13682
XMP Toolkit                     : Adobe XMP Core 5.5-c002 1.148022, 2012/07/15-18:06:45
Creator Tool                    : Adobe Photoshop Camera Raw 8.1 (Windows)
Metadata Date                   : 2014:01:22 20:52:02-05:00
Format                          : image/jpeg
Lens                            : EF24-105mm f/4L IS USM
Image Number                    : 0
Approximate Focus Distance      : 4294967295
Flash Compensation              : 0
Firmware                        : 1.2.3
Document ID                     : xmp.did:2ebdcc3d-4319-e64f-9647-0aac12eb17e5
Original Document ID            : 4EDD8C25FD17D20E5C36387FD6020CA2
Instance ID                     : xmp.iid:2ebdcc3d-4319-e64f-9647-0aac12eb17e5
Raw File Name                   : _5D34972.CR2
Version                         : 8.1
Process Version                 : 6.7
Color Temperature               : 3550
Tint                            : +46
Saturation                      : 0
Sharpness                       : 25
Luminance Smoothing             : 0
Color Noise Reduction           : 25
Vignette Amount                 : 0
Shadow Tint                     : 0
Red Hue                         : 0
Red Saturation                  : 0
Green Hue                       : 0
Green Saturation                : 0
Blue Hue                        : 0
Blue Saturation                 : 0
Vibrance                        : 0
Hue Adjustment Red              : 0
Hue Adjustment Orange           : 0
Hue Adjustment Yellow           : 0
Hue Adjustment Green            : 0
Hue Adjustment Aqua             : 0
Hue Adjustment Blue             : 0
Hue Adjustment Purple           : 0
Hue Adjustment Magenta          : 0
Saturation Adjustment Red       : 0
Saturation Adjustment Orange    : 0
Saturation Adjustment Yellow    : 0
Saturation Adjustment Green     : 0
Saturation Adjustment Aqua      : 0
Saturation Adjustment Blue      : 0
Saturation Adjustment Purple    : 0
Saturation Adjustment Magenta   : 0
Luminance Adjustment Red        : 0
Luminance Adjustment Orange     : 0
Luminance Adjustment Yellow     : 0
Luminance Adjustment Green      : 0
Luminance Adjustment Aqua       : 0
Luminance Adjustment Blue       : 0
Luminance Adjustment Purple     : 0
Luminance Adjustment Magenta    : 0
Split Toning Shadow Hue         : 0
Split Toning Shadow Saturation  : 0
Split Toning Highlight Hue      : 0
Split Toning Highlight Saturation: 0
Split Toning Balance            : 0
Parametric Shadows              : 0
Parametric Darks                : 0
Parametric Lights               : 0
Parametric Highlights           : 0
Parametric Shadow Split         : 25
Parametric Midtone Split        : 50
Parametric Highlight Split      : 75
Sharpen Radius                  : +1.0
Sharpen Detail                  : 25
Sharpen Edge Masking            : 0
Post Crop Vignette Amount       : 0
Grain Amount                    : 0
Color Noise Reduction Detail    : 50
Lens Profile Enable             : 1
Lens Manual Distortion Amount   : 0
Perspective Vertical            : 0
Perspective Horizontal          : 0
Perspective Rotate              : 0.0
Perspective Scale               : 100
Perspective Aspect              : 0
Perspective Upright             : 0
Auto Lateral CA                 : 1
Exposure 2012                   : +1.00
Contrast 2012                   : 0
Highlights 2012                 : 0
Shadows 2012                    : 0
Whites 2012                     : 0
Blacks 2012                     : 0
Clarity 2012                    : 0
Defringe Purple Amount          : 0
Defringe Purple Hue Lo          : 30
Defringe Purple Hue Hi          : 70
Defringe Green Amount           : 0
Defringe Green Hue Lo           : 40
Defringe Green Hue Hi           : 60
Convert To Grayscale            : False
Tone Curve Name 2012            : Linear
Camera Profile                  : Adobe Standard
Camera Profile Digest           : 87FB0EDC503E332309FB5DE5C5C65125
Lens Profile Setup              : LensDefaults
Lens Profile Name               : Adobe (Canon EF 24-105mm f/4 L IS USM)
Lens Profile Filename           : Canon EOS-1Ds Mark III (Canon EF 24-105mm f4 L IS USM) - RAW.lcp
Lens Profile Digest             : 0387279C5E7139287596C051056DCFAF
Lens Profile Distortion Scale   : 100
Lens Profile Chromatic Aberration Scale: 100
Lens Profile Vignetting Scale   : 100
Upright Version                 : 134217728
Upright Center Mode             : 0
Upright Center Norm X           : 0.5
Upright Center Norm Y           : 0.5
Upright Focal Mode              : 0
Upright Focal Length 35mm       : 35
Upright Preview                 : False
Upright Transform Count         : 0
Has Settings                    : True
Has Crop                        : False
Already Applied                 : True
Creator                         : V. Kelly Bellis
Rights                          : Copyright - all rights reserved..Visit panocea.us for more info
History Action                  : derived, saved
History Parameters              : converted from image/x-canon-cr2 to image/jpeg, saved to new location
History Instance ID             : xmp.iid:2ebdcc3d-4319-e64f-9647-0aac12eb17e5
History When                    : 2014:01:22 20:52:02-05:00
History Software Agent          : Adobe Photoshop Camera Raw 8.1 (Windows)
History Changed                 : /
Derived From Document ID        : 4EDD8C25FD17D20E5C36387FD6020CA2
Derived From Original Document ID: 4EDD8C25FD17D20E5C36387FD6020CA2
Tone Curve PV2012               : 0, 0, 255, 255
Tone Curve PV2012 Red           : 0, 0, 255, 255
Tone Curve PV2012 Green         : 0, 0, 255, 255
Tone Curve PV2012 Blue          : 0, 0, 255, 255
Displayed Units X               : inches
Displayed Units Y               : inches
Current IPTC Digest             : 32eca628dd67571b1e3cc8d54009215e
Coded Character Set             : UTF8
Application Record Version      : 4
Date Created                    : 2014:01:19
Time Created                    : 18:12:51
Digital Creation Date           : 2014:01:19
Digital Creation Time           : 18:12:51
By-line                         : V. Kelly Bellis
Copyright Notice                : Copyright - all rights reserved..Visit panocea.us for more info
Photoshop Thumbnail             : (Binary data 13682 bytes, use -b option to extract)
IPTC Digest                     : 32eca628dd67571b1e3cc8d54009215e
Image Width                     : 1620
Image Height                    : 1080
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Aperture                        : 8.0
Date/Time Created               : 2014:01:19 18:12:51
Digital Creation Date/Time      : 2014:01:19 18:12:51
Image Size                      : 1620x1080
Scale Factor To 35 mm Equivalent: 1.8
Shutter Speed                   : 3.2
Create Date                     : 2014:01:19 18:12:51.43
Date/Time Original              : 2014:01:19 18:12:51.43
Thumbnail Image                 : (Binary data 13682 bytes, use -b option to extract)
Circle Of Confusion             : 0.017 mm
Field Of View                   : 11.0 deg
Focal Length                    : 105.0 mm (35 mm equivalent: 186.7 mm)
Hyperfocal Distance             : 81.54 m
Lens ID                         : Canon EF 24-105mm f/4L IS
Light Value                     : 0.3

C:\ExifTool>

Phil Harvey

No.  You won't see it if it isn't there.  Not many cameras write this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).