Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm preparing a presentation where I want to place a background image on each slide (for aesthetics).

These are extremely color filled images (like photos; lets use "ExampleData/lena.tif" as example), which means that once they are the background, the text becomes hard to read.

So, I wanted to have some fading, like white at the top left corner (my background is not white: {253,253,251}, which means that the background color is important to be an option), and then fading in in the direction of the bottom right corner.

This fading should not change the color in itself (if you understand what I mean: not brighter, but more or less "transparent"). Transparent fading would be the best, since it would cover for whichever slide layout we have; but not sure how to pass it correctly to another program (using MS Powerpoint).

It would be great to be able to change each extremity fade value (that is, not from 0 to 1 all the time), and to change direction.

To change the fading function is a plus, but I think that not needed at this time (I mean: linear in the chosen direction, or power, or etc.)

share|improve this question
add comment

1 Answer 1

up vote 10 down vote accepted

To fade the transparency of an image, you need to create a second image which fades from black to white and set it as the alpha channel of the image.

Here is a simple interface which will let you adjust the angle, position and sharpness of the fade.

image = ImageResize[ExampleData[{"TestImage", "Apples"}], 400];

{w, h} = ImageDimensions[image];
fadex = N@Table[x, {x, -1, 1, 2/(h - 1)}];
fadey = N@Table[y, {y, -1, 1, 2/(w - 1)}];

Manipulate[SetAlphaChannel[image, 
   Image[a (b + Outer[Plus, fadex Sin[t], fadey Cos[t]])]],
 {{t, Pi/4, "angle"}, 0, 2 Pi},
 {{a, 1.5, "sharpness"}, 0.5, 5},
 {{b, 0.25, "position"}, -1, 1}]

enter image description here

To use the partially transparent image in PowerPoint you should save it as a PNG file. Alternatively, look at Todd Gayley's answer here for a way to copy it to the clipboard without losing the transparency (Windows only).

Here is the image from the above Manipulate overlaid onto a checkerboard pattern to show the transparency better:

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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