Comparison of a pi-camera and a 20x optical lens

Here are photographs comparing the resolution of the Openflexure microscope using a pi-camera lens (top image) and a 20x optical lens (bottom image).

The position of the slide being viewed is different between the two images as the slide moved slightly when screwing the camera platform into the upright z-axis.

The image using the 20x optical lens is crisper than that using the pi-camera lens, however the pi-camera still offers a reasonably high resolution image and is more accessible.


The magnifications are also pleasingly similar!

Thanks for posting this. I have the same observations. The RPI Lens provides enough resolution and is cheap. In my opinion the 20x objective adds an unnecessary cost to the microscope.

Hi, is the pi lens included in the 3d printed parts or is it something to order separately? We are looking for the 20x objective but would like to test the scope without a need for an objective!

The Pi lens is removed from the Pi camera and reversed. See the instructions for the Basic optics module ( The camera may come with a lens removing tool as in the pictures on Step 5, or there is a 3D printed lens removal tool in the printed parts (seen in the background of the photos of Step 4). This part does not appear to be in the STL configurator, you will need to download all of the STLs and print picamera_2_lens_gripper.stl.

1 Like

What are you doing to get such exquisite images from the Pi camera + lens? Your images appear to have even illumination, flat field and vibrant color. I can get more or less even illumination with the auto-calibrate function, but I can’t manage to get flat field. There are always out-of-focus areas. This is not from the sample and it’s not from the orientation of the sample on the stage. I don’t know if it’s aberration or what…

@atbalogh, there are possibly three separate things.

Even illumination: This is the easiest as most of it is done in software by the autocalibration function for the camera. If you are on a server version before 2.10.0b1 it is worth upgrading as the newer autocalibration is much better. There is a small catch that of course the software does need some light to work with. It pays to disable flat field correction and then auto gain and shutter speed first to see how even your physical illumination is. Then adjust the illumination condenser to get it as even as you can. Adjust in x-y using the two slots where the illumination dovetail is screwed to the main body. This can be very fiddly, you do not need it perfect, but a very dark corner can be too much to correct in the software.

Vibrant colour: Partly this is again getting the illumination in the right place and using the newer autocalibration. It is also about your light source. Many ultrabright white LEDs actually emit very little green light. LEDs specified as ‘warm white’ are usually better, but if you really mind you need to find a supplier which has the spectrum on the datasheet. All white LEDs have a peak in the blue, you are looking for that to be not too dominant, and to avoid a deep valley between it and the yellow/red hump.

Flat focus field: This is more tricky to specify and diagnose. A curved or thick sample will clearly mean that you cannot get it all in focus at once. Samples above are thin sections on a slide so they are thin and flat. Problems in printing, or in the set-up of the printer can mean that the stage is not level. We have seen that with high magnification lenses that have a very small depth of field. You can check whether stage tilt is a problem by looking to see whether one side or corner is in focus, then the middle, then the opposite side or corner. Finally there is aberration in the optics. The lens from the Pi Camera is remarkably good, but it does need to be used as designed. The most important thing is for it to be the right way up, which is turned round after you take it from the camera. How to tell is explained in the build instructions. It also needs to be flat in the lens extension tube. Other than that it should just work.

Further comparison of different lenses

I have analysed a Motic LM Plan 20x/0.40 infinity lens, a Comar Optics 20x/0.40 lens, a Motic EC Plan 40x/0.65 infinity lens, a Motic LM Plan 50x/0.55 infinity lens and a Pi Camera to compare their image quality. The camera was calibrated and focused first manually then using the 3 levels of the autofocus function inbuilt in the Openflexure GUI. The photographs are of the following:

  • Tilia Stem
  • Cucurbita Stem
  • Rabbit Lymph Node

Tilia stem

Pi Camera

Comar Optics 20x/0.40 lens

Motic LM Plan 20x/0.40 infinity lens

Cucurbita stem

Pi Camera

Comar Optics 20x/0.40 lens

Motic LM Plan 20x/0.40 infinity lens

Rabbit Lymph node

Pi Camera

Comar Optics 20x/0.40 lens

Motic LM Plan 20x/0.40 infinity lens


The corners of the three images are better defined through the 20x lenses particulaly the Motic LM Plan 20x/0.40 infinity lens as all corners and the centre of the image are in focus. For the Pi Camera and Comar Optics 20x/0.40 lens, the cells in the top left and right corners and the black cell wall in the bottom left corner are slightly out of focus; these are much crisper when viewed using the Motic lens.

The images of the cucurbita stem when viewed through the Pi Camera and the 20x lenses are of similar definition and quality; the two 20x lenses are marginally crisper. You can also see that the magnification of the Motic LM Plan 20x/0.40 infinity lens is a bit greater than the other two lenses.

The definition of the rabbit lymph node through the 20x lenses is crisper than that through the Pi Camera and appears less hazy, particularly through the Comar Optics 20x/0.40 lens. As can be seen again, the magnification of the Motic lens is a bit greater than the other two lenses as the white pointed object in the bottom left corner and the black smear in the upper right corner are further apart than in the other two images.

Overall, the definition of the optics when viewed through the 20x lenses is crisper and is better defined than when using the Pi Camera, however the difference in definition is slight and the Pi Camera is good low cost option for observations.

The Motic and Comar Optics lenses both have their advantages and disadvantages; the Motic lens appears to have better definition at the corners of the frame, however its overall crispness is not as good as the Comar optics lens.

Comparison lenses with higher magnifications

There are two higher magnification lenses observed below, one is a Motic LM Plan 50x/0.55 infinity lens and the other a

Motic EC Plan 40x/0.65 infinity lens. For this comparison both lenses are used to observe the rabbit lymph node.

Motic EC Plan 40x/0.65 infinity lens

Motic LM Plan 50x/0.55 infinity lens

As can be seen above, the Motic LM Plan 50x/0.55 infinity lens has better definition than the Motic EC Plan 40x/0.65 infinity lens. It is easier to differentiate between the small cells dyed pink filling the majority of the frame with the LM Plan lens and the cellular definition can be seen more clearly in central pale pink region with this lens too. Counter to expectation, the magnifications of the two lenses appear similar when viewing this slide, this may be due to differences in the position of the slide.


1 Like

@atbalogh sorry to reply to an old thread - but I thought I’d mention that @JohemianKnapsody did some more systematic investigation into field flatness in his (admittedly 100x) microscope. He found that part of the problem was that the top of the microscope stage wasn’t perfectly flat - or at least that the top of the sample riser wasn’t perfectly flat. When he added some sheets of paper on one side as a shim, he was able to get nice flat images. As @WilliamW says, it’s possible to do a relatively simple experiment to distinguish between field curvature and field tilt - and it’s tilt than can be corrected by this method. It sounds like you would have noticed if this was your problem, but I thought it would do no harm to double-check!