Custom processing for JPEG (Tone curve, CA ...) - page 2 - Feature Requests - CHDK Forum

Custom processing for JPEG (Tone curve, CA ...)

  • 101 Replies
  • 51435 Views
Re: Custom processing for JPEG (Tone curve, CA ...)
« Reply #10 on: 04 / April / 2008, 02:19:23 »
Advertisements
Uhhmm... unless I'm totally misunderstanding how the RAW data is being held in the camera's memory.... it should be in the format of RGBG (bayer matrix) for all of these cameras.

Aren't they all luminance values taken direct from the sensor? They just happen to have a color filter over each one. No such thing as a "colorPixel" in RAW.


Still need to find out what color filter is for which pixel. I am planning to apply a different response curve against each of those 'color filtered' pixel (e.g. the one with green filter will have the 'Green' response curve applied to).

Anyway, if the information can be read by dcraw, I'll probably have go look at the dcraw source and work from there.

Can you confirm that the CHDK RAW file is readable by dcraw?

Thanks

*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Custom processing for JPEG (Tone curve, CA ...)
« Reply #11 on: 04 / April / 2008, 02:51:54 »
Uhhmm... unless I'm totally misunderstanding how the RAW data is being held in the camera's memory.... it should be in the format of RGBG (bayer matrix) for all of these cameras.

Aren't they all luminance values taken direct from the sensor? They just happen to have a color filter over each one. No such thing as a "colorPixel" in RAW.

Still need to find out what color filter is for which pixel. I am planning to apply a different response curve against each of those 'color filtered' pixel (e.g. the one with green filter will have the 'Green' response curve applied to).

RGGB Bayer matrix.
* Even lines - RGRGRG...
* Odd lines - GBGBGB...


Can you confirm that the CHDK RAW file is readable by dcraw?

Yes.
CHDK Developer.

Re: Custom processing for JPEG (Tone curve, CA ...)
« Reply #12 on: 04 / April / 2008, 03:10:45 »
Deleted
« Last Edit: 22 / April / 2008, 15:56:19 by Barney Fife »
[acseven/admin commented out: please refrain from more direct offensive language to any user. FW complaints to me] I felt it imperative to withdraw my TOTAL participation. Nobody has my permission, nor the right, to reinstate MY posts. Make-do with my quoted text in others' replies only. Bye

Re: Custom processing for JPEG (Tone curve, CA ...)
« Reply #13 on: 05 / April / 2008, 23:09:13 »
Anyway, it should work very quick to prevent camera from shutdown by watchdog timeout.

Well I finished the coding and run a couple of test - It did not timeout but it did slow down the camera quite a bit!. It seems to work however (Tried on a  1=>1 level and 1=>1/2 level conversion).

As I am not a wiz for coding C, I attached the code snip here in case anybody has an idea of how to optimize it.

Code: (c) [Select]
unsigned short curve[4][1024];
// The 3 different color level conversion can be done here...
// (we'll do twice the Green one).
// Assume to have the following matrix
// (0)(1)
// (2)(3)

Cut out the outdated code to make room in the post...

Thank you all for your input.

Hope that I won't have to declare this as a dead feature.
« Last Edit: 12 / July / 2008, 17:51:38 by toinech »


*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Custom processing for JPEG (Tone curve, CA ...)
« Reply #14 on: 06 / April / 2008, 04:13:53 »
> unsigned short curve[4][1024];
> ...
> pixVal[k]=curve[2*(i&2)+(k&2)][pixVal[k]]; // Assumme Bayer

The expression 2*(i&2)+(k&2) can has 0, 2, 4, 6 as the result, but declaration is "curve[4]".
Is it supposed to be 2*(i&1)+(k&1)?
CHDK Developer.

Re: Custom processing for JPEG (Tone curve, CA ...)
« Reply #15 on: 06 / April / 2008, 10:44:07 »
> unsigned short curve[4][1024];
> ...
> pixVal[k]=curve[2*(i&2)+(k&2)][pixVal[k]]; // Assumme Bayer

The expression 2*(i&2)+(k&2) can has 0, 2, 4, 6 as the result, but declaration is "curve[4]".
Is it supposed to be 2*(i&1)+(k&1)?


Thanks for catching this bug.
By the way will there be any performance gain to have this section replaced by inline assembly?
The code is supposed to slice an 80 bit bloc into 8 blocs of 10 bits to use them as index to replace those 8 blocs of 10 bits and reassembling the whole thing.

I am pretty lame with inline assemble and would need help there.

*

Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: Custom processing for JPEG (Tone curve, CA ...)
« Reply #16 on: 07 / April / 2008, 08:02:50 »
Quote
Well I finished the coding and run a couple of test...

Hi toinech, it looks very interesting. My questions are threefold:

What does your code do?

How do we add it to CHDK?

Can you post some results for us to see?

Thank you.







Re: Custom processing for JPEG (Tone curve, CA ...)
« Reply #17 on: 08 / April / 2008, 01:02:00 »

What does your code do?

Emulate the curve feature of P*shop. Or some crude imitation of it.
The code load a binary file that contains 4 response curves for the following pixel pattern in the raw file:

  (0)(1)
  (2)(3)

The response curve will be applied to the RAW data before it gets converted to JPEG and after it is saved.
See the follow more graphical explanation from Mediachance: Tone Curves

Each of the curve is supposed to correct a color. I provided some more cryptic explanation earlier in this post.

Quote
How do we add it to CHDK?

It is still work in progress: I am still working on an offline tool that would generate the curve files.
I am still need to verify the exact pattern of the different 'color pixels' (see comments below)

Though I have the feeling that all of this may get to a dead feature and do not want to clog the
source tree with this as yet.

Quote
Can you post some results for us to see?

For now I only try 6 different curves:
- 1 to 1 level transformation (i.e no change) for the 4 curves => OK
- 1 to 1/2 level for the 4 curves => OK
- 4 curves with a 1 to 1 level transformation and zero for the other 3 => odd result to be understood.
  I was expecting to verify that by applying the different filter against a white picture and get the different colors
  corresponding to each of the colored pixel on the CCD sensor.
  I did not get the expected result: May be the assumption on the color pattern is not correct.

The speed is also too sluggish.

I also found out in the mean time that the polarizer can't be simulated and that the camera performance is too
slow for CA correction algorithm.






Re: Custom processing for JPEG (Tone curve, CA ...)
« Reply #18 on: 08 / April / 2008, 04:06:37 »
Deleted
« Last Edit: 22 / April / 2008, 15:56:47 by Barney Fife »
[acseven/admin commented out: please refrain from more direct offensive language to any user. FW complaints to me] I felt it imperative to withdraw my TOTAL participation. Nobody has my permission, nor the right, to reinstate MY posts. Make-do with my quoted text in others' replies only. Bye

Re: Custom processing for JPEG (Tone curve, CA ...)
« Reply #19 on: 09 / April / 2008, 23:09:48 »
This might be an excellent way to "fix" the color shift that happens when averaging RAW images for in-camera HDR. Averaging 3 or 5 bracketed RAW frames seemed to provide some excellent results in another thread where people were testing this. But highlights were getting strongly shifted into magentas/reds (most likely due to not having a proper color profile for RAW import that wasn't expecting that many frames added together needing compensation more accurately).

With the A610, it seems possible to go to "my colors" mode and adjust the parameters in "Custom color" mode and develop the picture with those.

Quote
I hope you don't give up working on this. For the advanced photographer this would be an excellent addition. The more that can be done with some simple and well-tested defaults in our cameras, the less that needs to be done in editing. I for one would love to be able to tone-down the contrast a bit more in my camera (for a simple example). Canon loses too much dynamic range in its JPGs by trying to produce garish "advertising" images to the average consumer.

With the A610, it seems to be possible to tone down the contrast. The "photo effects" mode offers some of the functions.
May be it is worth while to create means to save specific sets of values for the "photo effects" and "custom color" parameters  in loadable configuration files.
« Last Edit: 09 / April / 2008, 23:17:10 by toinech »

 

Related Topics