Focus Stacking with a Raspberry Pi – The Quest for Repeatability and Predictability

    Repeatability  – (of an experiment, etc) producing or capable of producing the same result again

    Predictabilityconsistent repetition of a state, course of action, behavior, or the like,making it possible to know in advance what to expect

    ………………………………..wouldn’t that be nice?

    Last Tuesday at Tetbury Camera Club we had an inspiring talk by Jay Myrdal who explained how he made stunning commercial images back in the day before Photoshop when it all had to be done in camera – a plate camera quite often. The techniques he explained were fascinating and the results were truly stunning. Some of his images involved taking action shots such as an exploding light bulb – this would be just a part of the image but he would have to shoot it over and over again to get all the timings of the effects just right. He built a rig to automate and adjust the various factors involved so he could tweak the important parameters knowing exactly what he had done beforehand and so migrate towards an optimal set up. He also scrupulously calculated all the angles involved in multi-layered super-imposed images to get things to look right from the perspective point of view.

    Double fly
    Double fly

    This got me thinking that I needed to apply his philosophy to my macro photography, which up to now I have been carrying out on a rather hit and miss basis in terms of choice of lens configuration, and adjustment of stacking parameters. So I decided to apply some of Jay’s thinking to the matter.

    My rig is pretty much automated already, but the key issue here is recording all the parameters that I have used for each stack in enough detail to enable evaluative decisions to be made after processing (which may be some time later) so that the parameters for the next stack can be improved or consolidated. I already have lots of bits of paper lying around with scribblings of what I have done but no real way of tying these back to the images I have processed. And not everything is written down anyway. It needed organisation and preferably automation.

    I was already in the process of updating my Raspberry Pi Python software for my focus stacker to add refinements based on the last few months shooting. As a result, my mind was in tune (as much as it will ever be!) with Python 2.7 and Tkinter, and then two and two came together and for once made four! I decided to automate the logging of my focus stacks using my RPi.

    I won’t bore you with the details of how I did it – programming and more programming is all you need to know! But this is what it now does.

    There are some user interface windows to enter information that the RPi doesn’t know such as what camera is being used, the lens configuration, the subject matter, and the camera settings. You can also enter a note for each stack. The software gathers up all the info it already knows about the shoot such as the near and far focus points, focus increment and so on; date and time stamps the log, gives it the next shoot number and then (and only) when the shoot sequence button is pressed, the whole lot is appended to a .csv log file.

    The .csv file can be read by Exel and as long as the camera and RPi are telling the same time I can figure out which log goes with which image stack.

    One hiccup in proceedings is that the RPi is not on the internet, and so the RPi cannot find out automatically what time it is. That’s because it doesn’t have its own real time clock and battery (it apparently kept the cost down) and relies on the internet to reset its clock each time it is turned on. No internet, and the clock just restarts from where it left off last time it was on! Not terribly useful. At the moment I have to enter the time manually into the RPi when I turn it on – it is very easy [sudo date -s “Sat, October 18, 2014 17:21:00] for example. But I might forget.

    What would be better is to get the lap top to tell the RPI what the time is. That is all within the realms of possibility. I would have to set up the lap top as an NTP server which Windows 7 does support. It seems to require some mining in the registry to do this, something I am not too keen on doing. There is plenty of advice on the internet, but I will have to nerve myself up before trying this. Then you have to rummage in the RPi’s software settings too. I may have to get my (no-longer) resident expert to help me on this some time.

    Finally, I have also made some measurements to establish/check the exact magnifications of my various lens configurations, and have produced a chart to enable me to select the best lens configuration for a given subject size. It requires measurement of the subject height to get it right first time – something I had not been bothering to do. The chart is shown below

    lens data
    lens data


    New Birmingham image gallery after recent trip

    Selfridges Store - Street Entrance
    Selfridges Store – Street Entrance

    Last Wednesday a group of us from Tetbury Camera Club made a visit to Birmingham (England not Alabama!) for the purposes of some photography. We organise regular photography trips within striking distance of Tetbury, including quite a few to London, but this was our first time to Birmingham ensemble. I used to work in Birmingham and so it had been reasonably straighforward to devise a route taking in the best bits of the centre of town. But it was ten years ago that I last ventured into Birmingham and a lot has changed since then – for the better – notably the construction of the splendid new library and the increase in the pedestrianisation of the streets in the centre. Birmingham, motown of the Midlands, had finally all but banished the motorcar from the centre of town – and what an improvement.



    The highlights of the trip were:

    1. Selfridges and the Bull Ring
    2. Snow Hill area
    3. Cathedral Green
    4. Victoria Square
    5. Council House
    6. Town Hall
    7. Centenial square showing library etc.
    8. Library Roof for a panoramic view of the city
    9. Malthouse Wharf area
    10. Gas Street Basin – aerial tour – click here
    11. The cube – aerial tour click here

    I have started a new gallery devoted to images of Birmingham. We will be going back
    soon for another session.

    Curved Reflections on Water – An Explanation?

    On a recent trip to Canary Wharf with fellow photographers from Tetbury Camera Club for some night photography, we spent some time at Millwall Dock photographing the reflections. When we got home and started processing the images we were looking at curved reflections that seemed to bear no resemblance to what you would expect to see. Here is an example. Some were much more pronounced than this one. Some curved to the left, some to the right.

    Curved Reflection
    Curved Reflection in Millwall Dock, Isle of Dogs

    In searching for reason for these curved reflections there were no plausible explanations on offer until it came up in discussion with Jim who provided an answer after just a few seconds of thought! And after a lot more thought on my part and with the aid of some pencil sketches I came to the conclusion that he is right.

    First of all, this is what it is not…. anything to do with the the lens, or the mirror (mine is a NEX-7 which is mirrorless!).  It is all to do with the reflection of light off the surface of the ripples being blown across the water surface.

    Look at the image above and you will see that the reflections are not representative of the illuminated scene but are reflections of the lightest parts of the scene smeared in a band vertically across the water surface – the obvious examples are the cyan colour of the JP Morgan sign and the purple colour reflected from the horizontal lights on top of the building to right of centre.

    The image above  is an HDR fusion image from individual shots ranging from 0.25 to 15 seconds – some  long exposures. So within the exposure time of the images making up the water we would expect the ripples being blown across the surface to have travelled many centimeters.

    So what is happening. If we take the simple example of waves moving towards the camera and think of a wave as being a mirror we can see how the reflections are smeared by reference to the diagram below. At the point where the wave is flat (A) – at its peak and the bottom of the trough – you should see the normal reflection as if the surface was a mill pond. The leading surface of a wave will reflect light into the camera lens and the trailing surface will also reflect light into the camera lens and here is where the smearing occurs. What I think is happening is that the very bright lights – say the JP Morgan sign – overwhelm everything else above and below. So on the water surface beyond where the reflections of the letters would be for a dead calm surface we see reflections off the leading surface of the ripples (C). And conversely, closer to the camera we see reflections from the trailing surface of the ripples (B). Because the ripples/waves are marching across the water the reflections are merged together and the brightest light dominates. If the ripples are going away from the camera then swap trailing surface for leading surface. The whole effect is accentuated by the long exposure.

    Diagram Smeared Reflections
    Diagram showing how the reflection is smeared by the surface ripples on the water.

    So far so good, but what about the curve? That is explained by the fact that the ripples are not marching directly towards or away from the camera but are at an angle. Depending on the orientation angle of the ripples (which way the wind is blowing), and the position of the camera relative to the subject, the reflection will appear to curve to the left or to the right. So in our case, if my theory is correct, the wind is blowing the waves in a direction that is from near left to far right or far right to near left. Which direction, forward or back, does not matter (just the orientation) but for the sake of this explanation I am assuming far right to near left. In this case the rear edge/surface of the wave is acting as a mirror at an angle and reflects light that should be heading to the left of our camera back into our lens making it appear to come from somewhere to the left of where it should be. And by the same reasoning where we would expect to see a reflection on the right side of the vertical band of light, the rear surface of the ripple reflects the light away from the lens making the water appear dark. If the ripples were orientated far left to near right the reflection would curve to the right.

    Curved Reflection
    Diagram showing how reflection is curved



    Here is the un-cropped, unprocessed 0.25 second exposure shot with the exposure turned up in Lightroom so you can see what is happening on the surface of the water; and you can see the direction of the ripples on the water surface, running far right to near left as expected.


    reflections curved to left
    Reflections curved left showing ripples orientated far right to near left


    And below you can see the opposite effect to the one above, with the curves running the opposite way,and the ripples running the opposite way too. QED? I hope so!

    Curved reflections to right
    HDR image of Millwall Dock with reflections curved to the right this time.
    curved reflections
    Here is the shortest  un-cropped exposure of the HDR set with the exposure cranked up in LR to reveal ripples running far left to near right – exactly as predicted.

What’s it all about?

Here are my jottings about my photographic projects and activities. I have been working on a focus stacking macro photography rig. There are quite a few posts about that. In addition I write about other photographic activities as and when!


Category Specific RSS


Warning: A non-numeric value encountered in /home/public/mhp_blog/wp-content/plugins/ultimate-social-media-icons/libs/sfsi_widget.php on line 238