Canon vs CHDK histograms - page 6 - General Help and Assistance on using CHDK stable releases - CHDK Forum

Canon vs CHDK histograms

  • 88 Replies
  • 4407 Views
Re: Canon vs CHDK histograms
« Reply #50 on: 17 / May / 2021, 01:23:29 »
Advertisements
@reyalp

Currently in Lua we can explore the histogram of the last image taken.

Is there any chance, as you revisit the live view histogram coding, you could include a Lua histogram function that gives histogram info from the live view, ie not needing to take a picture.

Such a function would be very useful, eg auto ETTRing etc.

*

Offline reyalp

  • ******
  • 13386
Re: Canon vs CHDK histograms
« Reply #51 on: 17 / May / 2021, 01:40:41 »
Quote from: pigeonhill link=topic=14342.msg146122#msg146122
Is there any chance, as you revisit the live view histogram coding, you could include a Lua histogram function that gives histogram info from the live view, ie not needing to take a picture.
Something like https://chdk.fandom.com/wiki/Lua/Lua_Reference#get_live_histo ? ;)
Don't forget what the H stands for.

Re: Canon vs CHDK histograms
« Reply #52 on: 17 / May / 2021, 02:08:30 »
@reyalp

 :o

Hadn't spotted that  :-[

Can you point me somewhere that shows how it might be used. That link is not that helpful.

Cheers

Garry
« Last Edit: 17 / May / 2021, 02:40:40 by pigeonhill »

*

Offline reyalp

  • ******
  • 13386
Re: Canon vs CHDK histograms
« Reply #53 on: 17 / May / 2021, 03:06:27 »
Can you point me somewhere that shows how it might be used. That link is not that helpful.
TBH, I'm not sure anyone's really used it since I implemented it.

It returns the histogram as a 0 based array of counts of the Y (luminance-ish) values of the viewport, along with the total number of pixels sampled so you can calculate what fraction is in a given range.

Note that depending on camera and settings, the live view may not reflect the used exposure outside of half press, and you may need to wait a bit after get_shooting() becomes true for the live view to be updated.

If you believe the CHDK division of Y values into 5 ev stops is valid (which appears roughly true using native exposure compensation), then bins of ~51 would be roughly one stop increments. But keep in mind digic 6 appears to use ~16 to 235 rather than the full 0-256 range seen on earlier cams, which would give bins of ~44.

Quick chdkptp example, on g7x
Code: [Select]
!h,c=con:execwait[[press'shoot_half' repeat sleep(10) until get_shooting() sleep(100) return get_live_histo()]]
!for i=16,192,44 do t=0 for j=0,43 do t=t+h[i+j] end printf('%d-%d:%d %0.2f\n',i,i+43,t,100*t/c) end
16-59:2573 17.87
60-103:4085 28.37
104-147:1161 8.06
148-191:6572 45.64
192-235:9 0.06
Repeat with ev shift +1
Code: [Select]
16-59:1247 8.66
60-103:3937 27.34
104-147:1587 11.02
148-191:1753 12.17
192-235:5876 40.81

Finally, given that your cam appears to have unresolved issues with the regular CHDK histogram, it's possible this one is broken too, although it uses different, simpler code, so it might not be.
Don't forget what the H stands for.


Re: Canon vs CHDK histograms
« Reply #54 on: 17 / May / 2021, 03:36:09 »
@reyalp

Thanks for the insight.

I have managed to get a test code up and running.

All it does is adjusts the shutter until the highlight zone histo[250-254] holds 0%.

It seems to work and correlates with the scene and canon histo.

Great...but!!!!

My issue is to find a way for the exposure to change, without taking an image, so that I can loop and test the exposure as I adjust it.

But I can't get the exposure that I adjust to take effect.

Here is the dirty test function

Code: [Select]

function set_ETTR(n)
    percent = 0
    histo,total=get_live_histo()
    for i = 254,(254-n), -1 do percent = percent + histo[i] end
    percent = (100*percent)/total
    s = get_tv96()

    if percent ~= 0 then
        i = 0
        repeat
            i=i+96
            percent = 0
            set_tv96_direct(s+i)
            press("shoot_half")
            repeat sleep(10) until get_shooting()
            sleep(1000)
            release("shoot_half")
            repeat sleep(10) until (not get_shooting())
            histo,total=get_live_histo()
            for i = 254,(254-n), -1 do percent = percent + histo[i] end
            percent = (100*percent)/total
            print(percent)
        until percent == 0
    end

    return percent
end

Any ideas? As I say, the live view stays fixed at the start value, although the Canon shutter speed feedback is changing  ???

Cheers

Garry

*

Offline reyalp

  • ******
  • 13386
Re: Canon vs CHDK histograms
« Reply #55 on: 17 / May / 2021, 03:52:35 »
All it does is adjusts the shutter until the highlight zone histo[250-254] holds 0%.
If M3 is like my d6 cams, there will never be anything in this range, as the Y values end around 235 even if the scene is totally blown out.

Quote
My issue is to find a way for the exposure to change, without taking an image, so that I can loop and test the exposure as I adjust it.
What shooting mode are you using?

In general, CHDK overrides aren't reliably reflected in the preview (may vary per camera). If you use M mode and use the _user values, they should be affect the live view after the next half press.

You may also be able to use the set_ev() function to control the cameras exposure compensation setting. On g7x, this appears to be reflected in the live view in the next half press.
Don't forget what the H stands for.

Re: Canon vs CHDK histograms
« Reply #56 on: 17 / May / 2021, 04:01:51 »
Quote
If M3 is like my d6 cams, there will never be anything in this range, as the Y values end around 235 even if the scene is totally blown out.

On the M3 it behaves really well.

Using user values fixed it, ie set_user_tv96(s+i)  :)

I’ll carry on refining the ETTR function, but it seems to work well on the M3.

My use case is to take a 'sky bracket', after taking a set of focus brackets at a different exposure, ie for the land.

Once again, thanks for all your help.

Cheers

Garry
« Last Edit: 17 / May / 2021, 04:36:10 by pigeonhill »

*

Offline reyalp

  • ******
  • 13386
Re: Canon vs CHDK histograms
« Reply #57 on: 17 / May / 2021, 12:37:39 »
On the M3 it behaves really well.
If you are seeing values between ~235 and 255, I'd suspect it's a sign of something being broken, similar to the problems you see with the standard CHDK histogram.

It should be fairly straightforward to draw a histogram with lua drawings and the get_live_histo data. It would be interesting to know how that compares to the Canon and standard CHDK histograms.
Don't forget what the H stands for.


Re: Canon vs CHDK histograms
« Reply #58 on: 17 / May / 2021, 12:44:50 »
Quote

If you are seeing values between ~235 and 255, I'd suspect it's a sign of something being broken, similar to the problems you see with the standard CHDK histogram.


You may be right, but it seems to work well  ;)

If I get some time a may investigate along the lines you suggest.

Cheers

Garry

Re: Canon vs CHDK histograms
« Reply #59 on: 17 / May / 2021, 14:07:47 »
@reyalp

Had a quick and dirty look and, you are right, the histogram looks broken with a couple of entries with huge numbers.

I’ll carry on looking.

But, as I say, broken or not, it does the job  ;)

Cheers

Garry

 

Related Topics