t1=time.time()
	imagepath = ito.getimpath(folderpaths[i])
	imseq = ito.fullseqimport(imagepath)
	
	#Seperate out side and top views
	sidestack = imseq[:,0]
	topstack = imseq[:,1]
	
	#Complete edge detection and cross correlation for side images
	croppedsides=ito.cropper2(sidestack,cropside)
	#Cross correlation
	noshift=croppedbase
	xvals , allcorr = crco.xvtfinder(croppedsides,noshift,cutpoint,guassfitl)
	ito.savelistnp(folderpaths[i]+'correlationdata.npy',[xvals,allcorr])
	#Perform edge detection
	sideedges = ede.seriesedgedetect(croppedsides,sidebackground,*sideimaparam)
	ito.savelistnp(folderpaths[i]+'sideedgedata.npy',sideedges) #Save for later use
	
	#Complete edge detection for top view
	croppedtops=ito.cropper2(topstack,croptop)
	topedges = ede.seriesedgedetect(croppedtops,topbackground,*topimaparam)
	ito.savelistnp(folderpaths[i]+'topedgedata.npy',topedges) #Save for later use
	
	#analysis
	ttake = time.time()-t1
	print("%s completed in %d seconds." % (folderpaths[i], ttake))

#%%
'''
This code no longer involves the images and can run much faster
Also has bits that are most commonly changed (ie fitting functions etc)
#%%
folderpaths, foldernames, dropProp = ito.foldergen(os.getcwd())
#%%
#Edge detection and save
for i in range(len(folderpaths)):
    imagestack = ito.omestackimport(folderpaths[i])
    croppedimages = ito.cropper(imagestack, *croppoints)
    noshift = croppedbase
    #Find the cross correlation xvt and save to position arrays
    xvals, allcorr = crco.xvtfinder(croppedimages, noshift, cutpoint,
                                    guassfitl)
    ito.savelistnp(folderpaths[i] + 'correlationdata.npy', [xvals, allcorr])

    #Define no shift cropped image as first frame, could change easily if needed
    #Perform edge detection to get python array
    stackedges = ede.seriesedgedetect(croppedimages, background, *imaparam)
    ito.savelistnp(folderpaths[i] + 'edgedata.npy',
                   stackedges)  #Save for later use
    print(folderpaths[i] + ' completed')
    #Crop
#%%
for i in range(len(folderpaths)):
    print(folderpaths[i])
    PosvtArray = ito.openlistnp(folderpaths[i] + 'correlationdata.npy')[0][:,
                                                                           0]
    stackedges = ito.openlistnp(folderpaths[i] + 'edgedata.npy')
    stackedges = [
        arr[(arr[:, 1] < yanalysisc[1]) & (arr[:, 1] > yanalysisc[0])]
        for arr in stackedges
    ]
    #Fit the edges and extract angles and positions
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)
#%%
noshift = croppedbase
#Find the cross correlation xvt and save to position arrays
xvals, allcorr = crco.xvtfinder(allimages, noshift, cutpoint, guassfitl)

np.save(dataDR + foldername + 'CCorcents.npy', xvals)
np.save(dataDR + foldername + 'CCorall.npy', allcorr)

#%%
stackedges = ede.seriesedgedetect(allimages, background, *imaparam)
ito.savelistnp(os.path.join(specfolder, 'edgedata.npy'), stackedges)
#Fit the edges and extract angles and positions
#%%
stackedgecrop = [
    arr[(arr[:, 1] < yanalysisc[1]) & (arr[:, 1] > yanalysisc[0])]
    for arr in stackedges
]
dropprops = df.edgestoproperties(stackedgecrop, pixrange, fitfunc, fitguess)
AnglevtArray, EndptvtArray, ParamArrat, rotateinfo = dropprops
ito.savelistnp(os.path.join(specfolder, 'fitparams.npy'), dropprops)

#%%
plt.plot(stackedges[150][:, 0], stackedges[150][:, 1], '.', markersize=1)
plt.plot(stackedgecrop[150][:, 0], stackedgecrop[150][:, 1], '.')
rotedges = df.xflipandcombine(df.rotator(stackedges[150], -.007, 0, 217))
Exemple #4
0
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)

#%%
dt = 300
mperpix = 0.75e-6
timedat = np.linspace(0, dt * serieslength, serieslength)
xstart = comlocs[0, 0]
ystart = comlocs[0, 1]
xshifted = (comlocs[:, 0] - xstart) * 0.75e-6
yshifted = (comlocs[:, 1] - ystart) * 0.75e-6
RMS = np.sqrt(xshifted**2 + yshifted**2)
plt.plot(timedat, xshifted)
plt.plot(timedat, yshifted)