how to blur circle edges inside and not outside ?

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
ravikum
Posts: 34
Joined: 2013-03-20T05:35:37-07:00
Authentication code: 6789

how to blur circle edges inside and not outside ?

Post by ravikum »

Hello,

I have a black circle on white background. (or any other colors)
i want to blur the edges of the circle.
So, I want the radius of the blurred circle not to increase.

when we use

Code: Select all

input -blur 0x8 output
I think it blurs outside.

Is it possible to blur inside and not outside?

Please suggest.
Thanks
(using the latest IM version on linux centos 6)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: how to blur circle edges inside and not outside ?

Post by snibgo »

You can mask the effect, so the result inside the circle is from the blur, and the result outside the circle is from the image before the blur. Eg Windows BAT script:

Code: Select all

%IM%convert ^
  -size 200x200 xc:White ^
  -fill Black -draw "circle 100,100 100,50" ^
  ( -clone 0 ^
    -blur 0x20 ^
  ) ^
  +swap ^
  -clone 1 ^
  -composite ^
  c.png
snibgo's IM pages: im.snibgo.com
ravikum
Posts: 34
Joined: 2013-03-20T05:35:37-07:00
Authentication code: 6789

Re: how to blur circle edges inside and not outside ?

Post by ravikum »

Hi,
thanks for your reply.

I tried to implement your code.
Image
In this image, first one is original circle.
second circle is what I got using your code.
Third is like what I want, but this got a bigger radius [ using the code -blur 0x20 ]

Using your code, the circle doesn't merge with the background like the third image.

Is there any way to achieve like the third image with the radius like the first one?

Please suggest.
Thanks.
(using the latest IM version on linux centos 6)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: how to blur circle edges inside and not outside ?

Post by snibgo »

You could start with a smaller circle. Or level the image:

Code: Select all

convert ^
  -size 200x200 xc:White ^
  -fill Black -draw "circle 100,100 100,50" ^
  -blur 0x20 ^
  -level 0,50%% ^
  c2.png
snibgo's IM pages: im.snibgo.com
ravikum
Posts: 34
Joined: 2013-03-20T05:35:37-07:00
Authentication code: 6789

Re: how to blur circle edges inside and not outside ?

Post by ravikum »

Thanks a lot snibgo
This code worked perfectly.
You saved me!
(using the latest IM version on linux centos 6)
Post Reply