Page 1 of 1

PNG to DPX without log

Posted: 2014-05-16T13:39:53-07:00
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?

Re: PNG to DPX without log

Posted: 2014-05-16T13:53:37-07:00
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

Re: PNG to DPX without log

Posted: 2014-05-16T15:47:31-07:00
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.

Re: PNG to DPX without log

Posted: 2014-05-16T16:50:39-07:00
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.

Re: PNG to DPX without log

Posted: 2014-05-16T17:25:02-07:00
by MGrossman
I'm on 6.5.4-7 2012-04-10 Q16 OpenMP - so maybe I should upgrade. Thanks

Re: PNG to DPX without log

Posted: 2014-05-16T17:26:54-07:00
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.

Re: PNG to DPX without log

Posted: 2014-05-19T13:03:56-07:00
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

Re: PNG to DPX without log

Posted: 2014-05-19T15:44:42-07:00
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:

Re: PNG to DPX without log

Posted: 2014-05-19T16:51:39-07:00
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.