Skip to content

Commit 09010b8

Browse files
author
Mathijs van Gorcum
committed
numpy int alias is deprecated
1 parent d70c10c commit 09010b8

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

drop_analysis/edge_analysis.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ def analysis(edgeleft,edgeright,baseinput,framesize,k=100,PO=3,fittype='Polyfit'
1010
"""
1111
import numpy as np
1212

13-
#use shapely linestrings to find the intersectionpoints between the edges and baseline
13+
#use shapely linestrings to find the intersection points between the edges and baseline
1414
baseline=LineString(baseinput)
1515
rightline=LineString(np.column_stack((edgeright,(range(0,framesize[0])))))
1616
leftline=LineString(np.column_stack((edgeleft,(range(0,framesize[0])))))
1717
leftcontact=baseline.intersection(leftline)
1818
rightcontact=baseline.intersection(rightline)
19-
fitpointsleft=edgeleft[range(np.int(np.floor(leftcontact.y)),np.int(np.floor(leftcontact.y)-k),-1)]
19+
fitpointsleft=edgeleft[range(int(np.floor(leftcontact.y)),int(np.floor(leftcontact.y)-k),-1)]
2020

2121
#if no edge was detected the value is set to 0 (ie. the edge of the image) so discard all these points
2222
if any(fitpointsleft==0):
2323
fitpointsleft=np.delete(fitpointsleft,range(np.argmax(fitpointsleft==0),k))
24-
fitpointsright=edgeright[range(np.int(np.floor(rightcontact.y)),np.int(np.floor(rightcontact.y)-k),-1)]
24+
fitpointsright=edgeright[range(int(np.floor(rightcontact.y)),int(np.floor(rightcontact.y)-k),-1)]
2525
if any(fitpointsright==0):
2626
fitpointsright=np.delete(fitpointsright,range(np.argmax(fitpointsright==0),k))
2727

@@ -46,20 +46,20 @@ def volumecalc(leftcontact,rightcontact,edgeleft,edgeright):
4646
"""
4747
import numpy as np
4848
dropvolume=0
49-
for height in range (0,min(np.int(np.floor(leftcontact.y)),np.int(np.floor(rightcontact.y)))):
49+
for height in range (0,min(int(np.floor(leftcontact.y)),int(np.floor(rightcontact.y)))):
5050
dropvolume=dropvolume+np.pi*np.square((edgeright[height]-edgeleft[height])/2)
5151
#using cylindrical slice we calculate the remaining volume
5252
slantedbasediff=max(np.floor(leftcontact.y),np.floor(rightcontact.y))-min(np.floor(leftcontact.y),np.floor(rightcontact.y))
5353
#we assume that the radius is constant over the range of the slanted baseline, for small angles this is probably accurate, but for larger angles this can result in a significant error.
54-
baseradius=(edgeright[np.int(min(np.floor(leftcontact.y),np.floor(rightcontact.y)))]-edgeleft[np.int(min(np.floor(leftcontact.y),np.floor(rightcontact.y)))])/2
54+
baseradius=(edgeright[int(min(np.floor(leftcontact.y),np.floor(rightcontact.y)))]-edgeleft[int(min(np.floor(leftcontact.y),np.floor(rightcontact.y)))])/2
5555
dropvolume=dropvolume+.5*np.pi*np.square(baseradius)*slantedbasediff
5656
return dropvolume
5757

5858
def centerofgravitycalc(leftcontact,rightcontact,edgeleft,edgeright):
59-
yvarleft =np.append(leftcontact.y,range(np.int(np.floor(leftcontact.y)),0,-1))
60-
yvarright=np.append(rightcontact.y,range(np.int(np.floor(rightcontact.y)),0,-1))
61-
edgerightadd=np.append(rightcontact.x,edgeright[range(np.int(np.floor(rightcontact.y)),0,-1)])
62-
edgeleftadd=np.append(leftcontact.x,edgeleft[range(np.int(np.floor(leftcontact.y)),0,-1)])
59+
yvarleft =np.append(leftcontact.y,range(int(np.floor(leftcontact.y)),0,-1))
60+
yvarright=np.append(rightcontact.y,range(int(np.floor(rightcontact.y)),0,-1))
61+
edgerightadd=np.append(rightcontact.x,edgeright[range(int(np.floor(rightcontact.y)),0,-1)])
62+
edgeleftadd=np.append(leftcontact.x,edgeleft[range(int(np.floor(leftcontact.y)),0,-1)])
6363
totaledge=np.append(edgeleftadd,np.flip(edgerightadd))
6464
totalyvar=np.append(yvarleft,np.flip(yvarright))
6565
edgexy=np.column_stack((totaledge,totalyvar))
@@ -107,8 +107,8 @@ def analysellipse(fitpointsleft,fitpointsright,leftcontact,rightcontact,baseinpu
107107
from ellipse import LsqEllipse
108108
from shapely.geometry import LineString
109109
import numpy as np
110-
yvarleft=range(np.int(np.floor(leftcontact.y)),np.int(np.floor(leftcontact.y)-k),-1)
111-
yvarright=range(np.int(np.floor(rightcontact.y)),np.int(np.floor(rightcontact.y)-k),-1)
110+
yvarleft=range(int(np.floor(leftcontact.y)),int(np.floor(leftcontact.y)-k),-1)
111+
yvarright=range(int(np.floor(rightcontact.y)),int(np.floor(rightcontact.y)-k),-1)
112112
edge=np.append(fitpointsleft,fitpointsright)
113113
yvart=np.append(yvarleft,yvarright)
114114
totalfitpoints=np.array(list(zip(edge, yvart)))
@@ -117,7 +117,7 @@ def analysellipse(fitpointsleft,fitpointsright,leftcontact,rightcontact,baseinpu
117117

118118
#pointsfitted=reg.return_fit(1000)
119119
a,b,c,d,e,f=reg.coefficients
120-
y=np.linspace(min(np.int(np.floor(leftcontact.y)),np.int(np.floor(rightcontact.y)))-k,max(np.int(np.floor(leftcontact.y)),np.int(np.floor(rightcontact.y)))+k,framesize[0]*10)
120+
y=np.linspace(min(int(np.floor(leftcontact.y)),int(np.floor(rightcontact.y)))-k,max(int(np.floor(leftcontact.y)),int(np.floor(rightcontact.y)))+k,framesize[0]*10)
121121

122122
#split ellipse in two parts with a vertical cut, to find the contact points
123123
#xellipse1&2 are just the function for ellipse solved for x(y)

drop_analysis/edge_detection.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ def subpixel_detection(image,thresh,mode):
1111
"""
1212
edge detection, allowing for two subpixel detection methods
1313
"""
14-
erffitsize=np.int(40)
14+
erffitsize=int(40)
1515
framesize=image.shape
1616
edgeleft=np.zeros(framesize[0])
1717
edgeright=np.zeros(framesize[0])
1818
for y in range(framesize[0]-1): #edge detection, go line by line on horizontal
1919
edgeleft[y]=np.argmax(image[y,0:framesize[1]]<thresh) #edge detection on pixel scale
20-
edgeright[y]=np.int(framesize[1]-np.argmax(image[y,range(framesize[1]-1,0,-1)]<thresh))
20+
edgeright[y]=int(framesize[1]-np.argmax(image[y,range(framesize[1]-1,0,-1)]<thresh))
2121
if mode == 'Linear':
2222
leftsubpxcorr,rightsubpxcorr=linear_subpixel(edgeleft[y],edgeright[y],image[y,:],thresh)
2323
elif mode == 'Errorfunction':
@@ -35,11 +35,11 @@ def linear_subpixel(edgeleft,edgeright,imagerow,thresh):
3535
"""
3636
if edgeleft!=0:
3737
#subpixel correction with using corr=(threshold-intensity(edge-1))/(intensity(edge)-intensity(edge-1))
38-
leftsubpxcorr=(thresh-np.float64(imagerow[np.int(edgeleft-1)]))/(np.float64(imagerow[np.int(edgeleft)])-np.float64(imagerow[np.int(edgeleft-1)]))-1
38+
leftsubpxcorr=(thresh-np.float64(imagerow[int(edgeleft-1)]))/(np.float64(imagerow[int(edgeleft)])-np.float64(imagerow[int(edgeleft-1)]))-1
3939
else:
4040
leftsubpxcorr=0
4141
if edgeright!=len(imagerow):
42-
rightsubpxcorr=(thresh-np.float64(imagerow[np.int(edgeright-1)]))/(np.float64(imagerow[np.int(edgeright)])-np.float64(imagerow[np.int(edgeright-1)]))-1
42+
rightsubpxcorr=(thresh-np.float64(imagerow[int(edgeright-1)]))/(np.float64(imagerow[int(edgeright)])-np.float64(imagerow[int(edgeright-1)]))-1
4343
else:
4444
rightsubpxcorr=0
4545
return leftsubpxcorr,rightsubpxcorr
@@ -51,14 +51,14 @@ def errorfunc_subpixel(edgeleft,edgeright,imagerow,erffitsize):
5151
def errorfunction(x,xdata,y): #define errorfunction to fit with a least squares fit.
5252
return x[0]*(1+sp.special.erf(xdata*x[1]+x[2]))+x[3] - y
5353
if (edgeleft-erffitsize)>=0 and (edgeleft-erffitsize)<=len(imagerow):
54-
fitparts=np.array(imagerow[range(np.int(edgeleft)-erffitsize,np.int(edgeleft)+erffitsize)]) #take out part of the image around the edge to fit the error function
54+
fitparts=np.array(imagerow[range(int(edgeleft)-erffitsize,int(edgeleft)+erffitsize)]) #take out part of the image around the edge to fit the error function
5555
guess=(max(fitparts)-min(fitparts))/2,-.22,0,min(fitparts) #initial guess for error function
5656
lstsqrsol=least_squares(errorfunction,guess,args=(np.array(range(-erffitsize,erffitsize)),fitparts)) #least sqaures fit
5757
leftsubpxcorr=-lstsqrsol.x[2]/lstsqrsol.x[1] #add the subpixel correction
5858
else:
5959
leftsubpxcorr=0
6060
if (edgeright-erffitsize)>=0 and (edgeright+erffitsize)<len(imagerow):
61-
fitparts=np.array(imagerow[range(np.int(edgeright)-erffitsize,np.int(edgeright)+erffitsize)])
61+
fitparts=np.array(imagerow[range(int(edgeright)-erffitsize,int(edgeright)+erffitsize)])
6262
guess=(max(fitparts)-min(fitparts))/2,.22,0,min(fitparts)
6363
lstsqrsol=least_squares(errorfunction,guess,args=(np.array(range(-erffitsize,erffitsize)),fitparts))
6464
rightsubpxcorr=-lstsqrsol.x[2]/lstsqrsol.x[1]

0 commit comments

Comments
 (0)