https://divisbyzero.com/2024/11/30/make-a-magic-eye-image-using-excel/ Skip to content David Richeson: Division by Zero Menu * Home * About Me * Teaching + Teaching + My Applets + A Quick Guide to LaTeX + Letters of Recommendation + The nuts and bolts of writing mathematics * Research + Research + Publications + Invited Presentations + BOOK: Tales of Impossibility + BOOK: Euler's Gem + Math Horizons * Blog Academic Technology, Math Make a "Magic Eye" image using Excel Posted by Dave Richeson on November 30, 2024 I've been on a weird kick lately making images using Excel. [Here's one post. I hope to post more soon.] If you add a background color to each cell in a spreadsheet and resize the cell widths to make each one square, then you can zoom out so that each cell acts like a pixel in an image. In this post, I show how you can create your own "Magic Eye" image using Excel. (I also give you an Excel spreadsheet to get you started.) Technically these images are called autostereograms. These are two-dimensional images that appear three-dimensional when viewed correctly with your two eyes. Here are some tips for viewing these images. 1. Relax your eyes. 2. Let your eyes diverge. Look through the image as if it's a window, and you are focusing on something beyond it. 3. If there are similar patterns in the pixels, allow them to come together as one in your vision. Here's one example I made. You shoud see a flat background with one large copy of the letter p floating a little above the background (closer to you). I have several other examples at the end of this post. (These all work better on a larger screen--not on a phone screen.) [pi] I'll now share how I made these images and give you enough details to make your own. If you want to make your own, download this Excel file , which has my sample code in it. The Excel file has three tabs at the bottom: the "Final" tab has the final image, the "Raw" tab contains the depth map for the image you'd like to create, and the "Parameters" tab allows you to adjust three parameters. Raw tab. This tab contains the 300x300 "depth map" for the desired 3D image. In my p example above, there are only two depths--the background (corresponding to 0 in the cell) and the p in the foreground (1). If you want to design a more complex shape with more depth, you can have different values in the cells (they do not have to be integers). For instance, two of the images below show undulating surfaces with varrying depths. I used ChatGPT to help create the depth map for p. First, I created the image shown below with a black p on a white background. I then uploaded it to ChatGPT and typed the following prompt. I am uploading a square black and white image. I would like a csv file with 300 rows and 300 columns that shows this image. In particular, I would like you to imagine shrinking this down to a 300x300 image, and then converting the white pixels to be 0 and the black pixels to be 1. [magiceyepi] For the two images showing surfaces, I begain with a top row and a left column that gave a sequence of points along the x- and y-axes, respectively. Then, I created a formula in each cell that evaluated a function at the corresponding x and y values. Here's the code in cell B2 for one example. =SIN(SQRT(B$1^2+$A2^2))/SQRT(B$1^2+$A2^2)+1 Parameters tab. This tab allows you to enter three values that will change the look of the final image: numcolors, backshift, and multfactor. Final tab. The "Final" tab contains the final image. To view this page, you want to zoom far enough out that the entire image is visible. You don't have to edit this page at all. It is generated using the information you provide in the other two tabs. This page is a 300x300 grid, and each cell contains a number 1 through numcolors. Excel's "conditional formatting" colors the page automatically based on the number. (You can change the colors by changing the conditional formatting for these cells.) Each cell has code like the following. (This code is in cell A1.) =LET( depth,Raw!A1, numcolors,Parameters!$B$1, backshift,Parameters!$B$2, multfactor,Parameters!$B$3, pixelshift,TRUNC(backshift-depth*multfactor), IF( COLUMN()>backshift, OFFSET(A1,0,-pixelshift), RANDBETWEEN(1,numcolors) ) ) Here's what it does. The general idea is that we want our two eyes to see two different horizontally-separated pixels of the same color as one pixel. The closer together the pair of pixels, the nearer to you the combined pixels will seem when looking at the image with both eyes. For the first backshift number of columns, the code randomly assigns a number (which we think of as a color): 1 through numcolors. For the rest of the columns, the color of a pixel is the same as the color of some pixel to its left. For points on the flat background (corresponding to a depth of 0), each pixel is the same color as the pixel backshift spaces to the left. My p example has backshift= 40. The pixels we want to appear closer to us should be closer together; in this code, such a pixel is the same color as the one backshift-depth*multfactor cells away. In our p example, we have multfactor= 4, so a depth of 1 yields a shift of 40-1\cdot 4=36. That's it! Have fun playing. Here are some examples. This one shows a familiar mathematical variable. [x] This one shows a familiar mathematical symbol. [infinity] This one shows a surface: the graph of a multivariable function. [function1-1] This one shows a surface: the graph of a multivariable function. [function2] This one shows one of our earlier symbols again. I changed the pattern for the first few columns. That gave this repeating look. [pi2] This one shows one of our earlier symbols again. I changed the pattern for the first few columns. That gave this repeating look. [infinity2] Share this: * Twitter * Facebook * Reddit * Email * Print * Like Loading... Related artautostereogramExcelillusioninfinityMagic EyeMathMutilvariable calculuspitechnology Post navigation Previous Post Making the Mandelbrot Set with Excel 2 Comments Add yours 1. Andre says: December 1, 2024 at 5:53 am Heads up that the images seem to get compressed in the newsletter email, which messes them up in interesting ways. Reply 1. Dave Richeson says: December 1, 2024 at 11:10 am Hmmm... That's too bad. Good to know though! Reply Leave a comment Cancel reply [ ] [ ] [ ] [ ] [ ] [ ] [ ] D[ ] Contact info Dave Richeson Professor of Mathematics Dickinson College Twitter: divbyzero Search for: [ ] [Search] My books Tales of Impossibility: The 2000-Year Quest to Solve the Mathematical Problems of Antiquity (Princeton University Press, 2019) [cover] Buy it: Princeton University Press Amazon Euler's Gem: The Polyhedron Formula and the Birth of Topology ( Princeton University Press, 2008) [EGthumb] Buy it: Princeton University Press Amazon Recent Posts * Make a "Magic Eye" image using Excel * Making the Mandelbrot Set with Excel * Fold-and-Cut Turtle Tile * Fold-and-Cut Hat and Spectre Tiles * Cardioid Drawbridges Top Posts * Make a "Magic Eye" image using Excel * Making the Mandelbrot Set with Excel * David Richeson * How to curve an exam and assign grades * Essential Trigonometry for Calculus * Make a Sugihara Circle/Square Optical Illusion Out of Paper * Sugihara's Circle/Square Optical Illusion * Playing the probabilities in Settlers of Catan * Two More Impossible Cylinders * Seventeen Facts about 17 * Comment * Reblog * Subscribe Subscribed + [4497ee] David Richeson: Division by Zero Join 489 other subscribers [ ] Sign me up + Already have a WordPress.com account? Log in now. * + [4497ee] David Richeson: Division by Zero + Customize + Subscribe Subscribed + Sign up + Log in + Copy shortlink + Report this content + View post in Reader + Manage subscriptions + Collapse this bar Loading Comments... Write a Comment... [ ] Email (Required) [ ] Name (Required) [ ] Website [ ] [Post Comment] %d [b]