Example #1
0
def run_slm():
    slm = slmpy.SLMdisplay(isImageLock=False)
    resX, resY = slm.getSize()
    #testIMG = np.round(image2pixelarray(file)).astype('uint8')
    #file = input('Type file name: ')
    #file = file+'.jpg'
    file = sys.argv[1]
    testIMG = image2pixelarray(file).astype('uint8')
    slm.updateArray(testIMG)
    SLMcorrectionMask = np.zeros((ImgResY, ImgResX), dtype="uint8")

    SLMbmpMask = cv2.imread(correctionMaskFile)
    SLMbmpMask = cv2.cvtColor(SLMbmpMask, cv2.COLOR_BGR2GRAY)

    rows, cols = SLMbmpMask.shape

    SLMcorrectionMask[0:rows, 0:cols] = SLMbmpMask

    return SLMcorrectionMask + image


if slmFlag == True:
    # create the object that handles the SLM array
    slm = slmpy.SLMdisplay(isImageLock=True)

    # retrieve SLM resolution (defined in monitor options)
    ImgResX, ImgResY = slm.getSize()
else:

    ImgResX = 792
    ImgResY = 600

ImgCenterX = ImgResX / 2
ImgCenterY = ImgResY / 2

x = np.linspace(0, ImgResX, ImgResX)
y = np.linspace(0, ImgResY, ImgResY)

# initialize image matrix
Example #3
0
import time
import numpy as np
import matplotlib.pyplot as plt
from scipy.misc import imresize

is_display = True  # swith to use SLM or not

if (is_display):
    import slmpy
    slm = slmpy.SLMdisplay(isImageLock=True, monitor=2)
    resX, resY = slm.getSize()

resX, resY = 1920, 720
resX_disp, resY_disp = 1920, 720

# We use images twice smaller than the resolution of the slm
ImgResX = resX // 2
ImgResY = resY // 2

mydistance = 10  # distance between peaks
npattern = 50  # how many times the pattern has to be displayed along X/Y
i = 0
dx = 0
dy = 0
for dx in range(mydistance):
    for dy in range(mydistance):
        subpattern = np.zeros((mydistance, mydistance))
        subpattern[dx, dy] = 1
        mypattern = np.tile(subpattern, (npattern, npattern))
        testIMG = np.zeros((resY, resX))
        if False:
Example #4
0
import slmpy
import time

slm = slmpy.SLMdisplay(isImageLock=False)
resX, resY = slm.getSize()
X, Y = np.meshgrid(np.linspace(0, resX, resX), np.linspace(0, resY, resY))
# The image we want on the green layer
greenIMG = np.round((2**8 - 1) * (0.5 + 0.5 * np.sin(2 * np.pi * X / 50)))
# We need a third dimension corresponding to the color layer
greenIMG.shape = greenIMG.shape[0], greenIMG.shape[1], 1
# The two other layers are blank arrays
blankImage = np.zeros([greenIMG.shape[0], greenIMG.shape[1], 1])
# We merge the three layers in a (resY,resX,3) color array
color_array = np.concatenate((blankImage, greenIMG, blankImage),
                             axis=2).astype('uint8')
# The image is sent to the slm
slm.updateArray(color_array)
# Wait 10 seconds
time.sleep(10)
# Close the window
slm.close