import skimage skimage.__version__ from matplotlib import pyplot as plt import numpy as np bright_raw = plt.imread('Pos60051.png') plt.imshow(bright_raw) bright_raw.dtype bright_raw.shape from skimage.filter import gaussian_filter bright_blurred = gaussian_filter(bright_raw, sigma=30) plt.imshow(bright_blurred) np.max(bright_blurred) np.max(bright_raw) # skimage.filter. from skimage.morphology import label # Threshold bright_regions = bright_blurred > 0.12 bright_regions.dtype np.unique(bright_regions[:, :, 2]) # Only G channel contains data label_regions = label(bright_regions[:, :, 1], neighbors=4, background=0) label_regions.dtype # Number of labels np.unique(label_regions) # or, simply, np.max(label_regions) # + 1 # plt.imshow(label_regions) plt.colorbar(plt.imshow(label_regions)) from skimage import measure intensity_regions = measure.regionprops(label_regions, ['MeanIntensity'], intensity_image=bright_raw[:, :, 1]) len(intensity_regions) coord_regions = measure.regionprops(label_regions, ['coords'], intensity_image=bright_raw[:, :, 1]) coord_regions[0]['coords'] np.where(label_regions==0) for i in xrange(len(intensity_regions)): print(intensity_regions[i]['MeanIntensity']) from skimage.feature import match_template np.where(label_regions==4) region_4 = bright_raw[720:780, 780:840] plt.imshow(region_4) region_matching = match_template(bright_raw[:, :, 1], region_4[:, :, 1]) plt.imshow(region_matching) plt.gray() plt.imshow(region_matching) plt.imshow(plt.imread('longtime_z006.png')) plt.axis('off')