Page 1 of 1

Invert region

Posted: 2013-11-21T07:00:01-07:00
by figgis
I'm trying to blur a picture except a region in the middle. Something like this:

Image

I only see options to do the opposite, i.e. blur a region and I need the inverse.
Can it be done?

Right now I'm trying to solve this by croping out the region in the middle, blurring the complete image and then merging the cropped region on top of the blurred image; quite messy!

Re: Invert region

Posted: 2013-11-21T08:30:18-07:00
by snibgo
The obvious way would be to use "+region", which would be like "-region" but allow changes outside the rectangle. Sadly, there is no "+region".

Instead, we can compose a blurred version over a non-blurred version, using a mask that is a black rectangle on a white background. In this Windows script, b.png is a test image.

Code: Select all

%IM%convert -size 600x400 label:snibgo b.png

%IM%convert ^
  b.png ^
  ( +clone -blur 0x5 ) ^
  ( +clone -fill White -colorize 100 -fill Black -draw "rectangle 100,100,499,149" ) ^
  -composite ^
  bz.png

Re: Invert region

Posted: 2013-11-21T08:58:00-07:00
by figgis
Haven't used windows for a decade but I'll try this tonight when my kids have fallen asleep :-)

Thanks!