Get the ROI of two binary images and find difference of the mean image intesities between 2 ROI in python -
i have 2 binary images (uint16, [512,512]) there roi @ exact center, how can roi of both binary images(image1.dat , image2.dat) , calculate difference in mean intensities between 2 roi , save pdf in python. please me out.
thanks
you should use [numpy][1]
.loading , saving images can done different modules. here using numpy, there other possibilities:
import numpy np #load image using numpy shape = (512, 512) im1 = np.fromfile('image1.dat', 'uint16').reshape(shape) im2 = np.fromfile('image2.dat', 'uint16').reshape(shape) #extract roi im1_roi = im1[100:400,150:350] im2_roi = im2[100:400,150:350] #get difference , save bmp im_difference = im1_roi-im2_roi result = image.fromarray(im_difference) result.save('out.bmp') #get mean of intensities , compute difference im_mean_difference = np.mean(im1_roi)-np.mean(im2_roi) print im_mean_difference
Comments
Post a Comment