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'd like to import an image, superimpose it, reduce the opacity of the overlaid image, and then use a manipulate to rotate the top image to illustrate rotational symmetry.

The image below is using image editing software,not Mathematica, but illustrates the effect I am after.

example of the effect I am after

There are many nice images on the net that could be used to illustrate this concept. Can this be done using Mathematica and the image processing commands?

I tried importing an image file, then used Show and ImageRotate

for example,

g1 = Import[ graphic....]
Show [ g1,  ImageRotate[g1, pi/4]]    but that wasn't at all what I was looking for...

I'd appreciate any suggestions for commands that could achieve this effect.

My goal would be to create several Manipulates with various images to illustrate various orders of symmetry with image files (I've already done this with line drawings),

share|improve this question

2 Answers 2

up vote 5 down vote accepted

Here is another approach using a background to prevent cropping of the rotated image when its aspect ratio is far from 1:

im = Import["http://i.stack.imgur.com/pyNu2.png"]

img

im2 = SetAlphaChannel[im, ColorNegate[im]];
bg = ImageCompose[
   Rasterize[
    Graphics[{Lighter[Orange], Rectangle[{0, 0}, {1, 1}]}, 
     PlotRange -> {{0, 1}, {0, 1}}], "Image", ImageSize -> 600], im2];

Manipulate[
 Show[ImageCompose[bg, ImageRotate[im2, angle, {600, 600}]]], {angle, 
  0, 2 Pi}]

manipulate

Edit

If you want smooth blending instead of a sharp alpha channel as I did in the first approach, you could do this:

crop = Rasterize[
   Graphics[{White, Disk[]}, PlotRange -> {{-1, 1}, {-1, 1}}], 
   "Image", ImageSize -> 600, Background -> Black];

Manipulate[
 SetAlphaChannel[
  ImageCompose[bg, {ImageRotate[bg, angle, {600, 600}], .5}], 
  crop], {angle, 0, 2 Pi}]

man2

Here, I added another cropping mask in the form of a disk to prevent the partially uncovered corners from showing.

share|improve this answer
    
Thank you, that's fantastic and just what I needed. I also appreciate the extra help with dealing with images that are not square. I've already put this approach to use on a lesson I'm giving to a student tomorrow. Thanks so much! –  Tom De Vries Mar 18 '13 at 19:59

Something like this maybe:

image = ImageResize[ExampleData[{"TestImage", "Lena"}], 200];

Manipulate[ImageCompose[image, {ImageRotate[image, a], 0.5}], {a, 0, 2 Pi}]

enter image description here

share|improve this answer
    
Thank you! ImageCompose is what I needed. Great answer, I appreciate your input. –  Tom De Vries Mar 18 '13 at 20:05

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.