Building the high-resolution, motorized OpenFlexure Microscope (v7) using the Rodeostat kit

There were a few problems with sending commands through Python to the microscope, but it was just the outdated operating system that caused them. I wrote a quick program to stitch images together with manually entered distances to estimate the camera moving over by around a frame.

I am currently having a lot of trouble downloading the other image stitching program, and connecting the microscope to the internet.

Here are some of the outputted images





Here is my code because it doesn’t let me upload a .py file

import openflexure_microscope_client
m = openflexure_microscope_client.find_first_microscope()
from PIL import Image

p = m.position

x=int(input("how many frames in the x direction"))
y=int(input("how many frames in the y direction"))
focus = int(input("do you want it to autofocus every time (generally better images less precise alignment)"))

imagearray=[]
for i in range(x):
    imagearray.append([])


xframe = 3850
yframe = 2900

p["y"] -= (y+1)/2*yframe
p["x"] -= (x-1)/2*xframe
for i in range(x):
    for j in range(y):
        p['y'] += yframe
        m.move(p)
        if focus == 1:
            m.autofocus()
        im = m.capture_image()
        
        imagearray[i].append(im)
    p["y"] -= yframe*y
    p["x"] += xframe


verticalbars = []
for i in imagearray:
    images = []
    for x in i:
        images.append(x)
    widths, heights = zip(*(x.size for x in images))
    width = widths[0]
    height = heights[0]
    heightt = sum(heights)
    verticalbar = Image.new('RGB', (width, heightt))
    placeheight = (len(images)-1)*height
    for i2 in images:
        verticalbar.paste(i2, (0, placeheight))
        placeheight -= height
    verticalbars.append(verticalbar)

widths, heights = zip(*(x.size for x in verticalbars))
width = widths[0]
height = heights[0]
widtht = sum(widths)
finalimage = Image.new('RGB', (widtht, height))
placewidth = (len(verticalbars)-1)*width
for i2 in verticalbars:
        finalimage.paste(i2, (placewidth, 0))
        placewidth -= width
finalimage.show()


1 Like