Darker output when combining multiple images

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
MGM
Posts: 10
Joined: 2014-05-07T12:32:17-07:00
Authentication code: 6789

Darker output when combining multiple images

Post by MGM »

Hello, I'm trying to combine 3 DDS images into a new DDS image's RGB channels. When I do this in both Photoshop (CS5) and using ImageMagick (6.8.8-5 Q16 x64), the IM results are slightly darker than the PS results. You can download the DDS files I reference below here.

The ImageMagick command I'm using is:
convert test.dds test.dds test.dds -channel RGB -combine -define dds:compression=none ouput.dds
See imagemagick_output.dds for how it looks.

In Photoshop, I open test.dds, select the RGB channels, copy them using Ctrl + C, create a new image (RGB 8 bit, Background Color of black), select the Red channel only in the new image, then paste. This pastes a combined, grayscaled version of test.dds into the Red channel of the new image. I do this for the G and B channels as well. See photoshop_output.dds for an example of how it looks.

When I compare the two DDS files (in Photoshop), the image created by IM is different from the one I created using PS. Is there a reason for this? What am I doing wrong?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Darker output when combining multiple images

Post by snibgo »

I don't use DDS or Photoshop.

I see that test.dds is a colour file. In both the IM and PS cases you are taking the "value" from each pixel and and putting the same value in each of the red, green and blue channels, making a greyscale image.

But what "value" is used? Both IM and PS must convert each colour pixel in test.dds into a single 1-channel value. It is converted to greyscale. There are many ways of doing this. See http://www.imagemagick.org/script/comma ... #intensity I suspect IM and PS are using different methods.

You might try converting test.dds to greyscale, making say testbw.dds. Then repeat your IM and PS processes with testbw.dds. I expect the results will be identical to each other. (And they will be identical to testbw.dds. I can't see the point of your processes.)
snibgo's IM pages: im.snibgo.com
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Darker output when combining multiple images

Post by snibgo »

EDIT: I posted too hastily. test.dds and photoshop_output.dds are both opaque. imagemagick_output.dds has transparency. Something else is also happening.
snibgo's IM pages: im.snibgo.com
MGM
Posts: 10
Joined: 2014-05-07T12:32:17-07:00
Authentication code: 6789

Re: Darker output when combining multiple images

Post by MGM »

snibgo wrote:You might try converting test.dds to greyscale, making say testbw.dds. Then repeat your IM and PS processes with testbw.dds. I expect the results will be identical to each other. (And they will be identical to testbw.dds. I can't see the point of your processes.)
I tried this, but it still comes out looking different. I even tried setting the colorspace to sRGB to no avail. I tried converting to grayscale using rec709luma and rec601luma. Every time it comes out looking a little different from the PS method.
MGM
Posts: 10
Joined: 2014-05-07T12:32:17-07:00
Authentication code: 6789

Re: Darker output when combining multiple images

Post by MGM »

I was able to resolve it. It seems that Photoshop defaults to a particular color profile, Dot Gain 20%, that ImageMagick can't recreate. Changing the color profile to Gray Gamma 2.2 got IM much closer to Photoshop's results.

You can change the color settings in Photoshop by clicking Edit -> Color Settings, then changing the dropdown next to Gray to "Gray Gamma 2.2".

I should note that the results still aren't 100% perfect, but they're pretty much as close as I could get them using the IM command below:

convert ( test.dds -colorspace Gray ) ( test.dds -colorspace Gray ) ( test.dds -colorspace Gray ) -combine -gamma 2.2 output.dds
Post Reply