Image.fromarray는 np.uint8만 가능

HeyHo·2022년 10월 27일
0

Image.fromarray는 numpy to png로 변환해주는데
이 놈 까다로운게,

Image.fromarray(x)에서 x의 type을 가려서 받음.
x는 오직 0 ~ 255, uint8만 입력 가능함. int도 안됨. 오직 uint8만 가능.

ex)

def processing(input):
    input = input + 1
    input = input - input.min()
    input = input / (input.max() - input.min())
    input = input.permute(1,2,0).numpy()
    input = (input * 255).astype(np.uint8)
    return input
    
im = Image.fromarray(images)   
profile
Coputer vision, AI

0개의 댓글