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:



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:



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.

  • 6
    $\begingroup$ I don't think what you want is really a blur but a white frame with an alpha gradient. $\endgroup$ Commented Jan 4, 2015 at 18:54

2 Answers 2

pic = Import["https://i.sstatic.net/TPxVj.png"]


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

ImageEffect[pic, "FadedFrame"]

Pre V11.2

alpha = Composition[
   GaussianFilter[#, 10] &,
   BoxMatrix[#/2 - 5, #] &,

SetAlphaChannel[pic, alpha]

enter image description here

  • 1
    $\begingroup$ 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" $\endgroup$
    – Dan Oak
    Commented Apr 19, 2016 at 16:32
  • $\begingroup$ @DanyloDubinin Thanks :) Deleted. $\endgroup$
    – Kuba
    Commented Apr 19, 2016 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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.