croppedbase=ito.cropper2(noforce,cropside)
croppedsidechecks=[ito.cropper2(extreme1[0],cropside),ito.cropper2(extreme2[0],cropside)]
croppedtopchecks=[ito.cropper2(extreme1[1],croptop),ito.cropper2(extreme2[1],croptop)]


pixelsize=0.75e-6

#Cross correlation
cutpoint=20 # y pixel to use for cross correlation
guassfitl=20 # Number of data points to each side to use for guass fit

#Side Edge detection
sideimaparam=[-1*np.max(croppedsidechecks[0])/3,40,.05] #[threshval,obsSize,cannysigma]
sidebackground=False 

sidethreshtest=ede.edgedetector(croppedsidechecks[0],sidebackground,*sideimaparam)

#Top Edge detection
topimaparam=[-1*np.max(croppedtopchecks[0])/1.7,40,.05] #[threshval,obsSize,cannysigma]
topbackground=False 

topthreshtest=ede.edgedetector(croppedtopchecks[0],topbackground,*topimaparam)
topthreshtest2=ede.edgedetector(croppedtopchecks[1],topbackground,*topimaparam)

ax1 = fig.add_subplot(gs[:2, :2])
ax2 = fig.add_subplot(gs[0, 2:])
ax3 = fig.add_subplot(gs[1, 2:])
ax4 = fig.add_subplot(gs[1:, :2])
ax5 = fig.add_subplot(gs[1:, 2:])

#%%
#Cross correlation
cutpoint = 50  # y pixel to use for cross correlation
guassfitl = 20  # Number of data points to each side to use for guass fit

#Edge detection
imaparam = [-20, 20, .01]  #[threshval,obsSize,cannysigma]
fitfunc = df.pol2ndorder  #function ie def(x,a,b) to fit to find properties
fitguess = [0, 1, 1]
clinyguess = 214  #Guess at the center line (helpful if parts of pipette are further than droplet)
pixrange = [60, 25, 25]  #xy bounding box to use in fit
#Specify an image to use as a background (needs same dim as images being analysed)
#Or can set to False
background = False

testedge = ede.edgedetector(croppedex1, background, *imaparam)
fig = plt.figure(figsize=(8, 4))
plt.imshow(croppedex1, cmap=plt.cm.gray)
plt.plot(testedge[:, 0], testedge[:, 1], 'b.', markersize=1)
croppedforfit = testedge[(testedge[:, 1] < yanalysisc[1])
                         & (testedge[:, 1] > yanalysisc[0])]
testfit = df.datafitter(croppedforfit, False, pixrange, 1, fitfunc, fitguess)
xvals = np.arange(0, 10)
yvals = df.pol2ndorder(xvals, *testfit[-2])
plt.plot(xvals + testfit[0], yvals + testfit[1], 'r-')
plt.ylim(np.min(testedge[:, 1]), np.max(testedge[:, 1]))
#%%
specfolder = "E:/SpeedScan/5umreturn_1/"
allimages = ito.omestackimport(specfolder)
allimages = ede.cropper(allimages, *croppoints)
#%%
ax[0, 1].imshow(testimage2)

ax[1, 0].imshow(croptest1)
ax[1, 1].imshow(croptest2)

#%%
#check that edge detection is working properly

#Create a zero background or could import one and crop
background = np.zeros(croptest1.shape)

#[threshval,obsSize,cannysigma]
imaparam = [-30, 20, .05]

#Have two edges
edges1 = ede.edgedetector(croptest1, background, *imaparam)
edges2 = ede.edgedetector(croptest2, background, *imaparam)

#Colormap to show fitting
colors = [(0, 1, 0, c) for c in np.linspace(0, 1, 100)]
cmapg = mcolors.LinearSegmentedColormap.from_list('mycmap', colors, N=5)

#Plot to show
plt.imshow(croptest2, cmap=plt.cm.gray)
plt.plot(edges2[:, 0], edges2[:, 1], 'r.', markersize=1)

#%%

#Crop and find the edges for all of the images
croppedimages = ede.cropper(imagestack, x1c, x2c, y1c, y2c)
alledges = ede.seriesedgedetect(croppedimages, background, *imaparam)
Exemple #4
0
#Or just one file
#%%
plt.imshow(imageframes[100])
croppoints = (np.floor(plt.ginput(2)))
croppoints = croppoints.T.flatten().astype(int)
imtest = ito.cropper(imageframes[100], *croppoints)
plt.imshow(imtest)
#%%
#Edge detection
plt.imshow(imtest, cmap=plt.cm.gray)
imaparam = [-100, 20, .05]  #[threshval,obsSize,cannysigma]
#Specify an image to use as a background (needs same dim as images being analysed)
#Or can set to False
background = False

threshtest = ede.edgedetector(imtest, background, *imaparam)
plt.plot(threshtest[:, 0], threshtest[:, 1], 'g.')
comloc = np.mean(threshtest, axis=0)
plt.plot(*comloc, 'ro')
lengtharr = imageframes.shape[0]

#%%
serieslength = imageframes.shape[0]
croppedimages = ito.cropper(imageframes, *croppoints)
#%%
edgevalsdust = ede.seriesedgedetect(croppedimages, background, *imaparam)
comlocs = np.zeros([serieslength, 2])
for i in range(serieslength):
    comlocs[i] = np.mean(edgevalsdust[i], axis=0)

#%%
importlib.reload(ede)
import PlateauAnalysis as planl
importlib.reload(planl)

#Remove to avoid cluttering path
sys.path.remove('./Tools') #Remove tools from path

#Set working directory to data location
os.chdir(dataDR)


#%%

testimage = imageio.imread('main.tif')

edges = ede.edgedetector(testimage,False,-20,500,2)
plt.imshow(testimage,cmap='gray')
#plt.plot(edges[:,0],edges[:,1],'r.')

#%%
oneslice=testimage[:,19]

from scipy.signal import savgol_filter, butter, filtfilt
from scipy.signal import filtfilt



def butter_lowpass(cutoff, fs, order=5):
    nyq = 0.5 * fs
    normal_cutoff = cutoff / nyq
    b, a = butter(order, normal_cutoff, btype='low', analog=False)