コード例 #1
0
def storeImage(image):
    imageWidth = image[0]  # width of the image
    imageHeight = image[1]  # height of the image
    imageData = image[6]  # array of pixel values
    imageTimestamp = float(image[4]) + (
        (image[5] / 10000) * 0.01)  # timestamp of the image

    im = Image.fromstring("RGB", (imageWidth, imageHeight), imageData)
    im = im.resize((imageWidth / 10, imageHeight / 10))

    px = im.load()

    with open("images.txt", "a") as imagesFile:
        width, height = im.size
        for x in range(width):
            for y in range(height):
                if (2 * px[x, y][0] - px[x, y][1] - px[x, y][2]) / 2 < 50:
                    px[x, y] = (0, 0, 0)
                else:
                    px[x, y] = (255, 255, 255)

        for pixel in im.getdata():
            p1 = coding.inputCode(pixel[0])
            p2 = coding.inputCode(pixel[1])
            p3 = coding.inputCode(pixel[2])
            imagesFile.write(str(p1) + " " + str(p2) + " " + str(p3) + " ")
        imagesFile.write("\n")
コード例 #2
0
def storeImage(image):
    imageWidth = image[0]                                           # width of the image
    imageHeight = image[1]                                          # height of the image
    imageData = image[6]                                            # array of pixel values
    imageTimestamp = float(image[4]) + ((image[5] / 10000) * 0.01)  # timestamp of the image
    
    im = Image.fromstring("RGB", (imageWidth, imageHeight), imageData)
    im = im.resize((imageWidth / 10, imageHeight / 10))
    
    px = im.load()
    
    with open("images.txt", "a") as imagesFile:
        width, height = im.size
        for x in range(width):
            for y in range(height):
                if (2*px[x,y][0] - px[x,y][1] - px[x,y][2]) / 2 < 50:
                    px[x,y] = (0,0,0)
                else:
                    px[x,y] = (255,255,255)
        
        for pixel in im.getdata():
            p1 = coding.inputCode(pixel[0])
            p2 = coding.inputCode(pixel[1])
            p3 = coding.inputCode(pixel[2])
            imagesFile.write(str(p1) + " " + str(p2) + " " + str(p3) + " ")
        imagesFile.write("\n")
コード例 #3
0
def saveRGBValues(image):
    imageWidth = image[0]                                           # width of the image
    imageHeight = image[1]                                          # height of the image
    imageData = image[6]                                            # array of pixel values
    
    im = Image.frombytes("RGB", (imageWidth, imageHeight), imageData)
    im = im.resize((imageWidth / 10, imageHeight / 10))
    im = im.rotate(180)

    px = im.load()
    
    with open("image.txt", "w") as imageFile:
        width, height = im.size
        for x in range(width):
            for y in range(height):
                if (2*px[x,y][0] - px[x,y][1] - px[x,y][2]) / 2 < 50:
                    px[x,y] = (0,0,0)
                else:
                    px[x,y] = (255,255,255)
                    
        for pixel in im.getdata():
            p1 = coding.inputCode(pixel[0])
            p2 = coding.inputCode(pixel[1])
            p3 = coding.inputCode(pixel[2])
            imageFile.write(str(p1) + "\n" + str(p2) + "\n" + str(p3) + "\n")
コード例 #4
0
def saveRGBValues(image):
    imageWidth = image[0]                                           # width of the image
    imageHeight = image[1]                                          # height of the image
    imageData = image[6]                                            # array of pixel values
    
    im = Image.fromstring("RGB", (imageWidth, imageHeight), imageData)
    im = im.resize((imageWidth / 10, imageHeight / 10))
    
    with open("image.txt", "w") as imageFile:
        for pixel in im.getdata():
            p1 = coding.inputCode(pixel[0])
            p2 = coding.inputCode(pixel[1])
            p3 = coding.inputCode(pixel[2])
            imageFile.write(str(p1) + "\n" + str(p2) + "\n" + str(p3) + "\n")
コード例 #5
0
def saveRGBValues(image):
    imageWidth = image[0]  # width of the image
    imageHeight = image[1]  # height of the image
    imageData = image[6]  # array of pixel values

    im = Image.fromstring("RGB", (imageWidth, imageHeight), imageData)
    im = im.resize((imageWidth / 10, imageHeight / 10))

    with open("image.txt", "w") as imageFile:
        for pixel in im.getdata():
            p1 = coding.inputCode(pixel[0])
            p2 = coding.inputCode(pixel[1])
            p3 = coding.inputCode(pixel[2])
            imageFile.write(str(p1) + "\n" + str(p2) + "\n" + str(p3) + "\n")
コード例 #6
0
def storeImage(image):
    imageWidth = image[0]                                           # width of the image
    imageHeight = image[1]                                          # height of the image
    imageData = image[6]                                            # array of pixel values
    imageTimestamp = float(image[4]) + ((image[5] / 10000) * 0.01)  # timestamp of the image
    
    im = Image.fromstring("RGB", (imageWidth, imageHeight), imageData)
    im = im.resize((imageWidth / 10, imageHeight / 10))
    
    with open("images.txt", "a") as imagesFile:
        for pixel in im.getdata():
            p1 = coding.inputCode(pixel[0])
            p2 = coding.inputCode(pixel[1])
            p3 = coding.inputCode(pixel[2])
            imagesFile.write(str(p1) + " " + str(p2) + " " + str(p3) + " ")
        imagesFile.write("\n")