BMP save alternative - RAW Shooting and Processing - CHDK Forum

BMP save alternative

  • 9 Replies
  • 7072 Views
*

Offline igor

  • *
  • 21
BMP save alternative
« on: 23 / September / 2008, 14:46:08 »
Advertisements
I'm wondering if gurus here would consider windows BMP save alternative to pure RAW.
Sure, RAW has full CCD image.
However, it has drawbacks in the form of size and special software for postprocessing, which introduces alot of confusion for some people.
So, as the way to show my appreciation to CHDK, I'll post C code of BMP saving if someone would want it and ready to incorporate it in a next build.
THat code, which I wrote sometime ago, produces 24bits BMP of RAW data by shrinking it twice in both directions and averaging neigbouring green components. So, each 4 Bayer pixels goes into 1 RGB. No other approximation is done. So, resultant BMP size is around 1.8 times smaller then correspondent RAW.
So, by sacrificing a little lose in size/quality someone might store around twice as many BMP files on the camera then RAWs.

Just let me know if interested, and I'll post.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: BMP save alternative
« Reply #1 on: 23 / September / 2008, 16:07:38 »
Post away, I think someone requested something similar very recently.

But exactly what do you mean when you say it's a 24-bit BMP? Are you ditching bits from the (sort of) 3*10 bit RAW image or wasting space by writing 10 bits of information in 24? Because if you're converting it to 8 bits per RGB channel, you're losing something that's considered quite valuable in those RAWs. :)

*

Offline igor

  • *
  • 21
Re: BMP save alternative
« Reply #2 on: 23 / September / 2008, 17:21:33 »
Tnx for responding.
>> Because if you're converting it to 8 bits per RGB channel, you're losing something that's considered quite valuable in those RAWs.
To clarify: each 2*2 Bayer mosaic from RAW gets converted just to 1 RGB pixel. So, 40bits are converted to just 24bits. Thats why it is 40/24=1.666 save spacing.
Yes, sure this loses some valuable info (mostly by shrinking 2*2=>1). However, any other tool I know does the same thing during RAW postprocessing. Except for cases when we want to extract greyscale image, there is no way to keep original RAW resolution without approximation.

Fine, if you feel it's a lose case, lets not bother.

*

Offline vit40

  • ****
  • 276
Re: BMP save alternative
« Reply #3 on: 23 / September / 2008, 17:31:22 »
If you save a BMP in linear color space of a sensor, you are loosing 2 bits per color, because raw values are 10 bit. Another thing, interpolation in raw converters is very sophisticated and averaging 4 pixels into 1 (same as -h option in dcraw) can't give the same amount of detail (not mentioning there's no protection against moire etc). Also, we have no program to convert this BMP to sRGB tif or jpg and writing one isn't as simple as it seems to be

If you want to save a BMP in sRGB, you need to do all processing camera does with raw data (the same as above, just it has to be done in camera) - convert it from color space of sensor , meaning you have to apply WB, use curves, do a matrix transformation of a color space and, if you want to come close to what camera or ACR 4.5 offer, another transformation in HSV space (including corresponding profile ...). And you will end up with BMP version of JPG from camera, loosing all advantages of having raw

So I think there is no advantage of this feature in both cases

« Last Edit: 23 / September / 2008, 17:35:54 by vit40 »

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: BMP save alternative
« Reply #4 on: 23 / September / 2008, 17:48:09 »
No, I didn't mean resolution.. Couldn't care less about it, most my shots aren't sharp enough for full resolution anyway. And yes, the bayer pattern is useless for viewing and is always converted to something more suitable for computer screens. Heck, outputting 10Mpixel RGB JPEGs from a 10Mpixel bayer camera is borderline cheating anyway since they're bound to be a bit blurry.

So, your downscaling is fine. What I was asking was how many bits per color per pixel do you have in your final image. If it's less than 10 bits, how do you decide which ones to ditch? The two LSBs i.e. possible detail in dark? The pixels in JPEGs have 8-bits for each pixel for each color. The pixels in the RAW file however are 10 bits deep. That cannot be fully viewed on most computers&displays, but software can be used to select how to represent those 10 bits in the final image. Unless of course they've been lost by the camera. If they've been lost, one can only hope the camera selected well.

For DSLRs with 14 bit RAWs this is huge, for our 10 bit RAW vs 8 bit JPEG it's not that big a deal, but still sometimes salvages bad shots.

*

Offline igor

  • *
  • 21
Re: BMP save alternative
« Reply #5 on: 23 / September / 2008, 18:19:13 »
Above points are well taken here.
No problemo. Just thought maybe there is such demand.
If no, fine with me...

Meanwhile: Question to you gurus.
OK, I have TX1 (or any other digital camera).
Imagine now, that instead of using it for photo operations, I'm just sending life view from LCD to TV using NTSC.
So, I have LCD which is 320*240, which is mapped to TV screen.

So, specification for camera says it has 10x optical zoom. And let's assume I'm in 10x zoom currently.
So my life view on TV shows field of view correspondent to 10x optical zoom, which is (49full FOV/10=4.9degrees).
Correct?

So, now I'm taking shot, grab RAW, process it to RGB and while camera is in review after shot, I'm extracting just 320*240 central window from original huge RAW image, process it to UYV and sending it back to LCD, overwriting normal review that is displayed by the camera at this point. So, as the result highly scaled image I see now on TV. That image is about 10x times zoomed compared to RAW.
Are you with me?

So, as I took just 320*240 from 3000+*2000+ RAW but then mapped it to the full LCD, I effectively increased resolution shown on LCD by 10x times.

So, overall I had 10x optical zoom of the camera multiplied by around 10x zoom that I got by showing just small subwindow of the RAW. So overall it is 10*10=100x zoom. Again, I never scaled any image at this point.

Now the question:
What do you think guys: as the result do I have Optical 100x zoom or is it Digital 100x Zoom?

Simple question, and I feel an answer is Optical, but I'm lost... :-X
« Last Edit: 23 / September / 2008, 18:21:49 by igor »

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: BMP save alternative
« Reply #6 on: 24 / September / 2008, 15:39:57 »
vit40: in my opinion writing an RGB image (even if it's only 8-bit) in a lossless format but with proper white balance and noise reduction applied to it (like Canon's JPEG) could be a highly useful feature. But I think this would need to be captured not from the RAW image, but from whatever's being fed to the the JPEG encoder (if that even exists on CPU... I find it likely that this is done in blocks from RAW data during encoding, or even entirely off-CPU).

igor: it's 10x optical zoom with no digital zoom at all. What you are normally seeing in on the TV screen is an image of a 10x optically zoomed image digitally downscaled by 0.1x (zoomed out if you wish to call it zoom) to resize it to fill the low-resolution screen.

Of course in the camera's terminology you may have 10x optical zoom and 10x digital zoom, 100x total, and a 320x240 maximum noninterpolated image size. I.e. your digital zoom has been done by discarding 90% of the data from the CCD. Which is good if you don't need it. This is how some of Canon's digital zoom features work if you're smart enough to specify the correct JPEG size (on my a570is the digital tele feature indicator color actually indicates interpolation).


*

Offline igor

  • *
  • 21
Re: BMP save alternative
« Reply #7 on: 24 / September / 2008, 20:53:56 »
fudgey,
As topic might not be of prncipal interest, I'm sorry. But I respectfully dissagree.
In my opinion Digital Zoom means at some point in processing original image has been either stretched or shrinked.
In explained by me case, none of those operations occured. Only windowing and nothing else.

Of course it's just terminology, but what I'm trying to say is the following:

When camera manufaturer specifies Optical/Digital zoom they mean that in terms of not Life View on preview screen, but instead to describe quality of resultant printed picture. If we consider the process of printing with the same DPI of 2 pictures one with 10x optical zoom and another one with 10x digital zoom, then of course digital zoom would give you 10times less resolution in terms of DPI.

Contrary, if we consider zoom just in terms of Life View on preview screen, that woul be different. For example, TX1 CCD has more then 3000 horizontal pixels, that are getting shrinked to 320 LCD screen. So, this is digital zoom of 0.1x

In terms of Optical Zoom vs. Digital on LCD, this is the path I'm thinking:
Forget about resolution as we have no control of it on LCD => it has finite resolution anyway. So, we forget abot quality of the image, as we cannot display it better then native resolution of LCD.
Now let's think just in optical terms:
1. Full filed of view of human is 49degress (at least Canon assumes that);
2. We do 10x optical zoom using camera feature, so this gives us 49/10=4.9degrees FOV;
3. Now we do windowing, by just taking central window from 3200*2400 full image representing 4.9FOV. Size of that window is 320*240, which is exactly 10 times smaller then our original image. So, that small window represents 1/10th of 4.9FOV. So, it is 4.9/10=0.49FOV.
4. Comparing 49 Human FOV with 0.49 FOV shown on LCD, we get 100x optical zoom.

Why its is optical => because at no point between 1 and 4 we did any digital zoom operations (shrink or stretch)...

Am I wrong?

*

Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: BMP save alternative
« Reply #8 on: 24 / September / 2008, 21:51:56 »
Quote
3. Now we do windowing, by just taking central window from 3200*2400 full image representing 4.9FOV. Size of that window is 320*240, which is exactly 10 times smaller then our original image. So, that small window represents 1/10th of 4.9FOV. So, it is 4.9/10=0.49FOV.
Isn't that cropping instead of zooming?

As I understand the term "optical zooming", it only can be increased/decreased by optical means (add/change/remove lenses).
But I guess this is just a matter of terminology.

*

Offline reyalp

  • ******
  • 14126
Re: BMP save alternative
« Reply #9 on: 24 / September / 2008, 21:58:59 »
Like vit40, I'm not too convinced of the value of saving to a processed, 8 bpp RGB format (calling it lossless is a bit of stretch, since you'd be irrevocably losing some information.) The way I see it, the main benefits of raw are
1) a little bit more dynamic range.
2) full control processing (white balance etc), not relying on the cameras guesses.
3) Practically unlimited CPU and memory of a PC for the above processing.

If you are discarding the dynamic range and using the cameras processing, it's hard to see where this will be much better than the highest quality camera jpeg. You can probably come up with some specific examples where matters, but I'd expect them to be quite limited.

I'm not sure I get the point is of the digital zoom discussion (it seems like everyone understands the actual result, and given that "digital zoom" is basically a marketing term for cropping on the camera, arguing over an exact definition seems futile). That said, I can definitely see an argument for the ability to save a cropped (or digital zoomed, if you prefer) raw. Unfortunately, this would confuse most of the tools that understand CHDK CRWs.
Don't forget what the H stands for.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal