Initial Raw Image Results

I’m very excited here!  I wrote a test application to read the raw RAF images that are produced by my Fuji s7000 digital camera.  Below I’ll show in general the different steps I had to go through.  This post will be short on details.  A Java image reader class will follow in a later post.  Some basic background is needed here, before the pretty pictures are shown.

One feature of the Fuji s7000 camera is that it can output the image as a raw file.  Most high-end cameras have this option.  This raw file includes all the CCD sensor information unmodified.  All cameras that output to JPG perform different sharpening and other image processing operations on the image.  The benefit is that these raw files allows one to perform these operations yourself with an application supplied with your camera, or other software like the Adobe Camera Raw program within Photoshop or dcraw and there is the possibility that the final image result will be better than what you would get directly from the camera.  Raw files also allow access to 12 bit color vs 8 bit (4096 colors vs 256) at each color point, so there is the opportunity to recover shadows or blown-out highlights.  In general you have more flexibility with the image.  Now comes the fun part!

Raw images only have 1 color at each pixel point either red, green or blue.  To be able to recognize much of anything in the image the missing 2 colors must be computed before the image will look good on screen or saved out to a JPG, BMP or similar.

Note: All images I’m showing are only a 50×50 pixel crop of the main raw image.  This crop was then blown-up 5x so that the individual pixels can be seen.  The image shows part of a tie-dyed shirt sleave.

I wanted to be able to see what I was dealing with so I wrote the data out to a standard image file.  You can see that it doesn’t look like all that much.  The arrangement of pixels you see is called a Bayer Pattern.  There is twice as many green pixels as red and blue.

Raw data from camera.

 The data then needs to be corrected for white balance by scaling the value of the colors by certain amounts.

After image corrected for whitebalance.

 Then the big step, demosaicking the image.  To demosaic the image I used the Bilinear Interpolation algorithm, this algorithm takes the average of the known pixels colors surrounding the current pixel for any color values its missing.  For instance if the algorithm is at a blue pixel it takes the average of the 4 red colors surrounding it to figure out what this pixels red value should be.  Similiarly for the green value.  This produces a much more pleasing image that is closer to the final result.

Image after it was demosaicked using bilinear interpolation.

 Lastly, the image is in the RGB color space right now, and monitors and cameras and most common file formats use the sRGB color space, so I needed to correct for that.  This results in the below image.

After converting to the sRGB colorspace.

A further post will detail more specifics related to dealing with the RAF format produced by the Fuji s7000, resources I used, and how I figured out how to read the file format.

Comments are closed.