示例#1
0
    v = np.linspace(0, s[0], s[0])
    h = np.linspace(0, s[1], s[1])
    sh = 50.
    sv = 75.
    alpha = -0.0
    for i in range(s[1]):
        BKGD[:, i] = 0.0 + 0.1 * (1.0 - np.random.rand(s[0]))
        IMGT[:, i] = 0.0 + 0.1 * (1.0 - np.random.rand(s[0])) + np.exp(
            -(v - np.mean(v) - alpha * (h[i] - np.mean(h)))**2 /
            (2. * sv**2)) * np.exp(-(h[i] - np.mean(h))**2 / (2. * sh**2))
        IMG = IMGT - BKGD

# display raw image
plt.figure()
plt.subplot(2, 2, 1)
imgtl.DisplayImage(IMG)
plt.title('raw data::' + FilenameBeam, fontsize=FTsize)
plt.axis('off')
print 'size raw:', np.shape(IMG)
# crop image
#    plt.figure()
plt.subplot(2, 2, 2)
# need to fix autocrop not to see image
#TODOFIX
# IMGc=imgtl.AutoCrop(IMG, bbox)
IMGc = imgtl.RemoveEdge(IMG, 100)
print 'size removed:', np.shape(IMGc)
imgtl.DisplayCalibratedProj(IMGc, cal, fudge)
plt.title('cropped' + FilenameBeam, fontsize=FTsize)
plt.axis('off')
# threshold image
示例#2
0
import ImageTool as imtl
import numpy as np
import pylab as pyl
import matplotlib.pyplot as plt
import pydefaults

# directory
upperfile = "./data_samples/X121_20150601//tight_focus/"
filename = "nml-2015-06-01-2205-23-13076.png"
# in um/pixel
cal = 9.
thres = 0.02

A = imtl.Load(upperfile + filename)
imtl.DisplayImage(A)
plt.title("raw: " + filename, fontsize=24)
B = imtl.AutoCrop(A, 100)
C = imtl.Threshold(B, thres)

plt.figure()
imtl.DisplayCalibratedProj(B, cal, 0.3)
plt.xlabel('x ($\mu$m)', fontsize=24)
plt.ylabel('y ($\mu$m)', fontsize=24)
plt.title("cal: " + filename, fontsize=24)
plt.tight_layout()
plt.show()