supplierdeeply

Optimal bracketing using an evolutionary algorithm

  • 7 Replies
  • 2808 Views
Optimal bracketing using an evolutionary algorithm
« on: 03 / October / 2010, 03:41:25 »
Advertisements
Hi,
Along the lines of the previous post, I have been trying to see what would be possible with CHDK and an evolutionary algorithm, and have concluded that maybe optimal bracketing could be done.
Since the histogram can be measured (and, as far as I have understood, it's one of the few things that can be measured), optimal bracketing would have two (or three, but let's say there are two) shots that would have histograms as far apart as possible, that is, minimal overlap.
In order to optimize it, we could create a population of possible exposure/aperture pairs, which would be evolved to get the optimal one. I don't know if the space is big enough for an exhaustive search, but I'm betting it's not (exposure-wise, for instance).
If this is eventually too slow, another stochastic algorithm, like Simulated Annealing, could be used. What do you think?

Cheers

JJ

*

Offline reyalp

  • ******
  • 11090
Re: Optimal bracketing using an evolutionary algorithm
« Reply #1 on: 03 / October / 2010, 16:05:13 »
As hacking project, this could be fun.

As a practical tool, I think conventional code would have no trouble doing this, and would be much simpler. Just set a threshold for allowable over and under exposed pixels and do a simple binary search on each end of the range. Given the total number of stops available on the camer, this should end in a handful of iterations at most.

Note that CHDK script cannot currently read the live histogram. shot_histogram reads the raw image buffer after the shot is taken. Reading the live histogram is a feature I'd like to add, (and in principle, you could get it in lua using peek() on the live view buffer), but it's not there yet.
Don't forget what the H stands for.

Re: Optimal bracketing using an evolutionary algorithm
« Reply #2 on: 03 / October / 2010, 16:30:39 »
What about introducing more variables in the mix? ISO, for instance, or some other things.

Thanks for the feedback

JJ

*

Offline reyalp

  • ******
  • 11090
Re: Optimal bracketing using an evolutionary algorithm
« Reply #3 on: 03 / October / 2010, 17:15:55 »
ISO doesn't really add much. In general, there's only a few stops of ISO that are useful, and the "optimum" ISO is always the lowest value you can use that doesn't violate some other constraint. The APEX equation lets you easily solve for a given constraint. The actual constraints depend on the type of subject (e.g. does it move, how much depth of field do you need), which your algorithm won't be able to figure out. For a given shooting situation, very simple logic should get you very close to an optimal exposure without much effort.

In general, I don't think this kind of thing will be worthwhile for any sort of exposure calculation. You almost always know which direction you are wrong, which makes finding the correct values very efficient.

As I said before, this doesn't mean that it couldn't be a fun hacking project for it's own sake.
Don't forget what the H stands for.


Re: Optimal bracketing using an evolutionary algorithm
« Reply #4 on: 04 / October / 2010, 02:29:21 »
BTW, how can I peek the live view buffer? I'm using a G9.

Cheers

JJ

Re: Optimal bracketing using an evolutionary algorithm
« Reply #5 on: 04 / October / 2010, 02:32:27 »
And I guess average or median luminance can be computed from the histogram, right?

JJ

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Optimal bracketing using an evolutionary algorithm
« Reply #6 on: 04 / October / 2010, 12:54:39 »
BTW, how can I peek the live view buffer? I'm using a G9.

You probably really don't want to, but to find out where it is for your camera and how to use it, you should probably take a look at CHDK source code parts that already read the live view, namely histogram, motion detector, zebra. They will also lead you to platform/g9/sub/*/lib.c for the actual absolute memory address and (with some forum searches) hopefully tell you how to interpret it as an actual image.




 

Related Topics