我有2个二进制图像(uint16,[512,512])ROI位于确切的中心,如何获得这些二进制图像(image1.dat和image2.dat)的ROI并计算平均强度之间的差异那两个ROI并将其保存为python中的PDF。请帮帮我。
由于
答案 0 :(得分:1)
您应该使用[numpy][1]
。可以使用不同的模块完成并保存图像。我在这里使用numpy,但有other possibilities:
import numpy as np
#Load the image using numpy
shape = (512, 512)
im1 = np.fromfile('image1.dat', 'uint16').reshape(shape)
im2 = np.fromfile('image2.dat', 'uint16').reshape(shape)
#extract the ROI
im1_roi = im1[100:400,150:350]
im2_roi = im2[100:400,150:350]
#Get the difference and save to BMP
im_difference = im1_roi-im2_roi
result = Image.fromarray(im_difference)
result.save('out.bmp')
#Get the MEAN of the intensities and compute the difference
im_mean_difference = np.mean(im1_roi)-np.mean(im2_roi)
print im_mean_difference