Wednesday, June 5, 2013

3D Printed Photograph

IMG_0032 copy.jpgThe 3d printer in our office (an Objet Connex500) prints with a rigid, semitransparent white material that can be used to create these unique black and white photographic prints.  These prints may be indecipherable when viewed from the side, but when backlit with a diffuse light, they recreate images with surprisingly high precision and even add some subtle dimensionality and texture to the scene.

Some will remember Beer's law from high school chemistry; it states that the absorption of light by a material varies linearly with the distance light travels through the material.  By varying the thickness of a region of this semitransparent print you can control the amount of light that is able to pass through, thereby controlling the brightness (thinner regions of material will appear brighter and thicker regions darker).  In this project, I've mapped each individual greyscale pixel value of an image to thickness, allowing me to precisely reproduce any greyscale image.  The photos I've printed include an adorable picture my mom took of our cat Teddy (fig 4), Saturn and its moon Titan taken by the Cassini space probe (fig 5 and 6), and a huge print (19x16") of Mt. Williamson by Ansel Adams (fig 1, 2, and 3).

print.jpgAll of these 3D models were generated algorithmically from Processing using the ModelBuilder library by Marius Watz.  This library allows you to save 3D geometries in the STL file format, STL files that form a watertight mesh can be printed by a 3D printer.

To get started using this code yourself, download the latest version of the ModelBuilder library, unzip the file, and copy the folder into Processing's "libraries" folder.  If you have installed the predecessor to the ModelBuilder library (called the Unlekker library), you will need to delete it.  Once this is done restart Processing.

//3D printed photograph//by Amanda Ghassaei//May 2013//http://www.instructables.com/id/3D-Printed-Photograph//* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version.*///librariesimport processing.opengl.*;import unlekker.util.*;import unlekker.modelbuilder.*;import ec.util.*;String name = "YOUR_FILE_NAME.jpg";//name of file//storage for dimensionsint widthRes;int heightRes;float widthDim = 8;//width dimension (in inches)float widthScaled;float heightScaled;float zDim = 0.1;//max vertical displacement (in inches)float thickness = 0.02;//base thickness (in inches)boolean invert = true;//if true, then white areas are lower than black, if not true white areas are tallerPImage img;//storage for imagefloat pixeldata[];//storage for pixel arrayUVertexList v1,v2,v3,v4;//storage for verticiesUGeometry geo;//storage for stl geometryvoid setup(){ img = loadImage(name);//load image //get dimensions of image widthRes = img.width; heightRes =img.height; size(widthRes,heightRes,P3D);//set dimensions of output image(img, 0,0);//display image loadPixels();//poad pixels into array pixeldata = new float[widthRes*heightRes];//initialize storage for pixel data for(int index=0;index 0) name = name.substring(0, dotPos); geo.writeSTL(this,name+".stl"); exit(); println("Finished");}Copy the Processing sketch above and save it.  Processing will automatically put this file inside a folder of the same name.  Copy any greyscale images you want to convert into this folder.

To run the sketch, replace the part in quotes in following line:

String name = "YOUR_FILE_NAME.jpg";

with the name of your greyscale image. I believe .gif, .jpg, .tga, and .png files will all work fine, but I have only tested .jpg so far.  Run the sketch, after a minute or two Processing will tell you that it is writing an STL file and eventually it will tell you that it is finished.  The resulting file will be located in the sketch's folder named "NAME_OF_ORIGINAL_FILE.stl"

You can open the stl file with a variety of CAD software and stl viewers, I like MeshLab for simple viewing (it's free and open source).

By default my sketch will scale images to 8" wide, with a base thickness of 0.02" and feature thickness of up to 0.1", you can change these setting by adjusting the variable at the top of the sketch.


View the original article here

No comments:

Post a Comment