Page 1 of 1

Color banding with high blur values

Posted: 2019-10-15T01:06:35-07:00
by leoncvlt
Hi all, I'm experiencing some faint color banding when blurring an image with high values - might be hard to see see but they are noticeable, especially in the center:

Image

I read that image magick automatically performs the blur operation at a bit depth of 16 so this shouldn't happen. I tried forcing this by adding

Code: Select all

depth -16
to the output - it's a .png, correctly identified at

Code: Select all

16-bit sRGB 2099910B 0.016u 0:00.001
but I still get that banding.

The command I'm using is a slight modification of fred's surroundblur script (http://www.fmwconcepts.com/imagemagick/ ... /index.php) to make it work in a python script on windows:

Code: Select all

  "magick", "convert", f"\"{input_file}\"", "-write mpr:img +delete",
  f"( mpr:img -resize {bg_size}! -crop {bg_size}+0+0 +repage -blur 0x{bg_blur} )",
  f"( mpr:img -resize {cover_size} -bordercolor {border_color} -border {border} )",
  f"( +clone -background black -shadow {shadow_darkness}x{shadow_fade}+{shadow_extent}+{shadow_extent} )", 
  "( -clone 2,1 -background none -layers merge +repage )",
  "-delete 1,2 -gravity center -compose over -composite",
  f"\"{output_file}\""
Thanks!

Re: Color banding with high blur values

Posted: 2019-10-15T02:13:41-07:00
by snibgo
Your linked image is 8-bit.

Your code doesn't have "-depth 16".

What version of IM? What does "magick -version" say?

I suggest you use "magick", not "magick convert".

Re: Color banding with high blur values

Posted: 2019-10-15T02:56:59-07:00
by leoncvlt
snibgo wrote: 2019-10-15T02:13:41-07:00 Your linked image is 8-bit.

Your code doesn't have "-depth 16".

What version of IM? What does "magick -version" say?

I suggest you use "magick", not "magick convert".
The image is 8-bit because it's just a screenshot of a part of the original image I took with the snipping tool. I removed the depth option from the code when I noticed it didn't make any difference. Here's the code again using just magick and with the depth option, alongside with the original input image and resulting output:

Code: Select all

magick input.jpg -depth 16 -write mpr:img +delete ( mpr:img -resize 1280x720! -crop 1280x720+0+0 +repage -blur 0x80 ) ( mpr:img -resize 480x480 -bordercolor white -border 10 ) ( +clone -background black -shadow 50x8+12+12 ) ( -clone 2,1 -background none -layers merge +repage ) -delete 1,2 -gravity center -compose over -composite output.png
input.jpg: https://filebin.net/ba3geqk2to98gotf/in ... t=n0tgy7zm
output.png: https://filebin.net/ba3geqk2to98gotf/ou ... t=n0tgy7zm

The magick -version ouput is:

Code: Select all

λ magick -version
Version: ImageMagick 7.0.8-68 Q16 x64 2019-10-05 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenCL OpenMP(2.0)
Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg lcms lqr lzma openexr pangocairo png ps raw rsvg tiff webp xml zlib

Re: Color banding with high blur values

Posted: 2019-10-15T03:31:56-07:00
by snibgo
Your output.png is still only 8-bit. Is that also a screenshot? Please post the actual file, not a screenshot.

As a test, I suggest you insert "+write abc.png" after the blur, to save just that image. Check this is 16-bit. Then:

Code: Select all

magick abc.png -auto-level abc2.png
This may show clear banding. With Gimp's eyedropper or similar, examine abc.png to see whether the values change by only one bit (out of 16 bits) at the band transitions. If they do, then no better result is possible.

Re: Color banding with high blur values

Posted: 2019-10-15T07:42:54-07:00
by leoncvlt
I did check with the eyedropper tool and indeed the colors do change by one bit at the time - guess this is the best I can do with this setup. However, exporting at a higher resolution (1080p compared to 720p) already generates a way better looking result. Thanks!