Intercepting JPEG? - General Discussion and Assistance - CHDK Forum  

Intercepting JPEG?

  • 4 Replies
  • 1828 Views
Intercepting JPEG?
« on: 08 / August / 2009, 17:55:05 »
Advertisements
Hi,

I noticed that there are hooks for postprocessing RAW before saving.
Is there a similar hook for postprocessing JPEG before saving?

What I want to do:
I want to implement my own sepia coloring.
I'm hoping I can have the camera capture the image, allow me to
modify the CCD memory directly and recolor it with a nice sepia algorithm,
then let the camera do its regular thing and save it as a JPEG (or RAW or DNG).
Photoshop has this cool sepia-ish function to make pictures bluish, greenish,
pinkish, etc. I think I know how the algorithm works, but I want to implement
it in the camera.

My question has a few parts:
1. Can I directly modify the CCD memory after a picture is taken?
Or is this bad? My alternative is to load the image into memory, edit, then save.

2. Since I cannot find a post-process function before it gets saved,
where would I put in this hook? (Camera is an A700, but I'd like something
in the general/ directory.)

3. Perhaps it is buried in the assembly code, but I don't see where the
actual camera shot or save takes place. Where and when is this happening?
(I looked over the developer wiki, but there really isn't a good description
of the overall process flow.)

Doing this with RAW or DNG seems pretty easy since there are hooks, but I
want to support JPEG too.

Thanks for any help!

*

Offline reyalp

  • ******
  • 12796
Re: Intercepting JPEG?
« Reply #1 on: 08 / August / 2009, 19:08:42 »
Hi,

I noticed that there are hooks for postprocessing RAW before saving.
Is there a similar hook for postprocessing JPEG before saving?
Modifications to the RAW buffer will affect the jpeg.
Quote
What I want to do:
I want to implement my own sepia coloring.
Doesn't mycolors do this already ?
Quote
My question has a few parts:
1. Can I directly modify the CCD memory after a picture is taken?
Of course, this is how things like badpixel and curves work.

Quote
Or is this bad? My alternative is to load the image into memory, edit, then save.
This would be very slow, and you might as well do it on the PC instead. Indeed, I'd suggest doing this anyway, your PC is FAR better suited to image processing than the camera is.
Quote
2. Since I cannot find a post-process function before it gets saved,
where would I put in this hook? (Camera is an A700, but I'd like something
in the general/ directory.)
Again, you can do this in the raw hook, whether or not your have raw saving actually enabled. This does mean you have to work in the raw pixel format, and you might have issues with camera processing (whitebalance etc) complicating things.
Don't forget what the H stands for.

Re: Intercepting JPEG?
« Reply #2 on: 08 / August / 2009, 20:37:52 »
Thanks reyalp. That's a big help.

I think I want to build it just to see if I can. But if it turns out to be slow, then I just won't tell anyone how I spent my time. :)

Re: Intercepting JPEG?
« Reply #3 on: 23 / August / 2009, 12:19:28 »
I'm still having problems with this...

I wrote my own function for sepia. (It's slow and ugly and not recommended. But it's a great exercise for learning how CHDK works.)

The problem is:
If I generate CRW or DNG files (via CHDK), then my sepia appears.
If I generate a JPEG, then I don't see my sepia changes.

From what I can tell, JPEG comes from the camera's firmware, while CRW and DNG comes from CHDK.

The place I inserted my hook:
  core/raw.c, raw_savefile(), right after the call to patch_bad_pixels().
    if (conf.bad_pixel_removal) patch_bad_pixels();
    if (conf.sepia) mysepia();

My question is:
Can I modify the CCD memory after the picture is taken but before the JPEG is written? I want my changes to appear in the JPEG.
If so, where do I place my hook and what conf settings do I need to have enabled?

Similarly, I want patch_bad_pixels to be performed before the JPEG is written.

Oh: my camera is a Canon A700, 100b.

Thanks.


*

Offline reyalp

  • ******
  • 12796
Re: Intercepting JPEG?
« Reply #4 on: 23 / August / 2009, 15:42:54 »
My question is:
Can I modify the CCD memory after the picture is taken but before the JPEG is written?
This is already where it happens on most/all cameras. This is how "raw develop" works. When you shoot, it overwrites the data in the raw buffer with an old raw from disk, and then the camera turns it into a jpeg. Does raw develop work on you camera ?


If so, where do I place my hook and what conf settings do I need to have enabled?
Don't forget what the H stands for.

 

Related Topics