PNG to DPX without log

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
MGrossman
Posts: 5
Joined: 2014-05-16T13:31:56-07:00
Authentication code: 6789

PNG to DPX without log

Post by MGrossman »

I'm trying to convert a PNG to DPX without applying a log function. I can ALMOST get the right results using
convert -colorspace sRGB colorramp.png colorramp.dpx
which says the source is already in log space, but not quite, because the sRGB curve isn't a perfect log curve. So how do I convert without molesting the colors at all?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PNG to DPX without log

Post by fmw42 »

I do not know much about DPX images, but DPX is by nature logarithmic. I do not know if you can create a linear DPX.

Don't know if this helps, but

see http://www.imagemagick.org/script/formats.php

DPX RW SMPTE Digital Moving Picture Exchange 2.0 (SMPTE 268M-2003) Use -set to specify the image gamma or black and white points (e.g. -set gamma 1.7, -set reference-black 95, -set reference-white 685).

and

http://www.imagemagick.org/script/motion-picture.php
MGrossman
Posts: 5
Joined: 2014-05-16T13:31:56-07:00
Authentication code: 6789

Re: PNG to DPX without log

Post by MGrossman »

I'm not trying to create a linear DPX, I'm just trying to preserve the colors in the original PNG. Without any arguments, it seems to assume the PNG colors are in linear RGB space and thus applies a log function to them. I'm trying to prevent this from happening.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: PNG to DPX without log

Post by magick »

Which version of ImageMagick? The current release, 6.8.9-1, saves in the source colorspace. PNG images are sRGB, convert this to DPX, and a sRGB DPX image is written.
MGrossman
Posts: 5
Joined: 2014-05-16T13:31:56-07:00
Authentication code: 6789

Re: PNG to DPX without log

Post by MGrossman »

I'm on 6.5.4-7 2012-04-10 Q16 OpenMP - so maybe I should upgrade. Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PNG to DPX without log

Post by fmw42 »

MGrossman wrote:I'm on 6.5.4-7 2012-04-10 Q16 OpenMP - so maybe I should upgrade. Thanks
The sRGB and RGB were swapped at that time. So then sRGB was linear color and RGB was non-linear color, ie. backwards. See viewtopic.php?f=4&t=21269

You would be well of upgrading if you can since your version is nearly 350 versions old.
MGrossman
Posts: 5
Joined: 2014-05-16T13:31:56-07:00
Authentication code: 6789

Re: PNG to DPX without log

Post by MGrossman »

OK, here in more detail are my (still bad) results using convert release, 6.8.9-1

My .png is definitely in sRGB space according to identify. It contains a color ramp from 0-255; pixel (128,1) has value 128. The first 5 pixel color values are 0, 1, 2, 3, 4.

convert foo.png foo.dpx causes an sRGB function (i.e. an exponent of about 1/2.2) to be applied to all my colors. Pixel (128,1) has value 185. The first 5 pixel color values are 0, 12, 21, 28, 33 (so the function isn't a pure exponent but it isn't the standard sRGB function either). convert -colorspace sRGB does the same thing.

convert -colorspace RGB foo.png foo.dpx better preserves the input color space but not until apparently two color space conversions back to back in an 8-bit quantized manner. Instead of the original png colors starting 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12... the dpx has (approximately) 0, 0, 0, 0, 0... 12, 12, 12, 12... 21, 21, 21... 28, 28, 28...

So I still really just want to convert from png to dpx without changing the color values at all.

thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PNG to DPX without log

Post by snibgo »

Perhaps your input isn't really sRGB. What is the gamma?

These commands give the same outputs for the png and dpx (IM v6.8.9-0 on Windows 8.1):

Code: Select all

%IM%convert -size 1x10 gradient: g.png
%IM%convert g.png g.dpx

%IM%convert g.png txt:
%IM%convert g.dpx txt:
snibgo's IM pages: im.snibgo.com
MGrossman
Posts: 5
Joined: 2014-05-16T13:31:56-07:00
Authentication code: 6789

Re: PNG to DPX without log

Post by MGrossman »

Hey, that txt: option is nice. It shows that the color values really are the same inside the file. So now I'm thinking I've been thrown off by IMDisplay 6.8.8-1 all this time. It must be doing an extra gamma conversion on the dpx that it doesn't do on the png. Running on a Win 8.1 desktop.
Post Reply