Hi,
I'm using -color-matrix on a bunch of images to change colour temperature slightly:
convert -quality 94 -color-matrix "1.0 0 0 0 0.975 0 0 0 0.95" x.jpg y.jpg
Problem is, in blue sky areas, this sometimes causes patchy colours and banding issues. However, and this is the strange part, if I convert to TIFF (even using JPEG compression), and then apply the colour matrix, I don't get these issues.
BUT, even wierder, if I then try to convert the resulting TIFF image (which looks fine) to JPEG again (even with -quality 100), I get these patchy colours again.
Anyone have any idea why this might be, and what I can do to avoid it?
This is with ImageMagick 6.7.0-10 2012-08-11 Q16 on a Fedora Linux system.
Many thanks in advance.
-color-matrix causes patchy colours but only with JPEG
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: -color-matrix causes patchy colours but only with JPEG
try reading the input image before the optionsconvert -quality 94 -color-matrix "1.0 0 0 0 0.975 0 0 0 0.95" x.jpg y.jpg
convert x.jpg -color-matrix "1.0 0 0 0 0.975 0 0 0 0.95" -quality 94 y.jpg
see
http://www.imagemagick.org/Usage/basics/#why
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: -color-matrix causes patchy colours but only with JPEG
I suspect the banding problem comes from quantum=8 in ordinary jpegs, but it's hard to tell without an example.
snibgo's IM pages: im.snibgo.com
Re: -color-matrix causes patchy colours but only with JPEG
You are right, I should have written it this way, but the artifacts are still there when I rearrange it unfortunately.try reading the input image before the options
I does look like that kind of problem. Would this be even when it's compiled with quantum=16? Oddly, although the 8-bit TIFFs it generates look ok, any attempt to convert them to JPEGs (even with quality 100), results in the same issues. This includes converting using other applications like the GIMP.I suspect the banding problem comes from quantum=8 in ordinary jpegs, but it's hard to tell without an example.
Are there colours that just can't be represented in JPEGs that can be represented in TIFFs using JPEG compression, and ImageMagic is using these in the TIFF files? I would have assumed that any RGB colour would be able to be represented in JPEGs or TIFFs, if 100% quality was used.
In case it helps, I've uploaded three example files: the original, the TIF after -color-matrix is applied, and the JPEG after the same operation (or after being converted from the TIFF) :
http://datadeliverance.com/photos/img_238374.jpg
http://datadeliverance.com/photos/img_238374-2.tif
http://datadeliverance.com/photos/img_238374-2.jpg
(Note that this is part of a bracketed set, which is why it's so dark. The artifacts are sometimes greatly accentuated after HDR processing.)
Thanks
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: -color-matrix causes patchy colours but only with JPEG
In the original, img_238374.jpg, I can see that the variation in the sky, from dark at the top becoming lighter at the horizon, isn't an even transition. There are "bumps" so to speak in the variation. I suspect this occurred in the scene, perhaps from high thin cloud, and isn't an imaging artefact.
However, changing pixel values (such as by your matrix) often exagerates such un-evenness. "-quality 100" for a jpeg makes the bumpiness more obvious. I suspect the lower quality settings remove the "irrelevant" detail.
I think that's the effect here -- the exaggeration of the unsmooth transition -- rather than genuine banding, which is the quantisation of a smooth transition into fewer colours. Perhaps both effects are in play.
I know nothing about IM's jpeg compression in tiffs, as I use zip compression. In this case, I can't see any visual difference between zip compressed tiff and a jpeg at quality 94.
If you have raw camera files, a comparison might be interesting.
However, changing pixel values (such as by your matrix) often exagerates such un-evenness. "-quality 100" for a jpeg makes the bumpiness more obvious. I suspect the lower quality settings remove the "irrelevant" detail.
I think that's the effect here -- the exaggeration of the unsmooth transition -- rather than genuine banding, which is the quantisation of a smooth transition into fewer colours. Perhaps both effects are in play.
I know nothing about IM's jpeg compression in tiffs, as I use zip compression. In this case, I can't see any visual difference between zip compressed tiff and a jpeg at quality 94.
If you have raw camera files, a comparison might be interesting.
snibgo's IM pages: im.snibgo.com