# How can I make a blurred or gradient photo frame?

I would like to "frame" a photo with a rectangular blur or gradient. Here is an example from the web that was not made using Mathematica. (Of course, anything is possible; I suppose that this example from the web may have been made using Mathematica, but I'm guessing that it was not.)

Regular version:

Blurred frame version:

My question is, given a normal, unframed photo image, how can I accomplish this sort of blurred/gradient photo frame in Mathematica? Are there any relatively straightforward ways of accomplishing this sort of effect? (The result doesn't have to be at all exactly like the example above; I'm just using the above example to illustrate generally what I would like.) It would be preferable if it could be accomplished using Mathematica 8 or 9, but if Mathematica 10 is necessary, that is fine, too.

Suppose that I import the regular image in a variable regular:

regular = Import["regular.jpg"]


I can blur the entire image using Blur:

Blur[regular]


I can also introduce a temporarily solid frame (i.e., a solid band of white -- or, here, yellow, so that you can see it against this white page) using ImagePad:

solidFrame = ImagePad[regular, 10, Yellow]


Then I can blur the result with Blur:

Blur[solidFrame]


Or, with a White ImagePad:

But, again, of course, the interior of the image becomes blurred as well. So I need some way to delineate the "frame area" of the image from the "interior" of the image. Is there any way to do this? Thanks so much for your time.

• I don't think what you want is really a blur but a white frame with an alpha gradient. – Martin Ender Jan 4 '15 at 18:54

pic = Import["http://i.stack.imgur.com/TPxVj.png"]


## V11.2+

As of V11.2 it is directly supported by ImageEffect:

ImageEffect[pic, "FadedFrame"]


## Pre V11.2

alpha = Composition[
GaussianFilter[#, 10] &,
Image,
BoxMatrix[#/2 - 5, #] &,
Reverse
][
ImageDimensions@pic
]

SetAlphaChannel[pic, alpha]


• there is a superfluous comma inside Composition body. the code doesn't work in version 10 because of that comma. please correct it, as noone else can do it: "edit must be at least 6 characters" – Dan Oak Apr 19 '16 at 16:32
• @DanyloDubinin Thanks :) Deleted. – Kuba Apr 19 '16 at 16:36

The above is an excellent answer to the specific question posed. Reading the documentation info on ImageApply[] and "Masking" provides another mechanism for performing image processing operations selectively on image regions.

Complex masks for ImageApply[] can be generated offline and Imported as mask images using software such as GIMP or Photoshop, giving some artistic freedom to the design of masks.