Quality loss when writing DPX files?

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Nicola

Quality loss when writing DPX files?

Post by Nicola »

Hi,

is it possible to get a quality loss when writing an image as DPX compared to writing it as BMP?

If I write exactly the same data as DPX and as BMP and open it with IMDisplay I see a quality difference with disadvantage at DPX. Where could this come from?
Here you can find both variants (DPX/BMP) of the image: http://www.yourfilehost.com/media.php?c ... vs_BMP.zip

Thanks in advance,
Nicola
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Quality loss when writing DPX files?

Post by magick »

You need to quantify quality differences. Use the compare program with the RSME metric to compare your original image with its reconstruction. Do the metrics differ between DPX and BMP?

If you have further problems, post a URL to your original image so we can reproduce the problem.
Nicola

Re: Quality loss when writing DPX files?

Post by Nicola »

The result of comparing the DPX and the BMP image is with RMSE: 6.2025 (0.243235)
So I think there is a difference. For a link to the images see my last post - or do you need direct links to the images?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Quality loss when writing DPX files?

Post by magick »

Ok, we type
  • -> convert test_IM.dpx test.bmp
    -> compare -metric rmse test_IM.dpx test.bmp null:
    0 (0)
Which shows the pixels are exactly the same when converting DPX to BMP. Now lets try the reverse:
  • -> convert test.bmp test.dpx
    -> compare -metric rmse test_IM.dpx test.dpx null:
    0 (0)
Once again there is no loss of pixel information. We're using ImageMagick 6.5.3-7, the latest release.
Nicola

Re: Quality loss when writing DPX files?

Post by Nicola »

Let me explain what I did:
1. Writing an image given as unsigned char array to DPX and BMP (in VC++):

Code: Select all

Magick::Image cMagickImage(
            pcBmpBuffer->getWidth(),
            pcBmpBuffer->getHeight(),
            "BGR",
            Magick::CharPixel,
            pcBmpBuffer->getImage() );

// set the image type
cMagickImage.type( Magick::TrueColorType );

// flip the image since the original is ordered bottom-to-top
cMagickImage.flip();
cMagickImage.orientation( Magick::BottomLeftOrientation );

// write the image
cMagickImage.write( "test.dpx" );
cMagickImage.write( "test.bmp" );
2. Copmaring the two resulting images:

Code: Select all

compare -metric RMSE test.bmp test.dpx diff.bmp
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Quality loss when writing DPX files?

Post by fmw42 »

Since you are flipping the image, have you actually viewed the results and visually compared them to see that both have the same orientation?
Nicola

Re: Quality loss when writing DPX files?

Post by Nicola »

Hm...some curiosity: "compare" of the same DPX image results in: 3.5474 (0.0139114) :shock:

EDIT: I'm using ImageMagick-6.5.3-Q8
Nicola

Re: Quality loss when writing DPX files?

Post by Nicola »

fmw42 wrote:Since you are flipping the image, have you actually viewed the results and visually compared them to see that both have the same orientation?
I think the images should be the same since I write exactly the same image once as DPX and directly after this once as BMP! Comparing them visually they are the same except the mentioned quality difference.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Quality loss when writing DPX files?

Post by fmw42 »

Hm...some curiosity: "compare" of the same DPX image results in: 3.5474 (0.0139114)

EDIT: I'm using ImageMagick-6.5.3-Q8
On Q8, you are seeing only 1.4% difference. I don't know much about DPX images (or bmp) to know if they have any natural loss of quality similar to JPEG due to compression. You should check to see if there is any built-in compression for either and disable or set similar.

see
http://www.imagemagick.org/Usage/formats/#bmp
http://www.imagemagick.org/Usage/formats/#dpx

an IM Q16 install may be more accurate?
Nicola

Re: Quality loss when writing DPX files?

Post by Nicola »

fmw42 wrote:an IM Q16 install may be more accurate?
Could this really be an option? I'd not like to change to Q16 with no opportunity of solution by this...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Quality loss when writing DPX files?

Post by fmw42 »

On my IM 6.5.3-7 Q16 Mac OSX Tiger:

compare -metric rmse test_IM.dpx test_IM.dpx null:
0 (0)

compare -metric rmse test_IM.dpx test_IM.bmp null:
0 (0)


Perhaps you are using too old a version of IM or it has a bug. Have you tried upgrading? Otherwise, perhaps it is Q8 vs Q16.
Nicola

Re: Quality loss when writing DPX files?

Post by Nicola »

I changed the bit depth of the DPX file to 10 (still using Q8) so I can import it into AfterEffects. In AE it looks exactly the same as the BMP, although it doesn't in IMDisplay (still the mentioned quality difference). With it, my problems are solved for the moment but I think the IMDisplay needs to be reworked.

Best regards and many thanks for your help,
Nicola
Post Reply