2024-12-04 14:36:00
divisbyzero.com
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.
- Relax your eyes.
- Let your eyes diverge. Look through the image as if it’s a window, and you are focusing on something beyond it.
- 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 π 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.)
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 300×300 “depth map” for the desired 3D image. In my π example above, there are only two depths—the background (corresponding to 0 in the cell) and the π 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 π. First, I created the image shown below with a black π 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.
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 300×300 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 π 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 π example, we have multfactor
= 4, so a depth of 1 yields a shift of
That’s it! Have fun playing. Here are some examples.
This one shows a familiar mathematical variable.
This one shows a familiar mathematical symbol.
This one shows a surface: the graph of a multivariable function.
This one shows a surface: the graph of a multivariable function.
This one shows one of our earlier symbols again. I changed the pattern for the first few columns. That gave this repeating look.
This one shows one of our earlier symbols again. I changed the pattern for the first few columns. That gave this repeating look.
Keep your files stored safely and securely with the SanDisk 2TB Extreme Portable SSD. With over 69,505 ratings and an impressive 4.6 out of 5 stars, this product has been purchased over 8K+ times in the past month. At only $129.99, this Amazon’s Choice product is a must-have for secure file storage.
Help keep private content private with the included password protection featuring 256-bit AES hardware encryption. Order now for just $129.99 on Amazon!
Support Techcratic
If you find value in Techcratic’s insights and articles, consider supporting us with Bitcoin. Your support helps me, as a solo operator, continue delivering high-quality content while managing all the technical aspects, from server maintenance to blog writing, future updates, and improvements. Support Innovation! Thank you.
Bitcoin Address:
bc1qlszw7elx2qahjwvaryh0tkgg8y68enw30gpvge
Please verify this address before sending funds.
Bitcoin QR Code
Simply scan the QR code below to support Techcratic.
Please read the Privacy and Security Disclaimer on how Techcratic handles your support.
Disclaimer: As an Amazon Associate, Techcratic may earn from qualifying purchases.