6
$\begingroup$

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).

Some related hopefully useful images:

example 1

example 2

example 3

example 4

example 5

$\endgroup$

2 Answers 2

7
$\begingroup$

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

im = Import["https://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.

$\endgroup$
1
  • $\begingroup$ 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! $\endgroup$ Mar 18, 2013 at 19:59
6
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ Thank you! ImageCompose is what I needed. Great answer, I appreciate your input. $\endgroup$ Mar 18, 2013 at 20:05

Your Answer

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

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