Magic Lantern Forum

Developing Magic Lantern => Feature Requests => Topic started by: Marsu42 on September 15, 2013, 01:19:31 PM

Title: Raw histogram (at least) for picture viewer
Post by: Marsu42 on September 15, 2013, 01:19:31 PM
I couldn't find a request for this, so here it goes (again?):

It would be really helpful to have a raw histogram not only for the last shot taken, but added as an option to the ml picture viewer or to the Canon picture player. It doesn't have to be fancy at all, actually *any* hint, even a text message, if there were blown highlights in the cr2 would be really helpful to decide if to re-take a shot or not.
Title: Re: Raw histogram (at least) for picture viewer
Post by: a1ex on September 15, 2013, 01:26:19 PM
The question is... how do you load the raw data from a CR2?
Title: Re: Raw histogram (at least) for picture viewer
Post by: Marsu42 on September 15, 2013, 02:24:11 PM
The question is... how do you load the raw data from a CR2?

You're the C wiz :-p ... but maybe it's possible to put part of dcraw into a module, just enough to get the max. rgb levels? Or is this completely out of the question due to memory/cpu constraints?
Title: Re: Raw histogram (at least) for picture viewer
Post by: a1ex on September 15, 2013, 02:33:26 PM
It's probably possible, but I'm not curious to try it ;)

(it's hard and I guess it will be very slow, since it will have to decompress the CR2)
Title: Re: Raw histogram (at least) for picture viewer
Post by: chris_overseas on September 15, 2013, 03:03:28 PM
It's probably possible, but I'm not curious to try it ;)

(it's hard and I guess it will be very slow, since it will have to decompress the CR2)

What about the possibility of writing a sidecar file with the required information when the photo is taken? It wouldn't need to be much, just the bare minimum required to reconstruct the histogram (128 pixels * four channels (RGB + luma) * 6 bits + a small amount of additional metadata). Presumably that sidecar file could be used for other purposes too.
Title: Re: Raw histogram (at least) for picture viewer
Post by: a1ex on September 15, 2013, 03:07:48 PM
That's easier. What's left to discover is the number of picture selected in playback mode (alternative: name the sidecars using a checksum of the image buffer).
Title: Re: Raw histogram (at least) for picture viewer
Post by: Marsu42 on September 15, 2013, 08:07:34 PM
What about the possibility of writing a sidecar file with the required information when the photo is taken?

Excellent idea - I seldom have time to look at the raw histogram right after shooting, and this would solve this. Is it mandatory to analyze each image in play mode just like auto-ettr does for this to work? For the format xmp would be good, it already contains ml deflicker and dual iso data and I guess you can write all sorts of other information into it which is then ignored by the raw converter.

As for reading a cr2 - I don't know about the raw data or the file format, but is it necessary to read *each* pixel from the cr2, maybe downsampling and reading only every nth pixel would be faster and be enough to get a "good enough" information about histogram or clipping?
Title: Re: Raw histogram (at least) for picture viewer
Post by: a1ex on September 15, 2013, 08:27:11 PM
Yes, it's mandatory to have the QR screen to appear (even if it's just for a split second). Intercepting burst in a reliable way is still unsolved.

I had some partial success with hooking in the capture tasks, works on 5D3 for post deflicker, but it's not quite portable (e.g. on 600D post deflicker doesn't work at all) and it's very likely to get out of sync (there was a bug report from 5D2 with noticeable flicker at fast intervals, but OK at slower intervals). Also it's slowing down Canon's capture task. So, I'm going to remove that feature and replace it with a post tool.

For CR2 you need to *decompress* it first.
Title: Re: Raw histogram (at least) for picture viewer
Post by: Marsu42 on September 16, 2013, 07:59:20 AM
When shooting wildlife and action it's often not possible to check the exposure carefully before, during, or immediately after shooting - doing so might mean missing "the" shot.

+1 ... I'm constantly trying to explain this point around here, obviously some people haven't got enough photography experience to have been in live wildlife or action situation, and it doesn't make any sense discussing on this basis ... but as long as alex gets the point it's good enough for me :-)

Having the RAW histogram available at that point would be invaluable to me. Currently I often find myself keeping two similar photos with slightly different exposures because I can't be sure if I've blown highlights or not.

Another +1 - even Canon has a histogram for shots taken previously, haven't they? Adding the full raw range to this would be a very big achievement for ml and a decisive point to use it even for non-nerd average canon users who don't fancy complicated exposure modules - the picture style tricks have been known for a long time, but why not go for the real thing?

Last not least, saving the histogram data and then restoring it as far as I understand it isn't much of a problem, so it'd be absolutely terrific if it'd really happen.
Title: Re: Raw histogram (at least) for picture viewer
Post by: gotar on September 16, 2013, 03:31:50 PM
For CR2 you need to *decompress* it first.

How about histogram from preview data (IFD2 I suppose)? It is uncompressed but small, so fast to read - much less accurate for sure, but it's subsampled from raw data without any WB impact AFAIK.
Title: Re: Raw histogram (at least) for picture viewer
Post by: a1ex on September 16, 2013, 03:34:05 PM
You already have it, just press the shortcut key for zebras in playback (see help, it's camera-specific).

Preview data is JPEG.
Title: Re: Raw histogram (at least) for picture viewer
Post by: Audionut on September 17, 2013, 06:24:48 AM
Off topic discussion move to here: http://www.magiclantern.fm/forum/index.php?topic=8341.0
Title: Re: Raw histogram (at least) for picture viewer
Post by: gotar on September 17, 2013, 04:03:48 PM
You already have it, just press the shortcut key for zebras in playback (see help, it's camera-specific).

Preview data is JPEG.

I thought this was calculated from visible screen as it changes it's shape on zooming in or out (to 1/4th of the screen when Canon's histograms are visible), and I've read it here lclevy.free.fr/cr2 (http://lclevy.free.fr/cr2): "The third IFD is containing a small RGB version of the picture NOT compressed (even with compression==6) and one which no white balance correction has been applied." which seemed appropriate for raw histogram. However in some other cr2 spec I've read that this is camera-specific, so I assume you're right.
Title: Re: Raw histogram (at least) for picture viewer
Post by: Audionut on February 02, 2014, 11:10:03 AM
Canon caches the images you have shot until you poweroff the camera or the memory gets full (5-10 images).
As long the images are in cache, you can review it without any problem.

Anyway to dig into the data from the cache?
Title: Re: Raw histogram (at least) for picture viewer
Post by: a1ex on February 02, 2014, 11:46:33 AM
If they would cache say 5 raw buffers, that means over 200MB => better use this for burst.

So I assume they are caching the JPEG previews only.