The advantages of parametric design

I work primarily in OpenSCAD when making designs for 3D printing (and 2D designs for lasercutting). This means that instead of a WYSIWYG interface based primarily on using the mouse, my designs are all scripted in a programming language that looks a lot like C. This might seem a bit more difficult at first (and it is certainly less than ideal for some situations) but it makes for a pretty simple way to generate repetitive structural elements in basic flow control, i.e. for loops. Even more important, it means that I can substantially change a design by modifying the variable values passed to a function (called modules in OpenSCAD). For the sake of an example, take Lieberkühn reflectors for macrophotography. Lieberkühn reflectors are a classic illumination technique that have mostly fallen out of style in favour of more modern illumination such as LED or fibre-based lighting, but remains quite elegant and offers a few unique advantages. I have been working with these in conjunction with a few different lenses, and mostly with the help of a macro bellows. The bellows makes for variable working distances as well as magnifications, so the focus of one Lieberkühn will be the most effective only within a narrow range of macro-bellows lengths. Parametric designs such as the ones I create and work with in OpenSCAD allow me to change attributes such as the nominal working distance without starting each design from scratch. For example:

LRWD35

35mm Lieberkühn focus

LRWD30

30mm Lieberkühn focus

LRWD25

25mm Lieberkühn focus

LRWD20

20mm Lieberkühn focus

This approach has proven highly useful for me in terms of both creating highly customisable design and iterating to get fit just right. I’ll post results of my latest exploration of Lieberkühn reflectors soon after I receive the latest realisation in Shapeways bronzed steel.

Advertisements

Quantitative comparisons of #macrophotography with and without Lieberkühn reflectors

In order to quantitatively examine the effect of the the 3D printed Lieberkühn reflectors I described previously, I came up with two image quality metrics relevant to their use, both measured on the “dark side” of the image subject. The metrics we will look at today are average intensity and, as a measure of contrast, the standard deviation of pixel values on a line trace.

I’ll be using the Megachile photo from the previous post for these analyses.

The first line trace begins at right eye and extends back behind the wing:

DSC_0523redLineRightEye

DSC_0524redLineRightEye

RightEyeTraceValues

If we plot these values together, we see that the photo taken with the Lieberkühn (values in black) is brighter and brings out a lot more detail, while the photo taken without is relatively flat and dark. We see similar results for second and third traces, taken across the tegula and along the wing.

DSC_0523redLineAcrossThorax

DSC_0524redLineAcrossThorax

AcrossThoraxTraceValues

DSC_0523redLineWing

DSC_0524redLineWing

wingTraceValues

If we compare the average values:

octave3.2:25> mean(RE523(:,2)) %with Lieberkühn, right eye trace
ans = 102.00
octave3.2:26> mean(RE524(:,2))%w/o Lieberkühn, right eye trace
ans = 54.093
octave3.2:28> mean(AT523(:,2))%with Lieberkühn, trace across tegula
ans = 81.553
octave3.2:27> mean(AT524(:,2))%w/o Lieberkühn, trace across tegula
ans = 51.288
octave3.2:29> mean(W523(:,2))%with Lieberkühn, across the wing
ans = 103.85
octave3.2:30> mean(W524(:,2))%w/o Lieberkühn, across the wing
ans = 53.045

We see that taken together, the averages of the plots from the photo taken with the Lieberkühn are about 80% brighter than those without.

mean(Lieberkühn)/mean(no Lieberkühn) = 1.8142

octave3.2:56> std(RE523(:,2)))%with Lieberkühn, right eye trace
ans = 20.316
octave3.2:55> std(RE524(:,2))%w/o Lieberkühn, right eye trace
ans = 7.3926

octave3.2:54> std(AT523(:,2))%with Lieberkühn, trace across tegula
ans = 17.737
octave3.2:53> std(AT524(:,2))%w/o Lieberkühn, trace across tegula
ans = 13.227

octave3.2:52> std(W523(:,2))%with Lieberkühn, across the wing
ans = 12.746
octave3.2:51> std(W524(:,2))%w/o Lieberkühn, across the wing
ans = 8.2902

Using standard deviation as a metric for image detail, we get an increase of about 75% in standard deviation over the dark photo by using the reflector.

octave3.2:30> (20.316+17.737+12.746)/(7.3926+13.227+8.2902)
ans = 1.7572

The averages, standard deviation etc. may seem a bit redundant at this point; you don’t need to plot a pixel-value profile to see that the image with the reflector is much brighter and more detailed than the photo taken without. Rather than “proving” that the Lieberkühn photos are better, these notes will serve as a baseline for future iterations of the reflectors made with different materials and/or with the addition of a reflective coating.

Lens caps that screw on

Most lenses already have a standard, secure method for attaching accessories to the distal end. So why do we still put up with the infamy of squeeze-style caps that are so easily lost? Below are some iterations of my designs for threaded lens caps, designed with information on the lens filter thread standards from Wikipedia, and printed in various colors of Shapeways basic sintered plastic. They’re durable, can be colorful, and it’s possible to emboss custom text or an image on the front. Oh, and I never worry about them falling off in the bag.

DSC_0421 DSC_0423 DSC_0417 DSC_0132 DSC_0141 DSC_0933DSC_0568 DSC_0567

Standard sizes can be bought from http://www.shapeways.com/shops/thebilder and there is a custom option for personalized text. I am planning to make some more test shots with Lieberkühn reflectors soon, so stay tuned!

First tests of 3D printed Lieberkühn reflectors

Here I will report my initial tests of my Lieberkühn reflector designs, “hot” off the 3D printers at Shapeways. DSC_0503

I am testing a squeeze-to-attach Lieberkühn that roughly fits a Canon f/3.5 20mm focal length macro lens (above), and a 58mm threaded version (below), tested with a Canon 35mm f/2.8 manual tilt shift lens. I used a Canon auto macro bellows and a Nikon D5100 with an adapter for all test images.
DSC_0512 I haven’t added any reflective material to them yet, so they are essentially “Lieberkühn diffusers” for these tests. I used a domestic desk lamp with a 750 lumen halogen bulb to illuminate the specimens, for slightly off-axis trans illumination.

DSC_0528These are the legs on a cicada molt from last year’s 17-year brood. The photo was taken with the 35mm Canon tilt-shift lens at about the shortest macro-bellows distance possible.

DSC_0527

And here is a shot of the same view with the reflector attached. I used a 1/13 second exposures at ISO 1600 and f/5.6 for both shots.

DSC_0529

The large claws up front with (below) and without (above) the reflector. Again this was taken at f/5.6, an ISO 0f 1600, and 1/13 second exposure time. I increased the bellows distance slightly for this shot, increasing the magnification.

DSC_0530

Although the fill light is definitely better in the shots with the reflector, in some cases a photographer may prefer the image without using it, e.g. to bring out the small details with shadow. The cicada molt is partially transparent, giving a nice effect to the light transmitted through the subject.

I took the two photos of a leaf-cutter bee (Megachile genus, female) below with the same setup. The difference in lighting with and without the reflector is pretty drastic.

DSC_0524

DSC_0523

I made the next two pairs of photos using the 20mm macro lens and the squeeze Lieberkühn reflector. The photos contain some apparent lens flare resulting from the off-axis light source, manifesting as a slight general brightening (and resulting loss of contrast) in the middle of each image. I am not sure if the aberration is reduced with the addition of the reflector or if it just looks that way due to the rest of the image being brighter. Looks like a job for some quantitative comparisons, for the next post.

DSC_0499

DSC_0500

DSC_0498

DSC_0497

The position of the lamp and bellows stand were maintained for each pair of images. The bellows was set at the same distance but displaced between exposures to make room to attach the reflectors without disturbing the subjects, so the comparison images may be focused ever-so-slightly at different depths.

The lighting was definitely improved by the use of reflectors for these (mostly opaque) subjects. The images above were intended as a qualitative investigation, I will be looking into the performance and useability of the designs further.

As a final note, compare the print of the 58mm threaded reflector with the render from the STL file. The consistency is inhomogenous, with some bulges introduced during manufacture that were not part of the design file. Can’t say that I’m impressed with the print quality.

DSC_0532

render58mmLR

3D Printable Lens Hood Design

A lens hood is a shade that blocks out-of-frame light from reflecting off of the internals within the lens. This minimizes lens flares, so you can add them later in post. Just kidding.

Another form of lens flare is less obvious (and I don’t think J.J. Abrams uses it). It manifests as a haze across the majority of the frame making the image appear washed-out, and it never looks good. Unlike deliberate lens flares, it’s not obvious in the image itself where it comes from and doesn’t look dramatic.

To get the most effect from a lens hood, it needs to block out as much unwanted light as possible without actually showing up in the frame. This means that for any given lens at a certain focal length and field of view there will be a best angle for your lens hood.

The wikipedia article for angle of view gives an equation depending on the focal length and sensor size.

2cdot tan^{-1}(frac{d}{2f})

The variable d is the dimension of interest. For a lens hood with a simple circular cross section throughout the longest dimension should be used, e.g. the diagonal length of a typical rectilinear sensor. The doubling factor can be omitted if you want to work the angle in relation to the optical axis, rather than the total angle.

The lens hood below is a general purpose lens hood (also 3D printed) for lenses with a 58mm filter thread diameter. It flares out a bit, and the angle is wide enough to use with a ~27mm focal length lens.

DSC_0432

The images below show essentially the same 58mm diameter lens hood optimized for 16mm, 35mm, and 50mm, in order from left to right. The length of the hood in each case is 16mm. The shorter the focal length of the lens (and the larger the image sensor) the wider the angle, and the lens hood angle increases accordingly.

lensCapsEpi

lensCapsSide

lensCapsSideSide

So far, I have printed the general purpose lens hood, which errs on the side of wide-angle caution. Once I have the additional test pieces in hand, we’ll give ’em the old Pepsi challenge.

Designing 3D printable Lieberkühn Reflectors for macro- and micro-photography

Designing a Lieberkühn Reflectors for macro- and micro-photography

A Lieberkühn Reflector gets its name from one Johann Nathaniel Lieberkühn, who invented the speculum that bears his name which you may recognize from reflective headband decorations for doctor costumes. The name is generally changed from “speculum” to “reflector” when referring to optical reflectors used in photography and microscopy, perhaps because the term has drifted from its original Latin root meaning “mirror” to refer to probing instruments for dilating orifices.

DSC_0124smallDSC_0125

Lieberkühn reflectors were a way to bathe an opaque specimen in fill light. Lieberkühn reflectors and their use have unfortunately fallen by the wayside with the advent of modern conveniences like LEDs and fiber optic illumination. The above example from the collection of the Royal Microscopical Society displays a Lieberkühn on a simple microscope. In use, the reflector would be pointed towards the specimen, and fed light by a second mirror like the one on the rightmost microscope. Both of the microscopes pictured were on display at the Museum of the History of Science in Oxford

The working part of the Lieberkühn reflector is a parabolic mirror, which doesn’t add the spherical aberrations of hyper- or hypo-bolic configurations. As an added benefit, mirrors don’t tend to add chromatic dispersion or other aberrations associated with refraction (though they can effect polarisation). A parabola can be described as a a particular slice through a cone , but for the purposes of my first prototype, the functional description in cartesian coordinates will do.

y = alpha x^2
Where alpha depends on the focal length of the parabola.
alpha = 1 /4 f

To get a functional, 3-dimensional mirror, I describe the parabola in terms of the focal length and a given radius as a 2D trace and spin it with rotate_extrude() in OpenSCAD. Leaving an aperture in the middle leaves room for light to reach the objective. The reflector shown below has a 4mm central aperture for the objective, 16mm focal length and 32mm diameter.


anaglyphLieberkuhn

lieberkuhnFlat

I have sent a few prototypes (matched to particular lenses or objectives) to Shapeways for prototyping. After some characterisation these will appear on theBilder shoppe.