SDK Question - Match Total Exposure

Explorer ,
Apr 15, 2022 Apr 15, 2022

Copy link to clipboard

Copied

Hey all! 

 

Looking for a little insight into the SDK regarding Match Total Exposure. Anyone know of a way to utilize Match Total Exposure within the SDK? Specifically for replicating the Match Total Exposure effect on a set by set basis automatically. Thanks for the insight. 

TOPICS
SDK

Views

352

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 15, 2022 Apr 15, 2022

Copy link to clipboard

Copied

Match Total Exposures adjusts the target photo's Exposure develop setting so that its effective exposure value is the same as that of the source photo.  Below is the code my Any Filter plugin uses for computing exposure value (EV) and effective exposure value.  You can get the shutter speed, aperture, and ISO using photo:getRawMetadata().

--[[----------------------------------------------------------------------------
public number 
ev (number shutterSpeed, number aperture, number iso)

Returns the exposure value of the shutterSpeed, aperture, and iso, or nil
if any one of them is nil.
------------------------------------------------------------------------------]]

function ExposureValue.ev (es, shutterSpeed, aperture, iso) 
    return (shutterSpeed and aperture and iso) and 
        log2 (aperture ^ 2 / shutterSpeed) - log2 (iso / 100) or nil
    end
    
--[[----------------------------------------------------------------------------
public number 
effectiveEV (number shutterSpeed, number aperture, number iso, 
    string processVersion, number exposure2012, number exposure)

Returns the effective exposure value, taking into account the additional
stops of the Develop setting "exposure2012" (if "processVersion" is "6.7")
or "exposure" (if "processVersion" is earlier).  Returns nil if any of the
arguments actually used to compute effective EV are nil.
------------------------------------------------------------------------------]]

function ExposureValue.effectiveEV (es, shutterSpeed, aperture, iso, 
        processVersion, exposure2012, exposure) 
    local processVersionNum = tonumber (processVersion) or 0
    local exp = processVersionNum >= 6.7 and exposure2012 or exposure
    return (shutterSpeed and aperture and iso and exp) and 
        ExposureValue.ev (es, shutterSpeed, aperture, iso) - exp or nil
    end
    

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 15, 2022 Apr 15, 2022

Copy link to clipboard

Copied

John,

 

Thank you again for your help. And just for my clarity, is this code affective for locating exposure for each photo in a set of images to ultimatley match the visual exposure of an 'anchor' image? I just want to make sure we are on the same page with the intended outcome. You've been a huge help. Thank you! 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 15, 2022 Apr 15, 2022

Copy link to clipboard

Copied

My point being I'm looking to locate the exposure for each image based on the visual exposure of the reference photo. This would be happening on a set by set basis. Anchor, set. Anchor, set. Goal being each sets exposure is cohesive and well matched. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 15, 2022 Apr 15, 2022

Copy link to clipboard

Copied

The code I posted just illustrates how to compute the effective exposure value for a photo.  From that, it should be straightforward to compute the adjustment to Exposure needed to make one photo's effective exposure value match another.  You'll have to use photo:getRawMetadata() to get the shutter speed, aperture, and ISO for each photo in a set.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 15, 2022 Apr 15, 2022

Copy link to clipboard

Copied

John,

 

Thank you. One more question while I have you. Do you have any similar code within your plugin that deals with matching WB or temp/tint effectively? I know it's a whole other animal but you seem to have the right approach. Appreciate any suggestions you have on matching temp/tint to a reference image for a set of images. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 16, 2022 Apr 16, 2022

Copy link to clipboard

Copied

I know very little about setting white balance algorithmically, other than that you can set Temperature/Tint via photo:applyDevelopSettings() (just as you can with Exposure2012).  From the little I've read here and other places, the very concept of "temperature" is squishy, in that for any given temperature, there is a broad range of "white" colors that are all deemed to have the same temperature; and cameras and software apps don't use the same algorithm for measuring temperature.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 16, 2022 Apr 16, 2022

Copy link to clipboard

Copied

All good John! I appreciate it. I'll look into the exposure and then start exploring some other options for temp and tint. All the best.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 17, 2022 Apr 17, 2022

Copy link to clipboard

Copied

@johnrellis,

 

I just have one more question for you regarding the SDK and our plugin. Do you know of the best approach for protecting/locking our plugin code to avoid having other developers ripping our full code? We have been looking into several options but I figured I'd ask if you were aware of any solutions that you've used with your plugin builds. Thanks! 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 17, 2022 Apr 17, 2022

Copy link to clipboard

Copied

I think most developers compile the their files into bytecodes using "luac", which is included in the SDK. While there are Lua bytecode decompilers, they're not perfect and they certainly don't result in very readable code.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 18, 2022 Apr 18, 2022

Copy link to clipboard

Copied

@johnrellis 

 

Thanks John! We were able to find our way forward with this. One more question for you: We have begun testing with the effective exposure calculation but are having trouble finding the correlation between effective exposure and the needed adjustment within LR's develop exposure setting to match anchor/reference photo with set. It seems effective exposure is on a range of -6 to +23 while in LR exposure has a range of -5 to +5. Any pointers on locating the correlation between the two? Thanks! In the meantime I am hunting for a pattern. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2022 Apr 18, 2022

Copy link to clipboard

Copied

[This post contains formatting and embedded images that don't appear in email. View the post in your Web browser.]

 

Have you verified that your calculation of the Exposure adjustment matches the adjustment made by Photo > Develop Settings > Match Total Exposures?

 

For example, I put two photos with much different exposure values in the Quick Collection:

johnrellis_0-1650297618365.png

I then did Match Total Exposures with the second photo most-selected, and it set Exposure of the first photo to -2.64:

johnrellis_4-1650297838830.png

 

johnrellis_2-1650297758743.png

 

I used the Any Filter plugin's Filter command to show the computed Exposure Value and Effective Exposure Value (which uses the code I posted above):

johnrellis_6-1650297961936.png

 

This shows that the difference in exposure values of the two photos is 2.644, which is the adjustment made by Match Total Exposures.

 

 

 

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 18, 2022 Apr 18, 2022

Copy link to clipboard

Copied

John, 

 

Thank you. I see. This example helped. I understand how this is working now. My concern for our use is that the matching of those total exposures worked on paper but visually looks more off than the images prior to the match total exposure function. I've found that calculating auto-exposure seems to be more effective than the match total exposure setting is some scenarios. 

 

I will keep fooling with this. My hope was that the bridging of effective exposures would in turn result in more visually similar exposures but from the example above it looks like the exposure visually is now further from being visually similar. Just curious if this is an expected outcome. It might not be the best fit for our needs but maybe I'm missing something. Thank you! 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2022 Apr 18, 2022

Copy link to clipboard

Copied

I don't have much practical experience with Match Total Exposure. I recall reading threads where people have time lapses taken with the camera's exposure set to Auto, so as the sun sets, the exposure value increases, producing discontinuities in the sequence of images as the camera changes the exposure.  Match Total Exposure appeared to have done a good job at making the images in the time lapse get progressively (and smoothly) darker as the sun sets.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 19, 2022 Apr 19, 2022

Copy link to clipboard

Copied

John,

 

Just wanted to thank you again. We've found our solution through some trial and error. All the best! 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2022 Apr 19, 2022

Copy link to clipboard

Copied

Just curious, what was the approach you took?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 19, 2022 Apr 19, 2022

Copy link to clipboard

Copied

We actually ended up using auto-exposure with some limiting values for our solution! It just ended up making more sense for our use internally. Appreciate your help though and I will absolutely be in touch with you as I have more questions. You know your stuff! 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 20, 2022 Apr 20, 2022

Copy link to clipboard

Copied

John,

 

I've got another question for you. Do you know any way of setting "auto White Balance" as a preset within LR. Currently each image needs to selected to apply auto WB. For Auto Exposure we are able to create a preset and apply to all at once. Any thoughts? Thanks so much! 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 20, 2022 Apr 20, 2022

Copy link to clipboard

Copied

[This post contains formatting and embedded images that don't appear in email. View the post in your Web browser.]

 

Start with a sample photo in Develop and set WB: Auto in the Basic panel. Then create a preset and check just White Balance:

johnrellis_0-1650469489067.png

 

That will set WB: Auto when you apply the preset, which will recompute the Temp and Tint for each target photo using the auto-white balance algorithm.

 

You can also do this within a plugin:

 

photo:applyDevelopSettings {WhiteBalance = "Auto"}

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 20, 2022 Apr 20, 2022

Copy link to clipboard

Copied

Thank you John! Perfect. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 22, 2022 Apr 22, 2022

Copy link to clipboard

Copied

@johnrellis 

 

Can I ask one more question regarding this AUTO WB. Do you know if there is a similar function/line of code for just applying the AUTO TEMP/AUTO TINT value separately? I was able to see that in LR you can manually hold shift and double click temp and tint to manually separate the two. Let me know if these functions are correct.

 

photo:applyDevelopSettings {temp = "Auto"}

photo:applyDevelopSettings {tint = "Auto"}

 

Thanks for your help on this! To give you a little background, currently the SDK is not allowing us to grab the correct value produced by AUTO TEMP. It is returning a crazy number like -999,999. I'm not sure what is causing the issue but looking for alternative methods to collecting the AUTO WB values for temp and tint within the SDK that are correct.

 

Let me know your thoughts! 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 23, 2022 Apr 23, 2022

Copy link to clipboard

Copied

"Do you know if there is a similar function/line of code for just applying the AUTO TEMP/AUTO TINT value separately?"

 

You can't do that directly. The only thing I can think of is to first get the current WhiteBalance, Temperture, Tint, IncrementalTemperature, and IncrementalTint settings returned by photo:getDevelopSettings(), then apply WhiteBalance = "Auto" as described in my last post, get the new temp/tint settings with photo:getDevelopSettings(), then restore the old temp and/or tint with photo:applyDevelopSettings().

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 23, 2022 Apr 23, 2022

Copy link to clipboard

Copied

I remembered that the sample code I posted for setting WB to Auto was wrong; it should be:

photo:applyDevelopSettings {WhiteBalance = "Auto", 
    Temperature = "", Tint = "",
    IncrementalTemperature = "", IncrementalTint = ""}

 

By setting the temp and tint settings to non-numeric invalid values, LR will recalculate the Auto values (this is undocumented, I discovered it by trial and error).

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

John, thank you, huge help! Let me give this a go tonight and see what success I have. Enjoy your weekend! 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

@johnrellis 

 

Just an update for you to see if I could get your thoughts. When we try to collect the AUTO WB values for temp and tint through this formula or via a preset of AUTO WB, we only get and are able to collect the auto values some of the time. To clarify, they are returning correctly to the LR sliders for each photo but they are not computing accurately on the backend from the SDK.

 

Here is an example of the values being returned when correct in the LR slider but way off on the backend. We can't pinpoint how to ensure the accurate returned values. We've even tried adding a a time break of upwards of 80 seconds for the values to compute correctly but no luck. AND we have had luck with auto-settings using this same principle. That is even more strange to me because auto-settings are returning many values correctly where AUTO WB cannot return temp and tint correctly.

 

INCORRECT VALUES

temperature: -999999,  Tint : -999999

 

Thoughts on this? Thanks so much. Just hitting a wall. 

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines