HDR fractional EV steps

42 views
Skip to first unread message

nandoide

unread,
Jan 9, 2011, 12:54:10 PM1/9/11
to Magic Lantern firmware development
Alex, I made some modifications to HDR bracketing in order to let
configure fractional EV steps: 1/2, 1/3, 1/4, 2/3 , .... also
teorethical 1,5, 1/6 ... 1/8 (but I don't think that cam+lens have
such exposure resolution).

I port and merge some code that I've made past november, over the
first release of branch 550D from Trammel.

The keys are:

SET: inc number of steps (no changes)
DISP: inc step size (numerator of EV factor)
Q: inc base (denominator of EV factor) from 1 to 8.

Factor is allways kept less than 5 EV.

I've a patch (made with 'hg diff > patchfile', I don't know if it's OK
the method). If you like I can send you.




Fernando Freire

unread,
Jan 9, 2011, 12:56:27 PM1/9/11
to Magic Lantern firmware development
The patch


2011/1/9 nandoide <nang...@gmail.com>
hdr_fine.patch

Alex

unread,
Jan 10, 2011, 3:56:59 AM1/10/11
to ml-d...@googlegroups.com
Thanks.

Camera adjusts exposure in 1/8 EV steps, so the others will not be exact.

In my code, Q disables the HDR setting. I've used it to quickly turn
it off without cycling through all the values.

Now, the question for our users:
Does anyone require fractional EV steps? The patch adds a bit of
complexity to the code and user interface; is it worth?

If your answer is yes, I'll apply it.

> --
> http://magiclantern.wikia.com/
>
> To post to this group, send email to ml-d...@googlegroups.com
> To unsubscribe from this group, send email to
> ml-devel+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ml-devel?hl=en

Fernando Freire

unread,
Jan 10, 2011, 5:08:50 AM1/10/11
to ml-d...@googlegroups.com
OK, Alex.

But I can say that the canon SW itself does exposure bracketing with a fractional basis on 1/3EV or 1/2EV, 2/3EV, 3/2EV and so on.  1/2 or 1/3 od a stop(=step) units are menu configurable.

.. but the patch let the user experiment to 1/8 increments.

ML now has a minimun change in resolution of 1 step , it increments raw values by 8, perhaps it's not what you desired:  hdr_stepsize = mod(hdr_stepsize, 40) + 8;

I agree camera stores raw values in a 8 values for step basis but I think that significant changes on exposure arrived on a 1/3 EV or 1/2 EV basis. I think it could be related to lens mechanical (shutter, aperture) constraints.

Another question: 1/3 (2/3, 5/3, ... etc) increments are not exact, need rounding arithmetic. CANON solves it, I think the raw_add funcion do the right way but I need debug and I put some DEBUG lines but I don't see them in the dumps (?). I suspect something is wrong with my algorithm because CANON fails to assign the correct exposure BIAS on EXIF, in some of the shots (negative values of exposure compensation).

A lot of thanks:

Fernando



2011/1/10 Alex <broscu...@gmail.com>

Alex

unread,
Jan 10, 2011, 5:37:35 AM1/10/11
to ml-d...@googlegroups.com
> Another question: 1/3 (2/3, 5/3, ... etc) increments are not exact, need
> rounding arithmetic. CANON solves it, I think the raw_add funcion do the
> right way but I need debug and I put some DEBUG lines but I don't see them
> in the dumps (?). I suspect something is wrong with my algorithm because
> CANON fails to assign the correct exposure BIAS on EXIF, in some of the
> shots (negative values of exposure compensation).

This is excellent info for solving this issue:
https://bitbucket.org/hudson/magic-lantern/issue/139/smaller-ev-steps-in-shutter-speed

Thanks! I'll take a look at this.

> I put some DEBUG lines but I don't see them in the dumps (?)

If the log becomes too big, it is trimmed. Try working outside
liveview. I also have this issue with logs.

> But I can say that the canon SW itself does exposure bracketing with a
> fractional basis on 1/3EV or 1/2EV, 2/3EV, 3/2EV and so on. 1/2 or 1/3 od a
> stop(=step) units are menu configurable.

I didn't do extensive testing on this, but I thought 1/3 EV is just
rounded to 2/8 or 3/8 and so on. A test with shots at 2/8, 3/8 and 1/3
will clarify this.

Stefano

unread,
Jan 10, 2011, 4:05:15 PM1/10/11
to Magic Lantern firmware development
I think that smaller Ev steps should be nice, but so many steps are
confusing and Q to disable the HDR setting is very useful.
I propose simply to have a EV step of 1/4 or 1/2, possible
configurable via value in config file, and leave the Q=reset.
The UI can display the values 3x1/2EV, 3x1EV 3x3/2Ev, ... 7x10/2EV
that are more clear

On 10 Gen, 11:37, Alex <broscutama...@gmail.com> wrote:
> > Another question: 1/3 (2/3, 5/3, ... etc) increments are not exact, need
> > rounding arithmetic. CANON solves it, I think the raw_add funcion do the
> > right way but I need debug and I put some DEBUG lines but I don't see them
> > in the dumps (?). I suspect something is wrong with my algorithm because
> > CANON fails to assign the correct exposure BIAS on EXIF, in some of the
> > shots (negative values of exposure compensation).
>
> This is excellent info for solving this issue:https://bitbucket.org/hudson/magic-lantern/issue/139/smaller-ev-steps...
> > 2011/1/10 Alex <broscutama...@gmail.com>
>
> >> Thanks.
>
> >> Camera adjusts exposure in 1/8 EV steps, so the others will not be exact.
>
> >> In my code, Q disables the HDR setting. I've used it to quickly turn
> >> it off without cycling through all the values.
>
> >> Now, the question for our users:
> >> Does anyone require fractional EV steps? The patch adds a bit of
> >> complexity to the code and user interface; is it worth?
>
> >> If your answer is yes, I'll apply it.
>
> >> On Sun, Jan 9, 2011 at 7:56 PM, Fernando Freire <nangdo...@gmail.com>
> >> wrote:
> >> > The patch
>
> >> > 2011/1/9 nandoide <nangdo...@gmail.com>

Fernando Freire

unread,
Jan 10, 2011, 4:31:03 PM1/10/11
to ml-d...@googlegroups.com
Hi,

me said:

"... I suspect something is wrong with my algorithm because CANON fails to assign the correct exposure BIAS on EXIF, in some of the shots (negative values of exposure compensation). "

...and yes, it was an error and I haven't take account of rounding negative values of raw exposure compensation. I correct this with a new version of the patch. But the only ae values that canon show OK are factors of 1/2 or 1/3. If you use 1/5 units, for example, canon not show 1/5 o 2/5 values of exposure.

Alex said:

"I didn't do extensive testing on this, but I thought 1/3 EV is justrounded to 2/8 or 3/8 and so on. A test with shots at 2/8, 3/8 and 1/3
will clarify this"

Yes it's true. And the decision of take 2/8 or 3/8 as the more accurate value is made by canon software and by the raw_add function from my patch, based on a common mathematical rounding algorithm. Just the part that I've modified for negative raw values. Also I've changed a bit the display of the functionality that it's more clear, and Q retains certain reset capability from actual version. 

If finally the patch is applied, this is the patch to deal with.









hdr_fine.patch

Fernando Freire

unread,
Jan 10, 2011, 4:44:48 PM1/10/11
to ml-d...@googlegroups.com

Stefano, ou mails crossed over. If reset is so neccesary it's possible to draw another line on menu to select the units (1/2, 1/3, ...), better than a value in config file, that we cannot change online,

or perhaps better, add another menu line only to disable or enable bracketing and maintain actual line to configure the bracket.


 








Stefano

unread,
Jan 10, 2011, 6:18:05 PM1/10/11
to Magic Lantern firmware development
reset it's not so necessary, just nice.
I propose a much more simple patch to HDR in steps of 1/2AE (simply
extendible to 1/4Ae step and to step configurable in magic.cfg)
I attach the patch here; didn't know hot to attach a file :-(

diff -r 28d35eb6698f shoot.c
--- a/shoot.c Sat Jan 08 22:24:08 2011 +0200
+++ b/shoot.c Tue Jan 11 00:09:11 2011 +0100
@@ -588,7 +588,7 @@


int hdr_steps = 1;
-CONFIG_INT("hdr.stepsize", hdr_stepsize, 8);
+CONFIG_INT("hdr.stepsize", hdr_stepsize, 4);

static void
hdr_display( void * priv, int x, int y, int selected )
@@ -606,9 +606,10 @@
bmp_printf(
selected ? MENU_FONT_SEL : MENU_FONT,
x, y,
- "HDR Brack:%dx%dEV",
+ "HDR Brack:%dx%d.%dEV",
hdr_steps,
- hdr_stepsize / 8
+ hdr_stepsize / 8,
+ (10*(hdr_stepsize-(hdr_stepsize/8)*8)/8)
);
}
bmp_printf(FONT_MED, x + 440, y, "[SET ]\n[DISP]");
@@ -624,14 +625,14 @@
static void
hdr_stepsize_toggle( void * priv )
{
- hdr_stepsize = mod(hdr_stepsize, 40) + 8;
+ hdr_stepsize = mod(hdr_stepsize, 40) + 4;
}

static void
hdr_reset( void * priv )
{
hdr_steps = 1;
- hdr_stepsize = 8;
+ hdr_stepsize = 4;
}

int mov_test_en = 0;
@@ -917,7 +918,7 @@
fnt = FONT(FONT_MED, 80, bg);

if (hdr_steps > 1)
- bmp_printf(fnt, 380, 450, "HDR %dx%dEV", hdr_steps, hdr_stepsize/
8);
+ bmp_printf(fnt, 380, 450, "HDR %dx%d.%dEV", hdr_steps, hdr_stepsize/
8, (10*(hdr_stepsize-(hdr_stepsize/8)*8)/8));
else
bmp_printf(fnt, 380, 450, " ");

Alex

unread,
Jan 11, 2011, 12:53:37 AM1/11/11
to ml-d...@googlegroups.com
Thanks.

I propose to use only these step sizes:
0.5 1 2 3 4

and add an option to do bracketing with 2 pictures instead of 3. This
is good for shutter count.

What do you think?

To attach files, send the message from gmail.

Stefano Cotterli

unread,
Jan 11, 2011, 11:19:21 AM1/11/11
to ml-d...@googlegroups.com
I experimented with an option in magic.cfg to have configurables steps.
I think that have simply the half steps is enought, that is:
0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
and 3x 5x 7x 9x is ok too.
The 2x should shoot only the +EV and -EV shots? may be useless...

anyway, here is the patch with all my tests:
- hdr.stepsizemin configurable HDR as described above (my tests with 8=1EV, 4=1/2EV, 2=1/4EV)
- debug.show.seconds cfg option to display seconds in timer (smaller fonts used)
- on-screen countdown to next shot in intervalometer
- some minor fixex about initial screenshot and clean screen when intervalometer or other shot menu option stops
p20110111.patch

Alex

unread,
Jan 11, 2011, 11:23:50 AM1/11/11
to ml-d...@googlegroups.com
The 2x option should shoot -0.5EV and +0.5EV for step equal to 1EV, I
think. This way, the interval between two shots is always the one you
set in the menu. Usefulness is to reduce shutter wear for HDR
timelapse.

Stefano

unread,
Jan 11, 2011, 11:42:02 AM1/11/11
to Magic Lantern firmware development
is not this already done by your "skip0" parameter set to 1?

Fernando Freire

unread,
Jan 11, 2011, 11:58:19 AM1/11/11
to ml-d...@googlegroups.com
Hi, Stefano, as user I prefer to configure the steps on menu, not on config file. And as user I would want to have steps on a 1/3 basis also. (even CANON SW on the cam offers it in his bracketing function). It's more complex to program but the issue is yet solved.

If the problem is to make a reset, we can add another menu item only to disable or enable bracketing and maintain actual line only to configure the bracket. It's better than now  because if we set OFF HDR Brak , we lost the bracket configuration.

I don't think the interface was so complex, with the inclusion of numerators and denominators of EV.
The users of ML are advanced users and we have yet more complex functionality (rack focus).

But we can wait for other opinions ...

Alex, to clarify the aproachs to the rest of the world would be nice to have the BMP print function. I think that in current version is gone.







Alex

unread,
Jan 11, 2011, 1:10:16 PM1/11/11
to ml-d...@googlegroups.com
The screenshot function is just commented in the debug menu. Code is
still there. I'll put it back in next build. I'm tweaking a bit the UI
after the new font.

Skip0 is intended for the HDR triggered by shutter press. I can't stop
Canon FW from taking the first pic (with 0 EV), but I can detect when
it finished to take the pic, and then take the other exposures
(skipping the 0EV one).

And it can be used for 2-step bracketing, too.

Stefano

unread,
Jan 11, 2011, 1:38:23 PM1/11/11
to Magic Lantern firmware development
I tryed your patch and really didn't understand why to use a so
complicated setting and display.
Even more, as we discussed early, the camera manage 1/8EV steps only,
so why not to use this step and allow all the configurations from 1/8
to 5EV? This can be done with my code, that is by far more simple
(just set hdr_stepsizemin fixed and = 1)
Anyway I hope that anybody will give us his/her opinion and that Alex
will apply a patch in short, so we can dedicate to the shot0 skip.
There are also some other littles changes I did, that are waiting for
a commit.

Fernando Freire

unread,
Jan 11, 2011, 2:39:38 PM1/11/11
to ml-d...@googlegroups.com
I post some images:

SET change number of steps

DISP increases numerator of step 1/3 -> 2/3 -> 3/3 (displayed as 1) -> 4/3 (displayed as 1 + 1/3) ... 

Q increases denominator of step 1/1 (displayed as 1) -> 1/2  -> 1/3 -> 1/4 -> 1/5 -> 1/6 -> 1/7 -> 1/8 .     

That's all the possibilities of steps of the CAM. Only one line of config, well, perhaps a bit compact (*), but the key would not be used much.

(*) I think not even CHDK offers this without use of scripts.


Another question, the cam codes 8 values for step. But we shouldn't think that the cam has a real resolution of 8 values for step. There are raw values that take the "same photo" . It seems that the most fine step is in fact 1/3 EV, as far as I test.

Steps of 1, 1/2 or 1/3, and multiples are standard, I think. (not so 1/4, 1/5, or 1/6, but the patch let try these).


 

  


five_steps_1_3_each_step.jpg
hdr_off.jpg
seven_steps_1_3_each_step.jpg
seven_steps_2_3_each_step.jpg
three_steps_3_2_each step.jpg
Reply all
Reply to author
Forward
0 new messages