PILImage as input?

How I will handle different PIL Images comming in different sizes one after the other?

I want to do a blur (which I need to check) and a change of color like make it more “green”.

I guess it should be something like this: https://github.com/taichi-dev/taichi/blob/master/examples/gui_image_io.py

But not sure, even more if images are of different shapes, say 3x200x150, then 3x280x280 and so on.

In fact, you don’t need PILImage, Taichi provides ti.imread for loading images.


import taichi as ti

## Load the image:
input_file_name = input('Enter the input image file name: ')
input_image = ti.imread(input_file_name)

## Process the image:
image = ti.var(ti.u8, input_image.shape)

def process():
    for i, j, k in image:
        image[i, j, k] = 255 - image[i, j, k]  # revert color


## Save the image:
output_image = image.to_numpy()


output_file_name = input('Enter the image file name to save: ')
ti.imwrite(output_image, output_file_name)
1 Like