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.