Histogram data in scripts? - Feature Requests - CHDK Forum

Histogram data in scripts?

  • 4 Replies
  • 5538 Views
*

Offline n6mod

  • *
  • 15
Histogram data in scripts?
« on: 28 / November / 2007, 13:58:14 »
Advertisements
I posted this on the other fora right around the time this one was created, so I'm guessing it might have been lost in the shuffle.

Is it possible to enable access to the histogram data from a script? I'd like to do a couple of things, namely "Expose to the Right", and a bracketing script that looks as the histogram to determine the limits. (shoot enough to capture everything)

Thanks,
Zandr

*

Offline intrnst

  • **
  • 99
  • A710IS + Morebest
Stick to the right!
« Reply #1 on: 04 / December / 2007, 02:29:02 »
Allow me to bring some thoughts about Expose to The Right that reinforce Zandr's idea.

Lately we had a lot of discussion on the theme:
forums.dpreview.com/...Pro Digital Talk (2006)
forums.dpreview.com/...Panasonic Talk (2005)
even some hot talks (with some concern) at forums.dpreview.com/...Canon Talk/CHDK 20 (2007)

Purists and RAWers have their own opinion, but there is a mathematical argument, based on the binary nature of the CCD-RAW file, that really matters in the case. Please, take a moment to read this objective article of Michael Reichmann.

So... maybe... this topic would deserve some attention of one of our CHDK's gurus. Please? ::)

___
@Woodsman: Please feel free to moderate any ugly (grammar/orthographical) errors.
Plz, feel!

« Last Edit: 04 / December / 2007, 03:45:19 by intrnst »
-- funny english, be aware -- CHDK for Dummies - The Very First Steps

Re: Histogram data in scripts?
« Reply #2 on: 16 / September / 2012, 11:29:47 »
Hi, I was sad too, that nobody seems to work on the accessing of the live histogram data for use in basic scripts.
The port of CHDK for my camera has just started some weeks ago and I was lucky to get the code of the pre-alpha version. So I looked inside of some CHDK files and thought, that it could be done.
I'm not a programmer and it was hard for me and took many, many hours, but I really wanted to try this "ettr" .

After many hours of reading in the source codes, I managed to create a new basic command.
I called it "get_lhisto_range" (the l stand for "live"). I can use it like the old "get_histo_range" command
(which gets the % of values in a certain range of the histogram of the previous shot image).
The new command of course gets these % value from the live histogram.

I add the diff file I made from the actual trunk2135 and my changes and my first test script.
The new command and the script work good on my sx240.

Since not all commands for the sx240 are working now, I had to do a workaround for the ettr-script.
The basic Idea is: part the histogram in x parts, get the % value of each part (from 255 down to 0, for example: 225-255,200-225,175-200...), look if the % value is <= the given max_value (for ex. 4), if yes-count a variable +1 -otherwise do not count anymore, at the end you get a variable which you can multiply with 1/3ev and add this to the measured exposure (time),and make a safety -1/3ev for example. ...

(Always make sure to check in the script min and max exposure time (or whatever you change) your camera is capable when you change the exposure settings.)

I would be happy if anyone who is interested in ettr and/or accessing the live histogram from basic script would look at it and try it, to see if it works on other cameras too (the files i changed are not camera specific i think).
As I said, I'm a beginner, but if someone can not compile this changes himself for his camera model, I would try to make it.

I would be happy if anyone would read, try, and reply  :) .

*

Offline reyalp

  • ******
  • 14082
Re: Histogram data in scripts?
« Reply #3 on: 16 / September / 2012, 14:51:08 »
I added live histogram support in lua to the dev trunk a while back http://chdk.setepontos.com/index.php?topic=2509.msg88973#msg88973

I haven't got around to testing it much, but it should work. Unlike shot_histogram, this gives you an array representing the entire histogram, so you can do whatever calculations you want on it. Obvious. this is only possible in lua since ubasic has no arrays.

A some things I'd like to do with this:
- Write a lua modules to give you the equivalent of get_histo_range
- Write a script to compare shot_histogram vs. live histogram.
- Write a script that automatically brackets based on histogram
Don't forget what the H stands for.


Re: Histogram data in scripts?
« Reply #4 on: 16 / September / 2012, 16:51:50 »
Hi reyalp, thank you very much for this information. Didn't know that you have added this function to lua  :), thats great.

For the moment I will stay at ubasic - it is easier for me, did a little microcontroller work where i used a basic like language some years ago (but I am still in the learning process of ubasic as a non programmer) - and i don't know anything about lua (and the ubasic scripts worked on my cam, the lua didn't so good). But I hope I will have more time in the next months to look at lua too.
Ubasic seems to work very slow, I hope lua will be a little faster.

But now, lua and ubasic programmers both can use the live histogram  :) (ok your lua can do more  ;) ).

Did you look at the diff file I attached? I was not sure if all I added is really needed (some commands in the new function-I added a "//"comment where), but this way I got it working. Perhaps you could give it a look and rework my changes, so that the code is 100% correct?

For the ettr (exposure to the right) guys -> I tested a little more and my opinion is that there is really much less noise in the image if u use ettr , but you have the danger of overexposing (at worst in one color channel). I tryed a lot.
But in most of the time the automatic camera metering is the better choice, at least in my experience  ;).

Would be nice if anyone would use the lua or basic function in a new script and share it  :).
Perhaps there are many other creative uses of the histogram functions.

 

Related Topics