Color blur

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
dognose
Posts: 265
Joined: 2005-03-08T22:16:37-07:00

Color blur

Post by dognose »

I was just watching this video on how broken color blur is
https://www.youtube.com/watch?v=LKnqECcg6Gw

and noticed the same problem with IM -blur and -gaussian-blur

Image

Notice the dark line in the middle.

Is there an easy way to fix this?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Color blur

Post by fmw42 »

try this

Code: Select all

convert -size 300x300 xc:red xc:green1 +append \
-evaluate pow 2 -blur 0x3 -evaluate pow 0.5 tmp.png
pow 2 = square

pow 0.5 = sqrt
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Color blur

Post by snibgo »

It isn't "wrong", but just the way it works.

The perceived dark band occurs when we blur (or anti-alias, etc) in sRGB, or other non-linear colorspace. If we don't want this, then convert to linear colorspace before blurring, and back to non-linear afterwards.

If the image is encoded in sRGB, then use "-colorspace RGB" and "-colorspace sRGB". Or as the video says inaccurately, square and square-root. Or, better, use 2.2 and 0.454545.
snibgo's IM pages: im.snibgo.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Color blur

Post by anthony »

It is also because the blur blurs red areas into black, and green areas into black because they are seperate color channels!
Try doing the blur in a different (also more linear) colorspace. Perhaps LAB or LUV colorspace.

Though snibgo is right in that the non-linear colors of sRGB is probably the main culpret

Hmmm...

Code: Select all

convert -size 50x50 xc:red xc:green1 +append -blur 0x30 show:
convert -size 50x50 xc:red xc:green1 +append -colorspace RGB -blur 0x30 -colorspace sRGB show:
convert -size 50x50 xc:red xc:green1 +append -colorspace LAB -blur 0x30 -colorspace sRGB show:
convert -size 50x50 xc:red xc:green1 +append -colorspace LUV -blur 0x30 -colorspace sRGB show:
The first shows the 'black' band. The other three (linear colorspace blurs) show basically identical, 'orange' bands.

This may be the best example yet on why image processing in sRGB is a bad idea.

Added the above into
http://www.imagemagick.org/Usage/color_ ... processing

UPDATE: The linked examples has now been formatted with example image results.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply