2013-10-23 1 views
4

여러 프레임을 가진 새로운 .tif 이미지를 만드는 데 사용할 픽셀 데이터가 있습니다. 이 일을 어떻게 하죠? 나는 파이썬 PIL을 시도했지만 필자가 쓰지 않은 다중 프레임 읽기를 지원한다는 것을 알았다. 작동하지 않는 시도는 아래를 참조하십시오. FreeImage 플러그인 NumPy와 및 scikit-image를 사용하여 예를 들어다중 프레임 .tif 파일 만들기

new_Image = Image.new("I;16", (num_pixels,num_rows)) 

for frame in range((len(final_rows)/num_rows)): 
    pixels = new_Image.load() 
    for row in range(num_rows): 
     row_pixel = final_rows[row].getPixels() 
     for pixel in range(num_pixels): 
      pixels[pixel,row] = row_pixel[pixel] 
    print frame 
    new_Image.seek(frame) 

답변

5

,이 모든 페이지가 동일한 데이터를 가지고 있다고 가정

import numpy as np 
from tifffile import imsave 
image = np.zeros((32, 256, 256), 'uint16') 
imsave('multipage.tif', image) 

:

import numpy as np 
from skimage.io._plugins import freeimage_plugin as fi 
image = np.zeros((32, 256, 256), 'uint16') 
fi.write_multipage(image, 'multipage.tif') 

또는 저장은 NumPy와 및 tifffile.py를 사용하는 비 압축 모양 및 유형이 없으며 추가 태그를 쓸 필요가 없습니다.