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?".
So i have some images that are saved as RGB16 but actually have no color and should be saved as 16bit grayscale images. However when using imagemagick, it results ina darker grayscale image. If i leave colorspace alone, then it looks right, but is still RGB
All resulting in the same thing. If i look at the desaturated rgb image in photoshop, each channel is correct so I'm not sure how IM is extracting the channel and it being darker. Am i missing something in this process?
What version of IM? How are you viewing the images? Can you give and example image?
Lots of changes were made in the last few months to do with colorspace handlin in IM, specifically correctly setting sRGB colorspace on most images. The exception to this is greyscale images.
Note that -seperate will generate 'gray' colorspace images, as that is what channel extracted images are.
A pure grayscale image in IM (colorspace "gray") is saved as linear grayscale, rather than sRGB (to avoid colorspace conversion losses). Many viewers automatically convert image colorspace to sRGB for display. Web browsers like Firefox does, which typically results in an image becoming brighter. Note that the IM "display" comamnd does not do this conversion (by default, as users can request the conversion), and shows the data AS IS.
Photoshop probably also shows and edits the data AS IS (so it looks darker). You do not want to convert values unless you really need to, especially in 8 bit resolution (photoshop) IM typically is either 16 bit integer values, or in some cases HDRI (floating point).
This is an area that is still being discussed and looked at within ImageMagick. Remember most grayscale images are mathematical linear value images (alpha masks, lighting effects, LUTs, Fourier Transform Spectrum, channel separations, etc), but grayscale photos should be saved using a non-linear sRGB colorspace, and not a linear colorspace.
Part of this is part of the preparations for IMv7 which will handle one channel images in memory with auto-promoting them to 3 color channels. It can also handle multi-spectral images containing dozens of channels, though there are few image file formats that can save such images.
-colorspace gray produces a linear gray. add -set colorspace RGB before it to force it to create a non-linear gray as it used to on older than IM 6.7.5.5 (possibly before 6.7.6.7).
-modulate does not convert to linear gray, so -set colorspace RGB is not needed
Actually modulate converts the image to one of the special Hue colorspaces before applying its actions, then converts back again. As such it essentially ignores the current colorspace (except to what to restore the image to after it has done its work).
im on the latest. My image to test is a simple gradient 512x512. In PS it's 3channel, but has been completely desaturated. Theoretically i just need to extract the r channel as they all should be the same, right? But in PS the resulting image from -separate looks darker than the R channel in PS. Is this just PS doing something to it?
None of us can say anything for sure about the coding of PS?
I believe that PS uses the desaturate method (-modulate) to get grayscale, but it is not clear which colorspace they use (HSL, HSB, HCL).
I do know that PS may not use the same mixing of channels to get grayscale from their channel mixer. IM grayscale is linear and needs -colorspace RGB to force it to be non-linear the way it used to work and the way I presume PS works. The IM channel mixing to get gray is defined by standards and is specified at http://www.imagemagick.org/script/comma ... colorspace as
Gray = 0.298839*R+0.586811*G+0.114350*B
I think PS uses a default of .3R + .6G + .1B in their channel mixer.
theiviaxx wrote:was the resulting image grayscale or rgb?
It was gray, but I did not look at the colorspace. But if you add -type grayscale after -modulate, the result should be a gray image with colorspace gray
Yes, the two viewers are displaying differently. IM displays as the colorspace dictates, in this case linear. But most other viewers display as non-linear (sRGB). I would suggest you view both images in some browser. But don't expect all browsers to view alike, either. Just display in the same viewer all the time.
But I am puzzled why you need all the -colorspace sRGB at the beginning, if your tif is already sRGB?
It is kind of hard to know what to tell you unless you provide your input image, your output image and your PS image and what PS function(s) you used to create it. Then other can see and test with your image.
Here are two images:
* color1.tif is the source, it's desaturated but has 3 channels
* _color1.tif is the result from PS. Simply changing the mode to Grayscale. In photoshop they look the same
So I tried running compare against these two and there is a difference. ~2% in my tests. If i view them with picasa or windows, they do look different. the grayscale looks darker. In PS they look the same, so PS is doing some magic there.
I guess my final question is why is it so difficult to grab a single channel from a tiff without loss?
If you switch to grayscale, then each channel gats multiplied by the values listed above. But if all channels are the same, then you will get a different image, right?