understanding chdk crw raw file - RAW Shooting and Processing - CHDK Forum supplierdeeply

understanding chdk crw raw file

  • 3 Replies
  • 2179 Views
understanding chdk crw raw file
« on: 14 / May / 2010, 13:49:03 »
Advertisements
Hello all.

I read some topics from the CHDK site about CHDK RAW processing. I need to develop a program that reads chdk .crw file, then demosaicing (or don't demosaicing, simple view it) bayer matrix and show the image. Now i have a question that is not understandable to me at this point.

How I must determine the resolution of the image ? If chdk crw is a really RAW (e. q. no header and no metadata) how I determine this ? The file is a one-dimensional array of bayer coefficients and it's absoluterly necessary (or I'm wrong ?) to know size of the array on the second dimension, after this I can load bayer matrix into two-dimensional array and start interpolation.

I found that some software (like FastStone image viewer) display CHDK .crw's correctly. It's my task. How are they doing this ?

Thank you.
WBR.

*

Offline whoever

  • ****
  • 280
  • IXUS950
Re: understanding chdk crw raw file
« Reply #1 on: 14 / May / 2010, 14:44:23 »
I found that some software (like FastStone image viewer) display CHDK .crw's correctly. It's my task. How are they doing this ?
They do it by looking up the raw file size -- consult dcraw, which is behind all those converters.

*

Offline at

  • *
  • 2
Re: understanding chdk crw raw file
« Reply #2 on: 14 / May / 2010, 17:44:59 »
For what its worth, for an SD850 IS, it is 3336 x 2480. pixels, which I got with a web search and verified by determining the size of the CRW file (the resolution quoted in some documents wasn't the exact number of pixels - I think what was quoted was useable pixels).  However, I also do not apparently understand the format, and am also trying to roll my own reader. 

I understand that the CRW data is 10 bit little endian, but what I read out isn't correct - there are dark columns spaced 8 pixels apart, though they appear to have at least some of the scene info in them. 

So say we have a pixel with an ADU value of 1000 and the next consecutive pixel read out has a value of 5.

The ten bits for each would be 1111101000 and 0000000101 respectively.  I was assuming that consecutive 10 bit ADU values get packed into consecutive 8 bit bytes LSB first as follows:
00010111  11101000   0000xxxx etc. 

But when I read out based on that assumption it seems to not quite be right.  I've tried a simple case where I know what the bit pattern is and the program seems to read as I expect.  As far as I can tell, the artifacts are not due to the Bayer pattern either, as they have the wrong pattern, and are present even if I take a "dark" frame - e.g. values should all be near zero.  So can someone explain where my assumption is wrong?

*

Offline reyalp

  • ******
  • 12793
Re: understanding chdk crw raw file
« Reply #3 on: 15 / May / 2010, 02:04:51 »
This thread http://chdk.setepontos.com/index.php/topic,4744.0.html might help.
You can also look at rawconvert in the tools directory of the CHDK source. In my (biased) opinion, it's a bit more readable than dcraw.

This won't get you the demosiacing part, but you should first verify that you are getting the raw data correctly before you worry about that.
Don't forget what the H stands for.


 

Related Topics