How to get Bayer raw using dcraw - page 2 - RAW Shooting and Processing - CHDK Forum supplierdeeply

How to get Bayer raw using dcraw

  • 14 Replies
  • 22391 Views
Re: How to get Bayer raw using dcraw
« Reply #10 on: 05 / April / 2010, 21:11:06 »
Advertisements
You wouldn't need to create a new image format. You could use the netpbm portable graymap (PGM) format. All you have to do is add the header "P5\n#Bayer Raw\nwidth height\nmaxcolor\n". The rest of the data remains exactly the same. 16 bit isn't standard for PGMs though. GIMP won't open it, but IrfanView will and so will the Gnome image viewer.

I only had to add around 10 lines of code to do this, and I didn't modify anything. I believe rawconvert can go backwards as well converting back to .crw. I didn't try to modify the code to back convert from .pgm.

Edit:
I just learned that 16 bit PGM should be stored as big-endian. rawconvert outputs the raw data in little-endian so simply adding a header to the data isn't enough to make it a standard PGM. This caused me a lot of confusion when comparing the output of rawconvert with the output of dcraw (which outputs standard big-endian PGM). However, there is a utility that will convert raw data in little endian to a big-endian PGM. It's called rawtopgm. Here's an example:
./rawconvert -10to16 -w=3336 -h=2480 -noshift myraw.crw myraw.raw
rawtopgm -bpp 2 -littleendian 3336 2480 myraw.raw > myraw.pgm
« Last Edit: 05 / May / 2010, 03:48:23 by yardleydobon »

*

Offline PS

  • ***
  • 157
  • A610 1.00f
Re: How to get Bayer raw using dcraw
« Reply #11 on: 06 / April / 2010, 12:28:03 »
@yardleydobon
dcraw -d -6 scales the image to 16 bits and you can set darkness and saturation level.
But if you don't need to display it then -D -4 will get you the raw data.

Re: How to get Bayer raw using dcraw
« Reply #12 on: 19 / April / 2010, 11:04:40 »
Convert the raw file to a TIFF using "dcraw -D -4 -j -t 0 -T ". The object here is to get the raw values without any adjustments or conversions.
-D   Shows the totally raw data with no interpolation and no colour scaling.
-4   Write 16-bit linear samples (fixed white level, no gamma).
-t 0   By default, dcraw applies the flip specified by the camera. -t 0 disables all flipping.
-j   this option guarantees that each output pixel corresponds to one raw pixel.
-T   Write TIF

Then you can use ImageJ to write out 4 files, one for each of the Bayer array pixels.

Checkout http://chdk.setepontos.com/index.php/topic,3576.0.html where I've pulled out just one of the green pixels from a 200x200 pixel section at the middle of the photo. My posting includes the ImageJ script I used.

Re: How to get Bayer raw using dcraw
« Reply #13 on: 02 / July / 2010, 01:52:27 »
cppasm added a pgm option to rawconvert and the updated source was added to trunk 894.
It correctly saves 16-bit PGM in big-endian.

http://chdk.setepontos.com/index.php/topic,5207.msg52343.html
http://tools.assembla.com/chdk/changeset/894


Re: How to get Bayer raw using dcraw
« Reply #14 on: 06 / July / 2010, 08:52:41 »

I'm not exactly sure what are you planning to do but I know IRIS software can manipulate with RAW files and maybe it can be useful to you. Its free btw :)

 

Related Topics