Page 1 of 1

How to convert DNG without normalization?

Posted: 2015-12-28T11:46:52-07:00
by Meloware
I am using my Canon DSLR to capture 16mm movie film. My camera creates raw DNG format images. Any conversion I try (such as mogrify -format png somefile.DNG) results in a normalized image, rather than one with the original brightness, contrast, and whitebalance values. This default behaviour isn't any good for creating movie frame sequences.

Is imagemagick using dcraw to convert these files? The dcraw command, dcraw -6 -T -W somefile.DNG, gives me the conversion I wish.

Is there some way to produce the same result in an imagemagick command line?

I have tens of thousands of images to batch process. Of course, there are other transformations to still do within imagemagick, and it is important to avoid wasting time and saving huge intermediate files. Movie film preservation needs your help!

Re: How to convert DNG without normalization?

Posted: 2015-12-28T12:51:10-07:00
by fmw42
mogrify -format png somefile.DNG
Try

Code: Select all

mogrify -format png DNG:somefile.DNG
From http://www.imagemagick.org/script/formats.php

DNG R Digital Negative Requires an explicit image format otherwise the image is interpreted as a TIFF image (e.g. dng:image.dng).

IM does use dcraw to process RAW files.

I am unaware of any special -defines for DNG images to customize processing.

Re: How to convert DNG without normalization?

Posted: 2015-12-28T14:35:57-07:00
by magick
ImageMagick uses the dcraw-batch delegate program under Linux and dcraw under Windows to read DNG files. The dcraw-batch delegate program provides additional camera metadata. For example,

Code: Select all

-> identify -verbose  CRW_0049.dng
identify -verbose CRW_0049.dng
Image: /tmp/magick-1540923BfiksRl3Co.png
  Base filename: CRW_0049.dng
  Format: DNG (Digital Negative)
  Class: DirectClass
  Geometry: 2630x1970+0+0
  Units: Undefined
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 16-bit
  Channel depth:
    red: 16-bit
    green: 16-bit
    blue: 16-bit
  Channel statistics:
    Pixels: 5181100
    Red:
      min: 0 (0)
      max: 65535 (1)
      mean: 32295.8 (0.492802)
      standard deviation: 22256.2 (0.339607)
      kurtosis: -1.35923
      skewness: 0.366125
      entropy: 0.788557
    Green:
      min: 0 (0)
      max: 65535 (1)
      mean: 32805.3 (0.500577)
      standard deviation: 21932.5 (0.334669)
      kurtosis: -1.34468
      skewness: 0.380011
      entropy: 0.82547
    Blue:
      min: 0 (0)
      max: 65535 (1)
      mean: 32271.9 (0.492437)
      standard deviation: 22156.4 (0.338085)
      kurtosis: -1.31337
      skewness: 0.487454
      entropy: 0.781009
  Image statistics:
    Overall:
      min: 0 (0)
      max: 65535 (1)
      mean: 32457.7 (0.495272)
      standard deviation: 22115.4 (0.33746)
      kurtosis: -1.33952
      skewness: 0.410946
      entropy: 0.798345
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 2630x1970+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: TopLeft
  Properties:
    date:create: 2015-12-28T16:26:57-05:00
    date:modify: 2015-12-28T16:26:57-05:00
    dng:Aperture: F2.8
    dng:AspectRatio: 1.335025
    dng:ChannelMultipliers: 1.677888 1.000000 1.311410 1.000000
    dng:CreateID: 1
    dng:Crop: 0 0 2630 1970
    dng:EXIFSource: exiv2 0.25
    dng:FocalLength: 7.1 mm
    dng:Green: 1.353
    dng:ISOSpeed: 50
    dng:Make: Canon
    dng:MatrixInputProfile: Color matrix
    dng:Model: PowerShot S50
    dng:Orientation: 0
    dng:Rotation: 0.000000
    dng:Shutter: 1/1000 s
    dng:sRGBOutputProfile: sRGB
    dng:Temperature: 5407
    dng:Timestamp: Fri Jun  3 13:23:50 2005
    dng:WB: Auto WB
    dng:WBFineTuning: 0
    exif:ApertureValue: 2970854/1000000
    exif:ColorSpace: 1
    exif:DateTimeOriginal: 2005:06:03 13:23:50
    exif:ExifOffset: 594
    exif:ExposureBiasValue: 0/1
    exif:ExposureProgram: 3
    exif:ExposureTime: 1/1000
    exif:Flash: 0
    exif:FNumber: 28/10
    exif:FocalLength: 71/10
    exif:ISOSpeedRatings: 50
    exif:Make: Canon
    exif:MaxApertureValue: 309375/100000
    exif:MeteringMode: 2
    exif:Model: Canon PowerShot S50
    exif:Orientation: 1
    exif:ShutterSpeedValue: 9965784/1000000
    png:IHDR.bit-depth-orig: 16
    png:IHDR.bit_depth: 16
    png:IHDR.color-type-orig: 2
    png:IHDR.color_type: 2 (Truecolor)
    png:IHDR.interlace_method: 0 (Not interlaced)
    png:IHDR.width,height: 2630, 1970
    png:sRGB: intent=0 (Perceptual Intent)
    png:text: 3 tEXt/zTXt/iTXt chunks were found
    png:text-encoded profiles: 1 were found
    signature: 429021c94b1e544d06ea90840e35562c54f57cf9ad736a970b6bc73fa4ffc8d9
    Software: UFRaw
    Source: CanonPowerShot S50
    unknown: UFRaw 0.21
  Profiles:
    Profile-exif: 838 bytes
  Artifacts:
    filename: CRW_0049.dng
    verbose: true
  Tainted: False
  Filesize: 21.67MB
  Number pixels: 5.181M
  Pixels per second: 126.37GB
  User time: 0.000u
  Elapsed time: 0:01.000
  Version: ImageMagick 6.9.3-0 Q16 x86_64 2016-01-07 http://www.imagemagick.org

Re: How to convert DNG without normalization?

Posted: 2015-12-28T14:39:55-07:00
by Meloware
Try

Code: Select all

mogrify -format png DNG:somefile.DNG
Thank you for the reply, but this suggestion doesn't affect my problem. The contrast still gets normalized. This prevents me from being able to control any levels across an entire image sequence. A 'fade to black', becomes a dissolve to noisy grey. Light vs dark scenes cannot be reproduced.

Is there anything else I might try? Is it possible to write a script which first uses the dcraw command, and then pass the result as an object which imagemagick may finish processing? A 30Mb dng turns into a 100Mb tiff. Saving each intermediate frame to disk will quickly eat a 4Tb drive and require a ton of additional CPU time. Unfortunately, I am stuck with Windows 7, so that may be even more limiting.

Re: How to convert DNG without normalization?

Posted: 2015-12-28T16:09:21-07:00
by magick
Locate the delegates.xml file on your system. You can edit the parameters we pass to the dcraw program to get the desired results.

Re: How to convert DNG without normalization?

Posted: 2015-12-28T16:32:33-07:00
by Meloware
Bingo! Thank You
My problem was solved by editing 'delegates.xml'. I replaced your dng decode command option from '-w' to '-W', and I was done.