Skip navigation
simonprince
Currently Being Moderated

Newbie - getting started

Apr 9, 2010 10:25 AM

Hi,

Hopefully someone can help me here.  I'm looking to place either simulated or camera raw output (and here I mean a matrix of 8 or 10 bit values without debayering) into a RAW format so that I can experiment with the debayering, white balance, colour profiles, linearization or LUTs that I need to shift my camera output into a useable image.  I was thinking about using the Adobe DNG format - but I'm struggling to understand where to start with this.

 

What I'd like to do to start with is simply create a DNG file with, say, a 10x10 image size, 8 bit data with a ramp profile: e.g.

0 20 40 60 80 100 120 140 160 180

0 20 40 60 80 100 120 140 160 180

.

.

.

0 20 40 60 80 100 120 140 160 180

 

I've been looking at using the dng_validate example and creating a new function:

 

static

 

dng_error_code dng_createsim (const char *filenameOut)

{

 

 

}

 

After several attempts at this, I've sort of guessed that I need to access the data buffer in negative->Stage1Image(), but I've not succeeded in this.

 

Thanks for any help.

 

Simon

 
Replies
  • Currently Being Moderated
    Apr 9, 2010 11:08 AM   in reply to simonprince

    Well, you can directly manipulate the stage 1 image if you want. In that case I'd look at the CornerFix source code. But that's complicated.

     

    An easier route if you're just creating a DNG file rather than manipulating existing data would be to (a) create a dng_host, (b) create a dng_memory_stream with your data, (c) create a dng_image with (d) its associated ifd, then (e) read the memory stream into the ifd using ifd.ReadImage.

     

    Regards,

     

    Sandy

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2010 10:54 PM   in reply to simonprince

    Simon,

     

    In general, the process is to create the IFD, read the data into the image via the IFD, then assign the image as the Stage 1 image of a negative. Then after you have gone through the process of building a stage 2 and stage 3 image, you have a DNG image (in the shape of the dng_negative). Usually you build the thumbnail by rendering the negative image via a dng_render object to a dng_image_preview, which is then passed to dng_image_writer.WriteDNG which it includes it into the dng file. A DNG isn't valid without a thumbnail.

     

    Sandy

     
    |
    Mark as:
  • Currently Being Moderated
    May 2, 2012 4:12 PM   in reply to simonprince

    There aren't that many sample programs out there.

     

    Take a look at elphel_dng.c from Dave Coffin. It uses libTIFF.

     

    On the CinemaDNG prerelease forum, there is raw2dng sample code, also using LibTIFF.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 22, 2014 6:58 PM   in reply to Lars Borg

    one can extract the image buffer from dng_negative *negative..

      // Returns the raw image data.

     

     

    const dng_image & RawImage () const

     

    From another post on this forum, the raw data can be extracted.

    >>

    it's done with a dng_const_tile_buffer, where you give the dng_image as parameter in its constructur, and then you can get the pixels with dng_const_tile_buffer::ConstPixel.

    >>

     

    The ifd header can be created separately.

    

    However, how does one force dng_host to use a certain compression method ? dng_host does not seem to deal with compression flags internally.

    

    

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points