Log in

View Full Version : detect bright/dark


fenomeno83
30th September 2017, 15:04
Hi.
Do you know some algorithm/plugin to delect if a frame/image is dark or bright?
something that calculates a value of "dark" or "bright" perception.

thanks

StainlessS
30th September 2017, 15:44
Have you tried AverageLuma, http://avisynth.nl/index.php/Internal_functions#Average
(required for use in eg Scriptclip) See also the following few functions.

fenomeno83
1st October 2017, 14:41
Hi...I need to use in a visual studio c++ project

IScriptEnvironment* env = CreateScriptEnvironment();
AVSValue input = env->Invoke("ImageReader", filename);

input = env->Invoke("ConvertToYV12", input);

AVSValue luma = env->Invoke("AverageLuma", input);

but I've this error: Average Plan: this filter can only be used within runtime filters...

I've no problem with others filters,plugin.
how can use AverageLuma?

Thanks

fenomeno83
1st October 2017, 21:18
Hi..i've tried averageluma, but i don't like for my purpouse.
I need something more intellingent:
For example if i have a subject with over exposure, but in "dark" background(for example when you make a photo with flash; a close up face ), the average luma is low, but i need to understand that the image is bright..

Thanks

wonkey_monkey
1st October 2017, 22:57
You'll first need to decide how you want to define "bright" and "dark," then. Is it when 50% of pixels are brighter than 128? Or 25%? Or 10%?

Or maybe there isn't an answer, because it depends too much on subjective judgement.

fenomeno83
2nd October 2017, 07:31
Something like this
https://stackoverflow.com/questions/14243472/estimate-brightness-of-an-image-opencv/22020098#22020098

raffriff42
2nd October 2017, 12:17
My approach is:
* Find histogram maximum (HMax) using threshold for removing hot pixels.
* Calculate mean values of all pixel between HMax * 2/3 and HMax
Something like this?
https://www.dropbox.com/s/19cn1p9uql1gwu4/adj-mean-sintel-2924.jpg?raw=1 https://www.dropbox.com/s/47g7m4vvem38jst/adj-mean-sintel-2974.jpg?raw=1
ScriptClip(Last, """
Grayscale
## histogram maximum (HMax) using threshold for removing hot pixels.
hmax = YPlaneMax(threshold=1.0)

## mean value of all pixels between HMax * 2/3 and HMax
max2 = 0.667*hmax
sclip = Levels(Round(max2), 1.0, hmax, 0, 255, coring=false)
smean = sclip.AverageLuma * (hmax-max2)/256.0 + max2

#BlankClip(Last, color_yuv=(Round(smean)*$10000) + (128*$100) + 128)

Subtitle("adj. mean =",
\ size=Height/12, align=8, text_color=$33e0e0e0)
Subtitle(
\ String(smean, "%0.3f"),
\ size=Height/8, align=8, y=Height/8, text_color=$33e0e0e0)
""")

fenomeno83
2nd October 2017, 12:58
YOU'RE GREAT!!! THANKS!
I'll try your script

StainlessS
2nd October 2017, 13:31
Great stuff Raff.

Below an alternative of same script but using Eval instead of ScriptClip, but pretty much as Raff script (processes single frame 0 only, no matter how long clip is).

FN="a.jpg"
#FN="b.jpg"

ImageSource(FN,end=0).ConvertToYv12

Crop(0,96,0,0) # Crop existing metrics off Raff's images

SSS="""
### CONFIG ###
current_frame = 0 # Simulate within ScriptClip, (set dummy run time frame number)
HOTTHRESH = 1.0 # Ignore up to 1.0% of HOT PIXELS when getting max
HMUL = 0.667
##############

Grayscale
## histogram maximum (HMax) using threshold for removing hot pixels.
hmax = YPlaneMax(threshold=HOTTHRESH)

## mean value of all pixels between HMax * 2/3 and HMax
max2 = HMUL*hmax
sclip = Levels(Round(max2), 1.0, hmax, 0, 255, coring=false)
smean = sclip.AverageLuma * (hmax-max2)/256.0 + max2

#BlankClip(Last, color_yuv=(Round(smean)*$10000) + (128*$100) + 128)

Subtitle("adj. mean =",
\ size=Height/12, align=8, text_color=$33e0e0e0)
Subtitle(
\ String(smean, "%0.3f"),
\ size=Height/8, align=8, y=Height/8, text_color=$33e0e0e0)
return last
"""

Eval(SSS)


I guess that you could return a number, and collect within CPP as an AVSValue.AsInt. EDIT: AVSValue.AsFloat

fenomeno83,
When you first posted, I said as afterthought that your thread should not be in Devs forum, but in Usage or Newbie forum. On exit,
I found that thread had already been moved to Usage by Wilbert(Moderator), and so deleted that comment.
It took us till post #4 to find out what your requirement actually was, and that it really should have been in Devs forum.
Maybe you should be a little more explicit in first post what it is that you actually want.

StainlessS
2nd October 2017, 13:48
Simulated CPP use,


# Req RT_Stats:- http://forum.doom9.org/showthread.php?t=165479&highlight=rt_Stats

A=ImageSource("a.jpg",end=0)
B=ImageSource("b.jpg",end=0)

A++B # Make 2 frame clip

ConvertToYv12.Crop(0,96,0,0) # Crop existing metrics off Raff's images

# Template String
SSS="""
### CONFIG ###
current_frame = %d # Simulate within ScriptClip, (set dummy run time frame number)
HOTTHRESH = %f # Ignore up to 1.0 Percent of HOT PIXELS when getting max
HMUL = %f
##############

Grayscale
## histogram maximum (HMax) using threshold for removing hot pixels.
hmax = YPlaneMax(threshold=HOTTHRESH)

## mean value of all pixels between HMax * 2/3 and HMax
max2 = HMUL*hmax
sclip = Levels(Round(max2), 1.0, hmax, 0, 255, coring=false)
smean = sclip.AverageLuma * (hmax-max2)/256.0 + max2
return smean
"""

# Simulate CPP usage (Requires GSCript:- http://forum.doom9.org/showthread.php?t=147846&highlight=GSCript)
GSCript("""
for(i=0,Last.FrameCount-1) {
S=RT_String(SSS, i, 1.0, 2.0/3.0) # set configs [EDIT: As for sprintf.]
smean = Last.Eval(S) # Simulated CPP call to get smean for frame i.
RT_DebugF("%d] SMean = %f",i,smean) # Requires DebugView:- https://docs.microsoft.com/en-us/sysinternals/downloads/debugview
}
""")

Return MessageClip("ALL DONE, See DebugView")


EDIT:
Debugview Output (top of frames cropped so diff to orig Raff's image results)

00000007 382.33502197 [3644] RT_DebugF: 0] SMean = 59.007420
00000008 382.35046387 [3644] RT_DebugF: 1] SMean = 98.937561


EDIT: Not sure if below would work, (Gavino would defo know)

# Req RT_Stats:- http://forum.doom9.org/showthread.php?t=165479&highlight=rt_Stats

A=ImageSource("a.jpg",end=0)
B=ImageSource("b.jpg",end=0)

A++B # Make 2 frame clip

ConvertToYv12.Crop(0,96,0,0) # Crop existing metrics off Raff's images

# Function, Not sure how to add this in CPP, Maybe an Eval would work, maybe not.
Func_S="""
Function MyFunc(clip c, Int n, Float Th, Float HMul) {
c
n = (n < 0) ? 0 : (n >= FrameCount) ? FrameCount-1 : n # Range limit n
current_frame = n
## histogram maximum (HMax) using threshold for removing hot pixels.
hmax = YPlaneMax(threshold=Th)
## mean value of all pixels between HMax * 2/3 and HMax
max2 = HMul*hmax
sclip = Levels(Round(max2), 1.0, hmax, 0, 255, coring=false)
Return sclip.AverageLuma * (hmax-max2)/256.0 + max2
}
"""

Eval(Func_S) # make permanently available function

# Simulate CPP usage (Requires GSCript:- http://forum.doom9.org/showthread.php?t=147846&highlight=GSCript)
GSCript("""
HOTTHRESH = 1.0 # Ignore up to 1.0 Percent of HOT PIXELS when getting max
HMUL = 2.0/3.0
for(i=0,Last.Framecount-1) {
S=RT_String("MyFunc(%d,%f,%f)", i, HOTTHRESH, HMUL) # Func call string : RT_String == sprintf
#S=String(i,"MyFunc(%.0f,")+String(HOTTHRESH,"%f,")+String(HMUL,"%f)") # Alternative without RT_Stats, but still required for RT_DebugF()
smean = Last.Eval(S) # Simulated CPP call to get smean for frame i.
RT_DebugF("%d] SMean = %f",i,smean) # Requires DebugView:- https://docs.microsoft.com/en-us/sysinternals/downloads/debugview
}
""")

Return MessageClip("ALL DONE, See DebugView")

fenomeno83
2nd October 2017, 16:32
Thank you all guys!!

Gavino
2nd October 2017, 19:42
Not sure if below would work, (Gavino would defo know)
Do you mean the bit about Invoke'ing Eval() with the function text to get the function declared when using CPP?
Yes, that should work.

StainlessS
2nd October 2017, 20:20
Yep, thats what i meant, thanx big G.

Mobile,

fenomeno83
2nd October 2017, 20:21
mmm...seems that the algorithm doesn't reach my purpouse..
consider these 4 images:
1)
https://preview.ibb.co/nvX3WG/1.jpg
2)
https://preview.ibb.co/b6GYyw/2.jpg
3)
https://preview.ibb.co/fXdJWG/3.jpg
4)
https://preview.ibb.co/hpxCrG/4.jpg

Here original images:
https://www.dropbox.com/s/dev79m0ve0c623l/img.zip?dl=0

I get respectively 159,161,168 and 161.
Values seems close. Am I wrong something?

I'd like something that help me to understand automatically:
1° image is very dark (so I need to increase brightness/contrast), 2° image is good or a little over exposed, 3° a little dark, 4° is good

lansing
2nd October 2017, 22:03
You suppose to be able to fix it with highlightlimiter (https://forum.doom9.org/showpost.php?p=1574765&postcount=60)+ raising the gamma
highlightlimiter()
Levels(0, 1.6, 255, 0, 255)


But highlightlimiter is forever loading with image inputs, don't know why.

StainlessS
2nd October 2017, 23:23
https://s20.postimg.cc/n43z6eltp/img_0001.jpg (https://postimages.cc/)

https://s20.postimg.cc/4ptg2f9j1/img_0002.jpg (https://postimages.cc/)

https://s20.postimg.cc/6vnqwxczh/img_0003.jpg (https://postimages.cc/)

https://s20.postimg.cc/5vxg17xtp/img_0004.jpg (https://postimages.cc/)

I guess that assigning exposure quality based on pixel count/histogram is prone to error.
Above, only #2 shows distinctly overbright (brightness added to ALL luma levels). EDIT: Quote "2° image is good or a little over exposed".
Perhaps only something like OpenCV library (or similar) that compare with huge database of images (looking for similar image),
could (perhaps) reduce number of erroneous guesses. [ EDIT: Assuming OpenCV lib does have that capability. ]

EDIT: Based only on above (luma) histograms, how would you create a rule to get it always correct ?
EDIT: Also consider two perfectly exposed images,
#1) Star on black sky,
#2) House fly on hospital wall.

EDIT: I'm no photographer and have no idea at all how one would perfectly expose #3 (on camera shoot).
Perhaps #3 is the one lansing was talking about with highlightlimiter (or maybe #1).

EDIT: Lansing script, does indeed fix #1 and #3 a bit.

function HighlightLimiter(clip v, float "gblur", bool "gradient", int "threshold", bool "twopass", int "amount", bool "softlimit", int "method")
{
gradient = default (gradient,true) #True uses the gaussian blur to such an extent so as to create an effect similar to a gradient mask being applied to every area that exceeds our threshold.
gblur = (gradient==true) ? default (gblur,100) : default (gblur,5.0) #The strength of the gaussian blur to apply.
threshold = default (threshold,150) #The lower the value, the more sensitive the filter will be.
twopass = default (twopass,false) #Two passes means the area in question gets darkened twice.
amount = default (amount,10) #The amount of brightness to be reduced, only applied to method=2
softlimit = default (softlimit,false) #If softlimit is true, then the values around the edges where the pixel value differences occur, will be averaged.
method = default (method, 1) #Method 1 is multiply, the classic HDR-way. Any other method set triggers a brightness/gamma approach.

amount = (amount>0) ? -amount : amount

darken=v.Tweak(sat=0).mt_lut("x "+string(threshold)+" < 0 x ?")
blurred= (gradient==true) ? darken.gaussianblur(gblur).gaussianblur(gblur+100).gaussianblur(gblur+200) : darken.gaussianblur(gblur)
fuzziness_mask=blurred.mt_edge(mode="prewitt", Y=3, U=2, V=2).mt_expand(mode="both", Y=3, U=2, V=2)
multiply = (method==1) ? mt_lut(v,"x x * 255 /") : v.Tweak(bright=amount)
multiply = (method==1) ? eval("""
(twopass==true) ? mt_lutxy(multiply,v,"x y * 255 /") : multiply""") : eval("""
(twopass==true) ? multiply.SmoothLevels(gamma=0.9,smode=2) : multiply""")

merged=mt_merge(v,multiply,blurred)
fuzzy= (softlimit==true) ? mt_merge(merged,mt_lutxy(v,merged,"x y + 2 /"),fuzziness_mask) : merged
return fuzzy
}

A=ImageSource("1.jpg",end=0) B=ImageSource("2.jpg",end=0) C=ImageSource("3.jpg",end=0) D=ImageSource("4.jpg",end=0) A++B++C++D

ConvertToYv12

O=Last

highlightlimiter()
Levels(0, 1.6, 255, 0, 255)

StackVertical(O,Last)


#3
https://s20.postimg.cc/oqt6rmxvh/img_0005.jpg (https://postimages.cc/)

raffriff42
3rd October 2017, 00:55
I'd like something that help me to understand automatically:
1° image is very dark (so I need to increase brightness/contrast), 2° image is good or a little over exposed, 3° a little dark, 4° is goodTry different numeric functions. I used yours, since you seemed to be very specific. A simple AverageLuma would probably work better for your purposes.

And you did not ask about correction, only detection. Correction of a badly backlit subject like you have here will be -- at best -- a tradeoff between showing the subject and blowing out the background.

Here's a manual correction with brighter foreground, but blown-out windows and a washed-out appearance. It took some fiddling to get even that.
https://www.dropbox.com/s/3l428tuwhv9ktcd/backlighting1-03%20AVS-BB.jpg?raw=1

StainlessS
3rd October 2017, 01:05
Lansing/Javlak correction for #1.

https://s20.postimg.cc/w82e6unel/img_0006.jpg (https://postimages.cc/)

lansing
3rd October 2017, 02:02
I also did some gamma tests between the internal levels(), smoothlevels() and the levels in photoshop. They all produced different results with the same gamma.

The internal levels has no limiting, when you have a big gamma increase like >2.0, the dark would also became brighter, so that's not good.

Smoothlevels has limiting and smoothing, so it's able to keep the darks in place even with big gamma increases, and the smoothing help prevent artifacts. But the downside is that it desaturate the color.

Photoshop's levels has dark limiting, smoothing and preserved saturation.

Photoshop's levels with gamma 2.08
https://i.imgur.com/9BiJQCLh.png

It has better color compares to the other two.

So to the OP, if you're just doing it with photos, sticks with photoshop or lightroom, they'll give you better results. And I think lightroom has feature to deal with overexposed highlight too.

poisondeathray
3rd October 2017, 04:44
Is he just looking for "perception" detection , or actually doing something about it ?

fenomeno83
3rd October 2017, 09:52
I need to understand just "perception"..need to understand how much a photo is dark or how much is brigh..
but I like also some suggestions of "how to do"

fenomeno83
3rd October 2017, 12:50
first post was not so clear what is my main purpouse..
I need to create a script that works good with "any" image..

I found a good mix (thanks to new lansing suggestion, too) that works pretty good with several photos, in different condition.

image = ImageReader("1.jpg")
image = ConvertToYV12(image)
image = Levels(image,0, 1.1, 255, 0, 255)
image = HDRAGC(image,corrector=0.8,protect=1,reducer=1.5,coeff_gain=0.0,min_gain=1.0)
image = Autolevels(image)
image = Tweak(image,0.0,1.0,-5.0,1.0)
image = ConvertToRGB(image)
ImageWriter(image,"1.jpg",0,0,"bmp)

(after I use a sharpener and denoiser)

So, my steps are:
1) change manually a little levels
2)use HDRAGC to equalize shadows
3)use autolevel to rebalance photo
4) tweak brighness (-5.0) to remove overbright caused by Levels

I've no problem if noise is increased; after I apply an intelligent noise removal using neatimage command line app...

Have you any suggestion about values/filters to use?

thanks

EDIT: I want to try and the end of script, HighlightLimiter with mod of travolter https://forum.doom9.org/showpost.php?p=1621040&postcount=70
seems works good and fast

fenomeno83
3rd October 2017, 17:25
EDIT: after test with highlightlimiter, I decided to don't use it..it generates a lot of artifact..
for example you can see in this image
https://ibb.co/mO5p6G

johnmeyer
3rd October 2017, 18:43
The test images posted by the OP show why HDR was invented. That is what is needed to fix his problems.

True High Dynamic Range is created by taking three or more exposures of the same scene, with the extra exposures being over- and under-exposed. The HDR algorithm then intelligently combines those multiple exposures into one picture. Here is an HDR photo I took several years ago inside a dark cabin overlooking the brightly-lit ocean. Note that you can see details in the dark shadows under the tables, while still seeing full details outside in the mid-day sun. Note also how the bright skylight sunlight on the floor of the cabin is nicely exposed rather than being totally bleached out:

http://i177.photobucket.com/albums/w208/johnmeyer/2011%20September%20Big%20Sur%2005%20HDR_zps09fulm7b.jpg

HDR can be simluated, although not fully duplicated, with algorithms that attempt to intelligently stretch the histogram of a single photo. Obviously there is a limit to this "poor man's HDR" because without the multiple exposures, you can never get well-exposed highlights and shadows, the way you can with real HDR.

So, to solve the OP's problem, he needs to search this forum for "HDR" or simply Google "HDR AVISynth".

wonkey_monkey
3rd October 2017, 20:54
True High Dynamic Range

I don't know if I'd call it "true." It's "just" another way of squeezing 14+ bits of range into 8 bits.

Now we're finally getting displays which finally can truly display such a range of brightness - that's what I'd call "real" HDR.

PS Fusion (http://forum.doom9.org/showthread.php?t=152109) may be of some limited use here.

johnmeyer
4th October 2017, 00:13
I only used the word "true" in order to distinguish it from the "HDR" that is promised, but not delivered, by algorithms that attempt to monkey with the histogram on a single photo in order to approximate what you get by merging multiple images that were taken using multiple exposures. The "real" HDR has almost an infinite dynamic range, something even the most sophisticated sensor cannot achieve. HDR can be any number of bits, so that isn't the important issue. The real issue has to do with how any medium -- digital or film -- records light, and how the limitations at the light and dark ends of the spectrum ultimately keep that medium from recording all the information that is in front of the camera.

fenomeno83
4th October 2017, 00:42
In my case i need highlightlimiter(the opposite of "highlighter)..that script works good but create artifacts..
Maybe i've to.read this thread where other users had similar problem
https://forum.doom9.org/showthread.php?t=161986&page=2

raffriff42
4th October 2017, 03:38
I have an alternative, called SmoothLimiter
https://forum.doom9.org/showthread.php?p=1781642#post1781642
Version 2 should prevent any discontinuities in the transfer function, which is the cause the the artifacts you see.
Plus it supports high bit depth. Don't know if it will solve your problem though.
(EDIT unlike HighlightLimiter, it does not do local contrast enhancement)

It requires MaskTools 2.2x (http://avisynth.nl/index.php/MaskTools2), AVS+ (http://avisynth.nl/index.php/AviSynth%2B), and you also need Utils-r41.avsi (http://avisynth.nl/images/Utils-r41.avsi)

Here's an example of a similar artifact, created with SmoothLimiter v1 and a poor choice of arguments -
note the break in the transfer function:
https://www.dropbox.com/s/lca5k06rlun1n4u/backlighting1-20%20limiter-error.jpg?raw=1

Here it is with SmoothLimiter v2 (also, banding is reduced by using 16bit color depth)
https://www.dropbox.com/s/9lkmdt3kazummpj/backlighting1-21%20limiter-fix.jpg?raw=1

Here's the script I used. Functions in blue are from http://avisynth.nl/images/Utils-r41.avsi
ConvertToPlanarRGBA
ConvertBits(16)
ConvertToYUV444(matrix="Rec709")
StackVertical(Grayramp(Last, height=80), Last)
SmoothLimiter(0, 170, k=9)
LevelsPlus(16, 2.2, 255, 0, 255)
return To8bit.HistogramTurn

fenomeno83
4th October 2017, 08:13
Great man!!! I'll try!!

fenomeno83
4th October 2017, 08:46
I've seen your script..just a question: what is difference between Levels and Levelsplus?

fenomeno83
4th October 2017, 11:39
Hi..I've problem with your script..
I've this error: there is not function named bitspercomponent

I've installed avisynth+ from installer download here: http://avs-plus.net/
I use virtualdub to open avs script

raffriff42
4th October 2017, 13:41
..just a question: what is difference between Levels and Levelsplus?LevelsPlus works at all bit depths without adjusting the arguments, and coring=false by default.

I've this error: there is not function named bitspercomponent
I've installed avisynth+ from installer download here: http://avs-plus.net/
I use virtualdub to open avs scriptOld version. Get the latest AVS+ bundled in Groucho's universal installer, here:
https://forum.doom9.org/showthread.php?t=172124

fenomeno83
4th October 2017, 14:42
thanks!
I've download this https://www.dropbox.com/sh/oxx5cm9hkbpj5oz/AAD0QBnTlczv7xW3jEdSjenHa?dl=0&preview=AviSynth%2B+r2294.7z
but now I have the same problem in replacestr function

edit: now I've installed avisynth using universal installer, as you said..now I've problem with mt_polish, but I think is related to masktools..I'll update you

edit2: after i've imported masktools, it works! now i try your filter

fenomeno83
4th October 2017, 19:16
Hi raffriff, I've tried filter..it works good (no artifacts and light removed), but sometimes creates some bad colors expecially in faces..
Here I compare filtered photos (using script posted before) + the same script with added Smoothlimiter at the end

1) filtered: https://ibb.co/h0koGG , filtered+smoothlimiter: https://ibb.co/bRG0Vb
2) filtered: https://ibb.co/jEPR3w , filtered+smoothlimiter: https://ibb.co/n25cAb
3) filtered: https://ibb.co/dx60Vb , filtered+smoothlimiter: https://ibb.co/bytEqb
4) filtered: https://ibb.co/cCazOw , filtered+smoothlimiter: https://ibb.co/jZV5wG
5) filtered: https://ibb.co/n5yKOw , filtered+smoothlimiter: https://ibb.co/g51Zqb
6) filtered: https://ibb.co/iQ4LVb , filtered+smoothlimiter: https://ibb.co/mBNeOw

raffriff42
4th October 2017, 20:51
After you apply any limiter you need to apply make-up gain (https://www.google.com/search?q="make-up+gain") -- that is, you need to raise the now-limited highlights to 100%. Once you do that you will see more vivid colors automatically. Of course you can also manipulate the colors further, to your liking.

StainlessS
4th October 2017, 20:52
John, methinks that photo of yours is quite lovely,
Du bist ein master EDIT: Meister..
(Speelin is probably lousy.).

raffriff42
4th October 2017, 22:13
I think so too, John.

fenomeno83
4th October 2017, 22:58
After you apply any limiter you need to apply make-up gain (https://www.google.com/search?q="make-up+gain") -- that is, you need to raise the now-limited highlights to 100%. Once you do that you will see more vivid colors automatically. Of course you can also manipulate the colors further, to your liking.

what filter can I apply after smothlimiter?
thanks

raffriff42
5th October 2017, 01:02
LevelsPlus, or simply ColorYUV(autogain=true)
and Tweak(sat=<something>) for color saturation

johnmeyer
5th October 2017, 05:27
John, methinks that photo of yours is quite lovely,
Du bist ein master EDIT: Meister..
(Speelin is probably lousy.).
I think so too, John.Are you two talking about my photo of the cabin? If so, da nada, but it really is nothing more than a fancy snapshot. Here is one that has the pretension of being a decent photograph, and which is also HDR. However, the dynamic range is not as immediately apparent as in the the picture I posted above. I chose that one because the exposure problems closely resembled the problems the OP was showing.

So, while the HDR advantages in this one are not as readily apparent, I have a non-HDR version I took and I can tell you that even after manipulating the RAW image in Adobe Lightroom it was impossible to capture all the highlights in the snow, while also seeing details in the shadows of the forest, while still getting details around the rocks in the foreground. This is especially difficult at altitude where you get far less scatter into the shadows.

Fortunately, I took a bracketed version (with the camera on a tripod), and have this infinitely superior HDR version.

http://i177.photobucket.com/albums/w208/johnmeyer/Banff%20%20129%2020150604RAW%20HDR%20Lake%20Louise_zpsr8molsjo.jpg

StainlessS
5th October 2017, 07:36
talking about my photo of ...
Yep.

I've just gotten (about a week ago) a used Sony Xperia Z2, HDR capable, now I know what its for :)
Shoots up to 3840x2160@29.97, but without HDR at that size. Only tried it once for about 30 secs, its supposed to get a wee
bit hot if you shoot at that size for too long. [EDIT: Also does 1920x1080@60FPS, (EDIT: But with HDR only @30FPS)]
Steadily building up my Android collection of devices.

StainlessS
5th October 2017, 12:06
@RaffRiff, Reel.Deel, Wilbert,

Is this script as intended ?

http://avisynth.nl/index.php/Internal_functions#Average

Runtime functions

These are internal functions which are evaluated at every frame. They can be used inside the scripts passed to runtime filters
(ConditionalFilter, ScriptClip, FrameEvaluate) to return information for a frame.

Average

AverageLuma(clip [, int offset = 0])
AverageChromaU(clip [, int offset = 0])
AverageChromaV(clip [, int offset = 0])
AverageB(clip [, int offset = 0]) AVS+
AverageG(clip [, int offset = 0]) AVS+
AverageR(clip [, int offset = 0]) AVS+
This group of functions return a float value with the average pixel value of a plane (Luma, U-chroma and V-chroma, respectively). They
require an ISSE capable cpu. In v2.61 an offset argument is added which enables you to access other frames than the current one.

Examples:

ScriptClip(Last, """
threshold = 55
luma = AverageLuma ## gives the average luma of the current frame
#luma = AverageLuma(1) ## gives the average luma of the next frame
luma < threshold
\ ? Levels(0, 1.0+0.5*(threshold-luma)/threshold, 255, 10, 255)
\ : last
Subtitle("luma=" + String(luma), align=2)
""")


EDIT:
Also, is this also as intended (in this thread, examples of intense_whites, YPlaneMedian is lesser than AverageLuma, and so
YPlaneMedian() - AverageLuma is -ve)

# median and average are close only on even distributions;
# this can be a useful diagnostic
have_intense_brights = YPlaneMedian() - AverageLuma() < threshold
...
# a simple per-frame normalizer to [16..235], CCIR, range
Levels(YPlaneMin(), 1.0, YPlaneMax(), 16, 235)

EDIT:
Ex 1) (Karate in Gym) Median 62, luma 66.2
Ex 2) 55, 75.4 (over bright on stage)
Ex 3) 73, 99.1 (band in hall)
Ex 4) 107, 111.9 (good exposure)

fenomeno83
5th October 2017, 13:11
this is a little out of scope, but i want ask you:
1) can I excecute an avisynth avs script without install avisynth (ma just placing avisynth.dll, devil.dll in ghe same script folder and using "import" for external dll plugin)
2) Can you suggest a good sharperer (it should not not much aggressive and enough intelligent and don't increase too much noise..something like this http://www.compression.ru/video/smart_sharpen/index_en.html )

Basically I work on single frame / images
Thanks

raffriff42
5th October 2017, 14:57
Is this script as intended ?
...Levels(0, 1.0+0.5*(threshold-luma)/threshold, 255, 10, 255)

...Also, is this also as intended
have_intense_brights = YPlaneMedian() - AverageLuma() < threshold
1) I think it's a typo. Should be 0. (EDIT: fixed it.)
2) it seems to me, highlights in a dark picture give a negative diff, and dark spots in a bright picture give a positive diff.
https://www.dropbox.com/s/v2sk09dt7xelbe4/Sintel-median-diff-frm3164.jpg?raw=1

https://www.dropbox.com/s/t6ll2bwc4aj24io/Sintel-median-diff-frm6761.jpg?raw=1




1) can I excecute an avisynth avs script without install avisynth (ma just placing avisynth.dll, devil.dll in ghe same script folder and using "import" for external dll plugin)
2) Can you suggest a good sharperer (it should not not much aggressive and enough intelligent and don't increase too much noise..1) you can't frameserve without installing, but you can process a video file with ffmpeg.
2) better use Google unless you want to start another "sharpener war." :devil:

fenomeno83
5th October 2017, 18:56
2) better use Google unless you want to start another "sharpener war." :devil:

And what do you prefer? :D

StainlessS
8th October 2017, 14:39
@JohnMeyer,

Hi John, downed you HDR images from earlier in thread (after some fun trying to display html disguised as jpg's), was wanting to look at histograms,
your mountain retreat histogram looks full range, but the Lake Louise image looks like it coulda had a bit more HDR range, it only just fills TV range
when using Matrix="PC.709".


FN="Banff129_20150604RAW_HDR_LakeLouise.jpg"

Imagesource(FN,end=0)
Crop(0,0,Width/4*4,Height/4*4)
A=ConvertToYV12(Matrix="Rec709").Histogram(Mode="Levels").Crop(Width,0,0,-448).sub("Matrix='Rec709'")
B=ConvertToYV12(Matrix="PC.709").Histogram(Mode="Levels").Crop(Width,0,0,-448).sub("Matrix='PC.709'")
Z1= StackHorizontal(A,B).Sub(FN)

FN="2011September_BigSur05_HDR.jpg"
Imagesource(FN,end=0)
Crop(0,0,Width/4*4,Height/4*4)
A=ConvertToYV12(Matrix="Rec709").Histogram(Mode="Levels").Crop(Width,0,0,-448).sub("Matrix='Rec709'")
B=ConvertToYV12(Matrix="PC.709").Histogram(Mode="Levels").Crop(Width,0,0,-448).sub("Matrix='PC.709'")
Z2= StackHorizontal(A,B).Sub(FN)
Return StackVertical(Z2,Z1)


https://s20.postimg.cc/kypstjbp9/image.jpg (https://postimages.cc/)

Maybe PhotoBucket messed around with it.

EDIT: Actually, using Showchannels.
@ Rec709, YAve 125.66 : YMin=19, YMax=234 : Loose YMin=37, Loose YMax=221
@ PC.709, YAve 127.68 : YMin=4 , YMax=254 : Loose YMin=24, Loose YMax=238

So actually not that bad really, YAve on both are pretty spot on TV Levels mid point = 125.5, PC level mid point =127.5.
Can only be a very few pixels at extremes.

EDIT: ShowChannels minPerc and maxPerc args are defaulted to 0.1%

raffriff42
8th October 2017, 15:49
...but the Lake Louise image looks like it coulda had a bit more HDR range...
Maybe PhotoBucket messed around with it...IrfanView auto-adjust agrees...

https://www.dropbox.com/s/wndbyo8pzavs7bq/Johnmeyer%20Banff%20Lake%20Louise%20129%20HDR%20half-auto-fix-small.jpg?raw=1

(maybe less realistic, but more eye candyish)

StainlessS
8th October 2017, 16:09
Raff, do you think that John had a wee-wee against that there rock in the foreground ?
[It just couldn't be..., surely, probably a bear or something.]
EDIT: Bet that mountain lion gets the blame again, poor beast.

EDIT: To below:-
I was once wee-wee'd on, by some French woman on a train stuck in station (for 4.5 hours), half way Paris->Léon.
I guess that accidents do happen, just wish it were not to me, you usually have to pay quite a toll to obtain such
service, where I got it for free & quite unexpectedly. I now if stuck on train in station (cannot use toilets), always try to
keep out of any splash zones, 7 or 8 feet seems to be about minimum recommended distance (although to sit comfortably
with medical and engineering safety principles, you may need to double that distance).
Still thats another story, tis a funny old world.
EDIT: Eg medicine, if a safe limit for a tablet is found to be 16 tablets in any day (in all circumstances), then safe limit
on bottle label would be 8 tablets per day.
Engineering, if crane tested at 600 tons for 30 minutes, then will be certified as being tested to lift 300 tons.

raffriff42
8th October 2017, 16:18
I don't know, but I have wee-wee'd on many of the great scenic natural wonders myself.