Page 1 of 2

DPX file writing red/blue swapped (6.4.9.2 Q16 windows DLL)

Posted: 2009-02-07T03:21:05-07:00
by dsharlet
I am having this problem with using ImageMagick to write DPX files (not read).

I have my own implementation of DPX reading/writing, and then I also use ImageMagick to work with every other image format. However, DPX with image magick should still work.

Anyways, with that background, here is what I see:

My DPX -> My DPX : OK
My DPX -> ImageMagick DPX: Red/Blue swapped
ImageMagick DPX -> My DPX: OK

These 3 cases tell me that we agree on the order for reading, but disagree for writing.

My DPX -> ImageMagick JPEG : OK
My DPX -> ImageMagick BMP: OK

This tells me that my channels for writing to image magick are OK.

My code for writing to any image magick format is exactly the same, so regardless there is some internal inconsistency in image magick.

It is not an endianness issue (it occurs with 10 bit DPX, but it does also happen with 8 bit DPX).

Thanks for looking

edit: Whoops, I meant to post this in the Bugs forum, and I don't see a way to delete my post. Sorry.

Re: DPX file writing red/blue swapped (6.4.9.2 Q16 windows DLL)

Posted: 2009-02-07T10:05:51-07:00
by magick
Post a URL to your DPX image and a command line or code snippet we can use to reproduce the problem.

Re: DPX file writing red/blue swapped (6.4.9.2 Q16 windows DLL)

Posted: 2009-02-07T13:41:24-07:00
by dsharlet
No source image needed. This code generates an image with the upper half red, the lower half blue. It writes it to two files, Test.bmp and Test.dpx. The bmp will have red on top, blue on bottom, the dpx has blue on top, red on bottom.

Code: Select all

// Test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <magick/MagickCore.h>

#include <string>

ImageInfo * image_info;
Image * image;
ExceptionInfo * magick_exception;

Image * InitializeBlankImage(unsigned long width, unsigned long height, const ImageInfo * image_info)
{
	//setup blank image
	MagickPixelPacket background;
	background.colorspace = RGBColorspace;
	background.storage_class = DirectClass;
	background.depth = 16;
	background.fuzz = 0;
	background.opacity = 1;
	background.matte = MagickFalse;
	background.red = 0;
	background.green = 0;
	background.blue = 0;
	return NewMagickImage(image_info, width, height, &background);
}

int _tmain(int argc, _TCHAR* argv[])
{
	MagickCoreGenesis(NULL,MagickTrue);
	magick_exception=AcquireExceptionInfo();
	image_info=CloneImageInfo(NULL);
	
	image_info->depth = 8;

	image = InitializeBlankImage(500, 500, image_info);

	//copy videoframe pixels to image
	for(unsigned long i=0; i < image->rows; ++i)
	{
		PixelPacket * pixels = GetAuthenticPixels(image, 0, i, image->columns, 1, magick_exception);

		unsigned short r = (i < 250) * 65535;
		unsigned short b = 65535 - r;

		for(unsigned long j = 0; j < image->columns; ++j)
		{
			pixels[j].red = r;
			pixels[j].green = 0;
			pixels[j].blue = b;
		}		
	}

	SyncAuthenticPixels(image,magick_exception);

	strcpy_s(image->filename, sizeof(image->filename), "C:\\Test.bmp");
	WriteImage(image_info, image);
	strcpy_s(image->filename, sizeof(image->filename), "C:\\Test.dpx");
	WriteImage(image_info, image);

	DestroyImageInfo(image_info);
	DestroyExceptionInfo(magick_exception);
	DestroyImage(image);
	MagickCoreTerminus();
	return 0;
}

Re: DPX file writing red/blue swapped (6.4.9.2 Q16 windows DLL)

Posted: 2009-02-07T14:01:24-07:00
by magick
We ran your program along with this command:
  • imdisplay Test.dpx
and the image is red on top and blue on the bottom as expected.

Re: DPX file writing red/blue swapped (6.4.9.2 Q16 windows DLL)

Posted: 2009-02-07T14:28:20-07:00
by dsharlet
XnView thinks they are reversed, and I've found XnView to be pretty reliable in the past (never seen it disagree with high end processing software).

Re: DPX file writing red/blue swapped (6.4.9.2 Q16 windows DLL)

Posted: 2009-02-07T16:46:01-07:00
by magick
We determine the correctness of the DPX files ImageMagick produces against the DPX standard, SMPTE_ DPX Version 2.0 (SMPTE_ 268M-2003). If you see ImageMagick is not producing a DPX file as determined by the standard, let us know how it violates the standard and we will investigate further.

Re: DPX file writing red/blue swapped (6.4.9.2 Q16 windows DLL)

Posted: 2009-02-07T17:59:53-07:00
by dsharlet
I tried to open the DPX produced by ImageMagick (by the test program above) in some other software to get some more data points.

AfterEffects cannot even read them. it can read DPX produced by Redcine however, as can my DPX implementation. It gives a rather unhelpful error (Something about 'Fill me in'. Lazy developers...).

I don't have any more tools on hand that can open DPX, but I've already got 3 out of 3 programs failing to read ImageMagick produced DPX files correctly. The other 3 programs all independently agree on what is a correct DPX and what is not.

Re: DPX file writing red/blue swapped (6.4.9.2 Q16 windows DLL)

Posted: 2009-02-07T18:24:18-07:00
by magick
We tried a couple of DPX readers we have access to and they read them fine of course. That is why its important to determine which method is correct by going against the standard. ImageMagick is in use by numerous movie production companies and so far we have not received any complaints about inverted channels.

Re: DPX file writing red/blue swapped (6.4.9.2 Q16 windows DLL)

Posted: 2009-06-11T03:30:51-07:00
by Nicola
Hello,

I recognized a similar behavior. I just read a BMP and write this one as DPX. XnView shows a mainly gray image with some vertical line fragments. ImageMagick shows a correct image. Sorry, but I don't have any more Programs to verify the DPX file. What could be the problem? How could one fix it? Mayby one has to set some more parameters for the DPX headers instead of using the default values set by ImageMagick?

Thanks in advance,
Nicola

Re: DPX file writing red/blue swapped (6.4.9.2 Q16 windows DLL)

Posted: 2009-06-11T05:49:38-07:00
by magick
Perhaps there is a bug in XnView. Post a URL to your image and the exact command line you are using. We will download the image. We will let you know if the problem is with ImageMagick or the image or if ImageMagick is behaving properly.

Re: DPX file writing red/blue swapped (6.4.9.2 Q16 windows DLL)

Posted: 2009-06-11T06:19:03-07:00
by Nicola
Hi,

here you can find the DPX file: http://www.yourfilehost.com/media.php?c ... est_IM.dpx

Regards,
Nicola

Re: DPX file writing red/blue swapped (6.4.9.2 Q16 windows DLL)

Posted: 2009-06-11T09:48:51-07:00
by magick
We have confirmed that ImageMagick is properly reading your DPX image. We're using ImageMagick 6.5.3-3.

Re: DPX file writing red/blue swapped (6.4.9.2 Q16 windows DLL)

Posted: 2009-06-11T09:57:38-07:00
by Nicola
magick wrote:We have confirmed that ImageMagick is properly reading your DPX image. We're using ImageMagick 6.5.3-3.
Thank you, but this is what I recognized as well. The question is why it is NOT working properly with XnView.

Re: DPX file writing red/blue swapped (6.4.9.2 Q16 windows DLL)

Posted: 2009-06-11T10:05:41-07:00
by magick
This forum is for problems with ImageMagick. For bugs in XnView you will need to contact them.

Re: DPX file writing red/blue swapped (6.4.9.2 Q16 windows DLL)

Posted: 2009-06-12T01:13:23-07:00
by Nicola
magick wrote:This forum is for problems with ImageMagick. For bugs in XnView you will need to contact them.
I did. Waiting what they are saying. Hopefully not just the same ;-)